wined3d: Fix mapping of SV_VertexID to gl_VertexID.
commit60d9211f0f2862c503fdb1fe229bc96f2cc06be4
authorJózef Kucia <jkucia@codeweavers.com>
Thu, 22 Nov 2018 16:49:04 +0000 (22 17:49 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Fri, 23 Nov 2018 19:17:45 +0000 (23 20:17 +0100)
tree3361873d02618724137493b866a2d5bfef184e4b
parentceef4e77cf8cc62fbfb5a1bbedf5e9cf0d71c135
wined3d: Fix mapping of SV_VertexID to gl_VertexID.

Based on a patch by Andrew Wesie.

In Direct3D, SV_VertexID generally starts from zero. In OpenGL,
gl_VertexID starts from "first" parameter passed to glDrawArrays(), or
from "baseVertex" parameter for indexed draw calls.  The
GL_ARB_shader_draw_parameters extension doesn't help us much because
gl_BaseVertexARB is zero for non-indexed draw calls [1]. If
gl_BaseVertexARB would be equal to "first" for non-indexed draw calls,
we could simply use gl_VertexID - gl_BaseVertexARB.

After this commit, SV_VertexID is still wrong for indirect draw calls
because we cannot easily access the "first" field from struct
DrawArraysIndirectCommand in a vertex shader.

[1] - The ARB_shader_draw_parameters spec says that "In the case where
the command has no <baseVertex> parameter, the value of
<gl_BaseVertexARB> is zero."

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
dlls/wined3d/cs.c
dlls/wined3d/glsl_shader.c
dlls/wined3d/wined3d_private.h