Discussion:
[v2 2/2] d3d11/tests: Add test of SV_VertexID.
Józef Kucia
2016-11-21 00:43:38 UTC
Permalink
+static void test_sm4_vertexid(void)
I would drop the "sm4" prefix.
+ static const D3D11_INPUT_ELEMENT_DESC layout_desc[] =
+ {
+ { "SV_Position", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "SV_VertexID", 0, DXGI_FORMAT_R32_UINT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ };
I don't think that SV_VertexID should be
Henri Verbeet
2016-11-22 14:02:52 UTC
Permalink
@@ -424,6 +424,9 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
device_invalidate_state(cs->device, STATE_BASEVERTEXINDEX);
}
+ state->base_vertex_index = op->indexed ? op->base_vertex_idx : op->start_idx;
I don't think you can do this, the modified state would be visible to
the application through wined3d_stateblock_capture() and
wined3d_device_get_base_vertex_index().
+ device_invalidate_state(cs->device, STATE_BASEVERTEXINDEX);
State invalidation isn't free, so it may be better to avoid doing this
unnecessarily. But if you do do this unconditionally, the invalidation
of STATE_BASEVERTEXINDEX a few lines above becomes redundant.
@@ -1793,7 +1800,8 @@ static void shader_glsl_declare_generic_vertex_attribute(struct wined3d_string_b
if (e->sysval_semantic == WINED3D_SV_VERTEX_ID)
{
- shader_addline(buffer, "vec4 vs_in%u = vec4(intBitsToFloat(gl_VertexID), 0.0, 0.0, 0.0);\n",
+ shader_addline(buffer, "uniform int base_vertex;\n");
+ shader_addline(buffer, "vec4 vs_in%u = vec4(intBitsToFloat(gl_VertexID - base_vertex), 0.0, 0.0, 0.0);\n",
index);
return;
}
Note that in principle this code would do the wrong thing when
ARB_draw_elements_base_vertex is not supported. The reason it works in
practice is that SV_VertexID is a SM4+ feature, and SM4 requires GL
3.2, which implies ARB_draw_elements_base_vertex. Th
Henri Verbeet
2016-11-22 14:02:59 UTC
Permalink
+ static const D3D11_INPUT_ELEMENT_DESC layout_desc[] =
+ {
+ { "SV_Position", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "SV_VertexID", 0, DXGI_FORMAT_R32_UINT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ };
I don't think that SV_VertexID should be a part of the input layout.
I'll note that that's an unusua

Loading...