Module: wine Branch: master Commit: 88f230b56e13c26e4b7a2040bc103850ef6f0078 URL: http://source.winehq.org/git/wine.git/?a=commit;h=88f230b56e13c26e4b7a2040bc...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Mon Mar 23 09:17:16 2015 +0100
d3d10core: Also pass unused input layout elements to wined3d.
While these won't be used by the shader, they potentially affect the calculated offset for WINED3D_APPEND_ALIGNED_ELEMENT elements.
---
dlls/d3d10core/inputlayout.c | 41 +++++++++++++++++++--------------------- dlls/d3d9/vertexdeclaration.c | 2 +- dlls/wined3d/context.c | 6 +++++- dlls/wined3d/vertexdeclaration.c | 2 +- include/wine/wined3d.h | 3 +++ 5 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/dlls/d3d10core/inputlayout.c b/dlls/d3d10core/inputlayout.c index bb3e4c5..fa08822 100644 --- a/dlls/d3d10core/inputlayout.c +++ b/dlls/d3d10core/inputlayout.c @@ -41,7 +41,7 @@ static HRESULT isgn_handler(const char *data, DWORD data_size, DWORD tag, void *
static HRESULT d3d10_input_layout_to_wined3d_declaration(const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code, SIZE_T shader_byte_code_length, - struct wined3d_vertex_element **wined3d_elements, UINT *wined3d_element_count) + struct wined3d_vertex_element **wined3d_elements) { struct wined3d_shader_signature is; HRESULT hr; @@ -61,33 +61,32 @@ static HRESULT d3d10_input_layout_to_wined3d_declaration(const D3D10_INPUT_ELEME HeapFree(GetProcessHeap(), 0, is.elements); return E_OUTOFMEMORY; } - *wined3d_element_count = 0;
for (i = 0; i < element_count; ++i) { + struct wined3d_vertex_element *e = &(*wined3d_elements)[i]; + const D3D10_INPUT_ELEMENT_DESC *f = &element_descs[i]; UINT j;
+ e->format = wined3dformat_from_dxgi_format(f->Format); + e->input_slot = f->InputSlot; + e->offset = f->AlignedByteOffset; + e->output_slot = WINED3D_OUTPUT_SLOT_UNUSED; + e->method = WINED3D_DECL_METHOD_DEFAULT; + e->usage = 0; + e->usage_idx = 0; + + if (f->InputSlotClass != D3D10_INPUT_PER_VERTEX_DATA) + FIXME("Ignoring input slot class (%#x)\n", f->InputSlotClass); + if (f->InstanceDataStepRate) + FIXME("Ignoring instance data step rate (%#x)\n", f->InstanceDataStepRate); + for (j = 0; j < is.element_count; ++j) { if (!strcmp(element_descs[i].SemanticName, is.elements[j].semantic_name) && element_descs[i].SemanticIndex == is.elements[j].semantic_idx) { - struct wined3d_vertex_element *e = &(*wined3d_elements)[(*wined3d_element_count)++]; - const D3D10_INPUT_ELEMENT_DESC *f = &element_descs[i]; - - e->format = wined3dformat_from_dxgi_format(f->Format); - e->input_slot = f->InputSlot; - e->offset = f->AlignedByteOffset; e->output_slot = is.elements[j].register_idx; - e->method = WINED3D_DECL_METHOD_DEFAULT; - e->usage = 0; - e->usage_idx = 0; - - if (f->InputSlotClass != D3D10_INPUT_PER_VERTEX_DATA) - FIXME("Ignoring input slot class (%#x)\n", f->InputSlotClass); - if (f->InstanceDataStepRate) - FIXME("Ignoring instance data step rate (%#x)\n", f->InstanceDataStepRate); - break; } } @@ -225,23 +224,21 @@ HRESULT d3d10_input_layout_init(struct d3d10_input_layout *layout, struct d3d10_ const void *shader_byte_code, SIZE_T shader_byte_code_length) { struct wined3d_vertex_element *wined3d_elements; - UINT wined3d_element_count; HRESULT hr;
layout->ID3D10InputLayout_iface.lpVtbl = &d3d10_input_layout_vtbl; layout->refcount = 1; wined3d_private_store_init(&layout->private_store);
- hr = d3d10_input_layout_to_wined3d_declaration(element_descs, element_count, - shader_byte_code, shader_byte_code_length, &wined3d_elements, &wined3d_element_count); - if (FAILED(hr)) + if (FAILED(hr = d3d10_input_layout_to_wined3d_declaration(element_descs, element_count, + shader_byte_code, shader_byte_code_length, &wined3d_elements))) { WARN("Failed to create wined3d vertex declaration elements, hr %#x.\n", hr); wined3d_private_store_cleanup(&layout->private_store); return hr; }
- hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count, + hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, element_count, layout, &d3d10_input_layout_wined3d_parent_ops, &layout->wined3d_decl); HeapFree(GetProcessHeap(), 0, wined3d_elements); if (FAILED(hr)) diff --git a/dlls/d3d9/vertexdeclaration.c b/dlls/d3d9/vertexdeclaration.c index 502b7d3..086ac70 100644 --- a/dlls/d3d9/vertexdeclaration.c +++ b/dlls/d3d9/vertexdeclaration.c @@ -353,7 +353,7 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem (*wined3d_elements)[i].format = d3d_dtype_lookup[d3d9_elements[i].Type].format; (*wined3d_elements)[i].input_slot = d3d9_elements[i].Stream; (*wined3d_elements)[i].offset = d3d9_elements[i].Offset; - (*wined3d_elements)[i].output_slot = ~0U; + (*wined3d_elements)[i].output_slot = WINED3D_OUTPUT_SLOT_SEMANTIC; (*wined3d_elements)[i].method = d3d9_elements[i].Method; (*wined3d_elements)[i].usage = d3d9_elements[i].Usage; (*wined3d_elements)[i].usage_idx = d3d9_elements[i].UsageIndex; diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 9cc68ab..894e259 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2771,7 +2771,11 @@ void context_stream_info_from_declaration(struct wined3d_context *context,
if (use_vshader) { - if (element->output_slot == ~0U) + if (element->output_slot == WINED3D_OUTPUT_SLOT_UNUSED) + { + stride_used = FALSE; + } + else if (element->output_slot == WINED3D_OUTPUT_SLOT_SEMANTIC) { /* TODO: Assuming vertexdeclarations are usually used with the * same or a similar shader, it might be worth it to store the diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c index 97992d6..df54bdc 100644 --- a/dlls/wined3d/vertexdeclaration.c +++ b/dlls/wined3d/vertexdeclaration.c @@ -296,7 +296,7 @@ static void append_decl_element(struct wined3d_fvf_convert_state *state, elements[idx].format = format_id; elements[idx].input_slot = 0; elements[idx].offset = offset; - elements[idx].output_slot = 0; + elements[idx].output_slot = WINED3D_OUTPUT_SLOT_SEMANTIC; elements[idx].method = WINED3D_DECL_METHOD_DEFAULT; elements[idx].usage = usage; elements[idx].usage_idx = usage_idx; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 6905585..b576e1a 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -1496,6 +1496,9 @@ enum wined3d_display_rotation
#define WINED3D_APPEND_ALIGNED_ELEMENT 0xffffffff
+#define WINED3D_OUTPUT_SLOT_SEMANTIC 0xffffffff +#define WINED3D_OUTPUT_SLOT_UNUSED 0xfffffffe + struct wined3d_display_mode { UINT width;