Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d11/tests/d3d11.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index c0cb9a2400f0..93184ada6015 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -24802,6 +24802,228 @@ static void test_generate_mips(void) release_test_context(&test_context); }
+static void test_alpha_to_coverage(void) +{ + struct ps_cb + { + struct vec2 top; + struct vec2 bottom; + float alpha[2]; + float padding[2]; + }; + + struct d3d11_test_context test_context; + ID3D11Texture2D *render_targets[3]; + D3D11_TEXTURE2D_DESC texture_desc; + ID3D11Texture2D *readback_texture; + ID3D11RenderTargetView *rtvs[3]; + ID3D11BlendState *blend_state; + ID3D11DeviceContext *context; + D3D11_BLEND_DESC blend_desc; + struct resource_readback rb; + UINT quality_level_count; + ID3D11PixelShader *ps; + struct ps_cb cb_data; + ID3D11Device *device; + ID3D11Buffer *cb; + unsigned int i; + HRESULT hr; + RECT rect; + + static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; + static const DWORD ps_code[] = + { +#if 0 + float2 top; + float2 bottom; + float alpha1; + float alpha2; + + void main(float4 position : SV_Position, + out float4 target0 : SV_Target0, + out float4 target1 : SV_Target1, + out float4 target2 : SV_Target2) + { + float alpha = all(top <= position.xy) && all(position.xy <= bottom) ? 1.0f : 0.0f; + target0 = float4(0.0f, 1.0f, 0.0f, alpha); + target1 = float4(0.0f, 0.0f, 1.0f, alpha1); + target2 = float4(0.0f, 1.0f, 0.0f, alpha2); + } +#endif + 0x43425844, 0x771ff802, 0xca927279, 0x5bdd75ae, 0xf53cb31b, 0x00000001, 0x00000264, 0x00000003, + 0x0000002c, 0x00000060, 0x000000c4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69, + 0x4e47534f, 0x0000005c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x00000050, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, + 0x00000050, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x545f5653, 0x65677261, + 0xabab0074, 0x52444853, 0x00000198, 0x00000040, 0x00000066, 0x04000059, 0x00208e46, 0x00000000, + 0x00000002, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, + 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000001, + 0x0800001d, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00208046, 0x00000000, 0x00000000, + 0x07000001, 0x00100012, 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x0800001d, + 0x00100062, 0x00000000, 0x00208ba6, 0x00000000, 0x00000000, 0x00101106, 0x00000000, 0x07000001, + 0x00100022, 0x00000000, 0x0010002a, 0x00000000, 0x0010001a, 0x00000000, 0x07000001, 0x00100012, + 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x07000001, 0x00102082, 0x00000000, + 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x08000036, 0x00102072, 0x00000000, 0x00004002, + 0x00000000, 0x3f800000, 0x00000000, 0x00000000, 0x08000036, 0x00102072, 0x00000001, 0x00004002, + 0x00000000, 0x00000000, 0x3f800000, 0x00000000, 0x06000036, 0x00102082, 0x00000001, 0x0020800a, + 0x00000000, 0x00000001, 0x08000036, 0x00102072, 0x00000002, 0x00004002, 0x00000000, 0x3f800000, + 0x00000000, 0x00000000, 0x06000036, 0x00102082, 0x00000002, 0x0020801a, 0x00000000, 0x00000001, + 0x0100003e, + }; + static const DWORD colors[] = {0xff00ff00, 0xbfff0000, 0x8000ff00}; + + if (!init_test_context(&test_context, NULL)) + return; + device = test_context.device; + context = test_context.immediate_context; + + hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps); + ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr); + ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0); + + memset(&blend_desc, 0, sizeof(blend_desc)); + blend_desc.AlphaToCoverageEnable = TRUE; + blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + hr = ID3D11Device_CreateBlendState(device, &blend_desc, &blend_state); + ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr); + ID3D11DeviceContext_OMSetBlendState(context, blend_state, NULL, D3D11_DEFAULT_SAMPLE_MASK); + + render_targets[0] = test_context.backbuffer; + rtvs[0] = test_context.backbuffer_rtv; + for (i = 1; i < ARRAY_SIZE(render_targets); ++i) + { + ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc); + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &render_targets[i]); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + hr = ID3D11Device_CreateRenderTargetView(device, + (ID3D11Resource *)render_targets[i], NULL, &rtvs[i]); + ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr); + } + ID3D11DeviceContext_OMSetRenderTargets(context, ARRAY_SIZE(rtvs), rtvs, NULL); + + cb_data.top.x = cb_data.top.y = 0.0f; + cb_data.bottom.x = cb_data.bottom.y = 200.0f; + cb_data.alpha[0] = 0.75; + cb_data.alpha[1] = 0.5f; + cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(cb_data), &cb_data); + ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb); + + for (i = 0; i < ARRAY_SIZE(rtvs); ++i) + ID3D11DeviceContext_ClearRenderTargetView(context, rtvs[i], white); + draw_quad(&test_context); + for (i = 0; i < ARRAY_SIZE(render_targets); ++i) + { + DWORD expected_color; + + assert(i < ARRAY_SIZE(colors)); + expected_color = colors[i]; + get_texture_readback(render_targets[i], 0, &rb); + SetRect(&rect, 0, 0, 200, 200); + check_readback_data_color(&rb, &rect, expected_color, 1); + SetRect(&rect, 200, 0, 640, 200); + todo_wine + check_readback_data_color(&rb, &rect, 0xffffffff, 1); + SetRect(&rect, 0, 200, 640, 480); + todo_wine + check_readback_data_color(&rb, &rect, 0xffffffff, 1); + release_resource_readback(&rb); + + if (i > 0) + ID3D11Texture2D_Release(render_targets[i]); + render_targets[i] = NULL; + } + + ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc); + texture_desc.Format = DXGI_FORMAT_R16G16_UNORM; + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &render_targets[0]); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + hr = ID3D11Device_CreateRenderTargetView(device, + (ID3D11Resource *)render_targets[0], NULL, &rtvs[0]); + ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr); + ID3D11DeviceContext_OMSetRenderTargets(context, ARRAY_SIZE(rtvs), rtvs, NULL); + + ID3D11DeviceContext_ClearRenderTargetView(context, rtvs[0], white); + draw_quad(&test_context); + get_texture_readback(render_targets[0], 0, &rb); + SetRect(&rect, 0, 0, 200, 200); + check_readback_data_color(&rb, &rect, 0xffff0000, 1); + SetRect(&rect, 200, 0, 640, 200); + todo_wine + check_readback_data_color(&rb, &rect, 0xffffffff, 1); + SetRect(&rect, 0, 200, 640, 480); + todo_wine + check_readback_data_color(&rb, &rect, 0xffffffff, 1); + release_resource_readback(&rb); + + ID3D11Texture2D_Release(render_targets[0]); + for (i = 0; i < ARRAY_SIZE(rtvs); ++i) + ID3D11RenderTargetView_Release(rtvs[i]); + + ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc); + hr = ID3D11Device_CheckMultisampleQualityLevels(device, + texture_desc.Format, 4, &quality_level_count); + if (FAILED(hr)) + { + skip("4xMSAA not supported.\n"); + goto done; + } + texture_desc.SampleDesc.Count = 4; + texture_desc.SampleDesc.Quality = 0; + + for (i = 0; i < ARRAY_SIZE(render_targets); ++i) + { + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &render_targets[i]); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + hr = ID3D11Device_CreateRenderTargetView(device, + (ID3D11Resource *)render_targets[i], NULL, &rtvs[i]); + ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr); + } + ID3D11DeviceContext_OMSetRenderTargets(context, ARRAY_SIZE(rtvs), rtvs, NULL); + + for (i = 0; i < ARRAY_SIZE(rtvs); ++i) + ID3D11DeviceContext_ClearRenderTargetView(context, rtvs[i], white); + draw_quad(&test_context); + texture_desc.SampleDesc.Count = 1; + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &readback_texture); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + for (i = 0; i < ARRAY_SIZE(render_targets); ++i) + { + DWORD expected_color; + + assert(i < ARRAY_SIZE(colors)); + expected_color = colors[i]; + + ID3D11DeviceContext_ResolveSubresource(context, (ID3D11Resource *)readback_texture, 0, + (ID3D11Resource *)render_targets[i], 0, texture_desc.Format); + + get_texture_readback(readback_texture, 0, &rb); + SetRect(&rect, 0, 0, 200, 200); + todo_wine + check_readback_data_color(&rb, &rect, expected_color, 1); + SetRect(&rect, 200, 0, 640, 200); + todo_wine + check_readback_data_color(&rb, &rect, 0xffffffff, 1); + SetRect(&rect, 0, 200, 640, 480); + todo_wine + check_readback_data_color(&rb, &rect, 0xffffffff, 1); + release_resource_readback(&rb); + } + ID3D11Texture2D_Release(readback_texture); + + for (i = 0; i < ARRAY_SIZE(render_targets); ++i) + { + ID3D11Texture2D_Release(render_targets[i]); + ID3D11RenderTargetView_Release(rtvs[i]); + } + +done: + ID3D11Buffer_Release(cb); + ID3D11PixelShader_Release(ps); + ID3D11BlendState_Release(blend_state); + release_test_context(&test_context); +} + START_TEST(d3d11) { unsigned int argc, i; @@ -24930,4 +25152,5 @@ START_TEST(d3d11) test_clip_distance(); test_combined_clip_and_cull_distances(); test_generate_mips(); + test_alpha_to_coverage(); }
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/cs.c | 27 +++++++++++++ dlls/wined3d/device.c | 25 ++++++++++++ dlls/wined3d/state.c | 88 +++++++++++++++++++++++++++++++++++++++++- dlls/wined3d/wined3d.spec | 7 ++++ dlls/wined3d/wined3d_private.h | 18 ++++++++- include/wine/wined3d.h | 15 +++++++ 6 files changed, 178 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index bb9b915a5980..76316e008f47 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -48,6 +48,7 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW, WINED3D_CS_OP_SET_SAMPLER, WINED3D_CS_OP_SET_SHADER, + WINED3D_CS_OP_SET_BLEND_STATE, WINED3D_CS_OP_SET_RASTERIZER_STATE, WINED3D_CS_OP_SET_RENDER_STATE, WINED3D_CS_OP_SET_TEXTURE_STATE, @@ -256,6 +257,12 @@ struct wined3d_cs_set_shader struct wined3d_shader *shader; };
+struct wined3d_cs_set_blend_state +{ + enum wined3d_cs_op opcode; + struct wined3d_blend_state *state; +}; + struct wined3d_cs_set_rasterizer_state { enum wined3d_cs_op opcode; @@ -1432,6 +1439,25 @@ void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); }
+static void wined3d_cs_exec_set_blend_state(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_set_blend_state *op = data; + + cs->state.blend_state = op->state; + device_invalidate_state(cs->device, STATE_BLEND); +} + +void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend_state *state) +{ + struct wined3d_cs_set_blend_state *op; + + op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); + op->opcode = WINED3D_CS_OP_SET_BLEND_STATE; + op->state = state; + + cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); +} + static void wined3d_cs_exec_set_rasterizer_state(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_set_rasterizer_state *op = data; @@ -2397,6 +2423,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_set_unordered_access_view, /* WINED3D_CS_OP_SET_SAMPLER */ wined3d_cs_exec_set_sampler, /* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader, + /* WINED3D_CS_OP_SET_BLEND_STATE */ wined3d_cs_exec_set_blend_state, /* WINED3D_CS_OP_SET_RASTERIZER_STATE */ wined3d_cs_exec_set_rasterizer_state, /* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state, /* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 2d1603f0b097..78610fc90360 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1948,6 +1948,31 @@ static void resolve_depth_buffer(struct wined3d_state *state) src_view->sub_resource_idx, &src_rect, 0, NULL, WINED3D_TEXF_POINT); }
+void CDECL wined3d_device_set_blend_state(struct wined3d_device *device, struct wined3d_blend_state *blend_state) +{ + struct wined3d_blend_state *prev; + + TRACE("device %p, blend_state %p.\n", device, blend_state); + + prev = device->update_state->blend_state; + if (prev == blend_state) + return; + + if (blend_state) + wined3d_blend_state_incref(blend_state); + device->update_state->blend_state = blend_state; + wined3d_cs_emit_set_blend_state(device->cs, blend_state); + if (prev) + wined3d_blend_state_decref(prev); +} + +struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct wined3d_device *device) +{ + TRACE("device %p.\n", device); + + return device->state.blend_state; +} + void CDECL wined3d_device_set_rasterizer_state(struct wined3d_device *device, struct wined3d_rasterizer_state *rasterizer_state) { diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index db1711ef76c2..aa1a2ae5b319 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -38,6 +38,67 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
+ULONG CDECL wined3d_blend_state_incref(struct wined3d_blend_state *state) +{ + ULONG refcount = InterlockedIncrement(&state->refcount); + + TRACE("%p increasing refcount to %u.\n", state, refcount); + + return refcount; +} + +static void wined3d_blend_state_destroy_object(void *object) +{ + HeapFree(GetProcessHeap(), 0, object); +} + +ULONG CDECL wined3d_blend_state_decref(struct wined3d_blend_state *state) +{ + ULONG refcount = InterlockedDecrement(&state->refcount); + struct wined3d_device *device = state->device; + + TRACE("%p decreasing refcount to %u.\n", state, refcount); + + if (!refcount) + { + state->parent_ops->wined3d_object_destroyed(state->parent); + wined3d_cs_destroy_object(device->cs, wined3d_blend_state_destroy_object, state); + } + + return refcount; +} + +void * CDECL wined3d_blend_state_get_parent(const struct wined3d_blend_state *state) +{ + TRACE("state %p.\n", state); + + return state->parent; +} + +HRESULT CDECL wined3d_blend_state_create(struct wined3d_device *device, + const struct wined3d_blend_state_desc *desc, void *parent, + const struct wined3d_parent_ops *parent_ops, struct wined3d_blend_state **state) +{ + struct wined3d_blend_state *object; + + TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n", + device, desc, parent, parent_ops, state); + + if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + return E_OUTOFMEMORY; + + object->refcount = 1; + object->desc = *desc; + object->parent = parent; + object->parent_ops = parent_ops; + object->device = device; + + TRACE("Created blend state %p.\n", object); + *state = object; + + return WINED3D_OK; +} + ULONG CDECL wined3d_rasterizer_state_incref(struct wined3d_rasterizer_state *state) { ULONG refcount = InterlockedIncrement(&state->refcount); @@ -81,7 +142,8 @@ HRESULT CDECL wined3d_rasterizer_state_create(struct wined3d_device *device, { struct wined3d_rasterizer_state *object;
- TRACE("device %p, desc %p, state %p.\n", device, desc, state); + TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n", + device, desc, parent, parent_ops, state);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) return E_OUTOFMEMORY; @@ -553,6 +615,28 @@ static void state_blendfactor(struct wined3d_context *context, const struct wine checkGLcall("glBlendColor"); }
+static void state_blend_object(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) +{ + const struct wined3d_gl_info *gl_info = context->gl_info; + BOOL alpha_to_coverage = FALSE; + + if (!gl_info->supported[ARB_MULTISAMPLE]) + return; + + if (state->blend_state) + { + struct wined3d_blend_state_desc *desc = &state->blend_state->desc; + alpha_to_coverage = desc->alpha_to_coverage; + } + + if (alpha_to_coverage) + gl_info->gl_ops.gl.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); + else + gl_info->gl_ops.gl.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); + + checkGLcall("blend state"); +} + void state_alpha_test(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_info *gl_info = context->gl_info; @@ -5024,6 +5108,7 @@ const struct StateEntryTemplate misc_state_template[] = { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_BLENDOPALPHA), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, + { STATE_BLEND, { STATE_BLEND, state_blend_object }, WINED3D_GL_EXT_NONE }, { STATE_STREAMSRC, { STATE_STREAMSRC, streamsrc }, WINED3D_GL_EXT_NONE }, { STATE_VDECL, { STATE_VDECL, vdecl_miscpart }, WINED3D_GL_EXT_NONE }, { STATE_FRONTFACE, { STATE_FRONTFACE, frontface_cc }, ARB_CLIP_CONTROL }, @@ -5973,6 +6058,7 @@ static void validate_state_table(struct StateEntry *state_table) STATE_FRAMEBUFFER, STATE_POINT_ENABLE, STATE_COLOR_KEY, + STATE_BLEND, }; unsigned int i, current;
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 606ba0b35250..f65cc85be3f2 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -22,6 +22,11 @@ @ cdecl wined3d_register_software_device(ptr ptr) @ cdecl wined3d_set_adapter_display_mode(ptr long ptr)
+@ cdecl wined3d_blend_state_create(ptr ptr ptr ptr ptr) +@ cdecl wined3d_blend_state_decref(ptr) +@ cdecl wined3d_blend_state_get_parent(ptr) +@ cdecl wined3d_blend_state_incref(ptr) + @ cdecl wined3d_buffer_create(ptr ptr ptr ptr ptr ptr) @ cdecl wined3d_buffer_create_vb(ptr long long long ptr ptr ptr) @ cdecl wined3d_buffer_decref(ptr) @@ -53,6 +58,7 @@ @ cdecl wined3d_device_evict_managed_resources(ptr) @ cdecl wined3d_device_get_available_texture_mem(ptr) @ cdecl wined3d_device_get_base_vertex_index(ptr) +@ cdecl wined3d_device_get_blend_state(ptr) @ cdecl wined3d_device_get_clip_plane(ptr long ptr) @ cdecl wined3d_device_get_clip_status(ptr ptr) @ cdecl wined3d_device_get_compute_shader(ptr) @@ -126,6 +132,7 @@ @ cdecl wined3d_device_reset(ptr ptr ptr ptr long) @ cdecl wined3d_device_restore_fullscreen_window(ptr ptr ptr) @ cdecl wined3d_device_set_base_vertex_index(ptr long) +@ cdecl wined3d_device_set_blend_state(ptr ptr) @ cdecl wined3d_device_set_clip_plane(ptr long ptr) @ cdecl wined3d_device_set_clip_status(ptr ptr) @ cdecl wined3d_device_set_compute_shader(ptr ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 334724514df3..e2527f2a224a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1642,7 +1642,10 @@ enum wined3d_pipeline #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1) #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
-#define STATE_COMPUTE_OFFSET (STATE_STREAM_OUTPUT + 1) +#define STATE_BLEND (STATE_STREAM_OUTPUT + 1) +#define STATE_IS_BLEND(a) ((a) == STATE_BLEND) + +#define STATE_COMPUTE_OFFSET (STATE_BLEND + 1)
#define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET) #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER) @@ -2763,6 +2766,17 @@ HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags) DECLSPEC_HIDDEN; BOOL wined3d_register_window(HWND window, struct wined3d_device *device) DECLSPEC_HIDDEN; void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
+struct wined3d_blend_state +{ + LONG refcount; + struct wined3d_blend_state_desc desc; + + void *parent; + const struct wined3d_parent_ops *parent_ops; + + struct wined3d_device *device; +}; + struct wined3d_rasterizer_state { LONG refcount; @@ -2841,6 +2855,7 @@ struct wined3d_state const struct wined3d_light_info *lights[MAX_ACTIVE_LIGHTS];
DWORD render_states[WINEHIGHEST_RENDER_STATE + 1]; + struct wined3d_blend_state *blend_state; struct wined3d_rasterizer_state *rasterizer_state; };
@@ -3519,6 +3534,7 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, DWORD flags) DECLSPEC_HIDDEN; void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *query, DWORD flags) DECLSPEC_HIDDEN; void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN; +void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend_state *state) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 2a7960290984..f6ffdba67c80 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -1976,6 +1976,11 @@ struct wined3d_buffer_desc unsigned int structure_byte_stride; };
+struct wined3d_blend_state_desc +{ + BOOL alpha_to_coverage; +}; + struct wined3d_rasterizer_state_desc { BOOL front_ccw; @@ -2086,6 +2091,7 @@ struct wined3d_buffer; struct wined3d_device; struct wined3d_palette; struct wined3d_query; +struct wined3d_blend_state; struct wined3d_rasterizer_state; struct wined3d_rendertarget_view; struct wined3d_resource; @@ -2238,6 +2244,7 @@ HRESULT __cdecl wined3d_device_end_stateblock(struct wined3d_device *device, str void __cdecl wined3d_device_evict_managed_resources(struct wined3d_device *device); UINT __cdecl wined3d_device_get_available_texture_mem(const struct wined3d_device *device); INT __cdecl wined3d_device_get_base_vertex_index(const struct wined3d_device *device); +struct wined3d_blend_state * __cdecl wined3d_device_get_blend_state(const struct wined3d_device *device); HRESULT __cdecl wined3d_device_get_clip_plane(const struct wined3d_device *device, UINT plane_idx, struct wined3d_vec4 *plane); HRESULT __cdecl wined3d_device_get_clip_status(const struct wined3d_device *device, @@ -2348,6 +2355,7 @@ HRESULT __cdecl wined3d_device_reset(struct wined3d_device *device, void __cdecl wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window, const RECT *window_rect); void __cdecl wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index); +void __cdecl wined3d_device_set_blend_state(struct wined3d_device *device, struct wined3d_blend_state *blend_state); HRESULT __cdecl wined3d_device_set_clip_plane(struct wined3d_device *device, UINT plane_idx, const struct wined3d_vec4 *plane); HRESULT __cdecl wined3d_device_set_clip_status(struct wined3d_device *device, @@ -2550,6 +2558,13 @@ static inline HRESULT wined3d_private_store_set_private_data(struct wined3d_priv return WINED3D_OK; }
+HRESULT __cdecl wined3d_blend_state_create(struct wined3d_device *device, + const struct wined3d_blend_state_desc *desc, void *parent, + const struct wined3d_parent_ops *parent_ops, struct wined3d_blend_state **state); +ULONG __cdecl wined3d_blend_state_decref(struct wined3d_blend_state *state); +void * __cdecl wined3d_blend_state_get_parent(const struct wined3d_blend_state *state); +ULONG __cdecl wined3d_blend_state_incref(struct wined3d_blend_state *state); + HRESULT __cdecl wined3d_rasterizer_state_create(struct wined3d_device *device, const struct wined3d_rasterizer_state_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rasterizer_state **state);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d11/d3d11_private.h | 2 +- dlls/d3d11/device.c | 20 +++++++++--- dlls/d3d11/state.c | 78 ++++++++++++++++++++++++++++------------------ 3 files changed, 64 insertions(+), 36 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 1030b96e7c67..52496d8b123e 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -392,6 +392,7 @@ struct d3d_blend_state LONG refcount;
struct wined3d_private_store private_store; + struct wined3d_blend_state *wined3d_state; D3D11_BLEND_DESC desc; struct wine_rb_entry entry; ID3D11Device *device; @@ -522,7 +523,6 @@ struct d3d_device struct wine_rb_tree rasterizer_states; struct wine_rb_tree sampler_states;
- struct d3d_blend_state *blend_state; float blend_factor[4]; struct d3d_depthstencil_state *depth_stencil_state; UINT stencil_ref; diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index b14c3862a1dc..f9db15f12fdc 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -686,6 +686,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi { struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); static const float default_blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f}; + struct d3d_blend_state *blend_state_impl; const D3D11_BLEND_DESC *desc;
TRACE("iface %p, blend_state %p, blend_factor %s, sample_mask 0x%08x.\n", @@ -697,8 +698,9 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi wined3d_mutex_lock(); memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor)); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK, sample_mask); - if (!(device->blend_state = unsafe_impl_from_ID3D11BlendState(blend_state))) + if (!(blend_state_impl = unsafe_impl_from_ID3D11BlendState(blend_state))) { + wined3d_device_set_blend_state(device->wined3d_device, NULL); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, FALSE); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_COLORWRITEENABLE, D3D11_COLOR_WRITE_ENABLE_ALL); @@ -712,7 +714,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi return; }
- desc = &device->blend_state->desc; + wined3d_device_set_blend_state(device->wined3d_device, blend_state_impl->wined3d_state); + desc = &blend_state_impl->desc; wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, desc->RenderTarget[0].BlendEnable); if (desc->RenderTarget[0].BlendEnable) @@ -1988,13 +1991,22 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11Devi ID3D11BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask) { struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct wined3d_blend_state *wined3d_state; + struct d3d_blend_state *blend_state_impl;
TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n", iface, blend_state, blend_factor, sample_mask);
- if ((*blend_state = device->blend_state ? &device->blend_state->ID3D11BlendState_iface : NULL)) - ID3D11BlendState_AddRef(*blend_state); wined3d_mutex_lock(); + if ((wined3d_state = wined3d_device_get_blend_state(device->wined3d_device))) + { + blend_state_impl = wined3d_blend_state_get_parent(wined3d_state); + ID3D11BlendState_AddRef(*blend_state = &blend_state_impl->ID3D11BlendState_iface); + } + else + { + *blend_state = NULL; + } memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor)); *sample_mask = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK); wined3d_mutex_unlock(); diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 47058a0a082e..a14c9d3cb40d 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -64,13 +64,15 @@ static ULONG STDMETHODCALLTYPE d3d11_blend_state_AddRef(ID3D11BlendState *iface)
TRACE("%p increasing refcount to %u.\n", state, refcount);
- return refcount; -} + if (refcount == 1) + { + ID3D11Device_AddRef(state->device); + wined3d_mutex_lock(); + wined3d_blend_state_incref(state->wined3d_state); + wined3d_mutex_unlock(); + }
-static void d3d_blend_state_cleanup(struct d3d_blend_state *state) -{ - wined3d_private_store_cleanup(&state->private_store); - ID3D11Device_Release(state->device); + return refcount; }
static ULONG STDMETHODCALLTYPE d3d11_blend_state_Release(ID3D11BlendState *iface) @@ -82,12 +84,13 @@ static ULONG STDMETHODCALLTYPE d3d11_blend_state_Release(ID3D11BlendState *iface
if (!refcount) { - struct d3d_device *device = impl_from_ID3D11Device(state->device); + ID3D11Device *device = state->device; + wined3d_mutex_lock(); - wine_rb_remove(&device->blend_states, &state->entry); - d3d_blend_state_cleanup(state); + wined3d_blend_state_decref(state->wined3d_state); wined3d_mutex_unlock(); - heap_free(state); + + ID3D11Device_Release(device); }
return refcount; @@ -288,24 +291,25 @@ static const struct ID3D10BlendState1Vtbl d3d10_blend_state_vtbl = d3d10_blend_state_GetDesc1, };
-static HRESULT d3d_blend_state_init(struct d3d_blend_state *state, struct d3d_device *device, - const D3D11_BLEND_DESC *desc) +static void STDMETHODCALLTYPE d3d_blend_state_wined3d_object_destroyed(void *parent) { - state->ID3D11BlendState_iface.lpVtbl = &d3d11_blend_state_vtbl; - state->ID3D10BlendState1_iface.lpVtbl = &d3d10_blend_state_vtbl; - state->refcount = 1; - wined3d_private_store_init(&state->private_store); - state->desc = *desc; - - state->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(state->device); + struct d3d_blend_state *state = parent; + struct d3d_device *device = impl_from_ID3D11Device(state->device);
- return S_OK; + wine_rb_remove(&device->blend_states, &state->entry); + wined3d_private_store_cleanup(&state->private_store); + heap_free(parent); }
+static const struct wined3d_parent_ops d3d_blend_state_wined3d_parent_ops = +{ + d3d_blend_state_wined3d_object_destroyed, +}; + HRESULT d3d_blend_state_create(struct d3d_device *device, const D3D11_BLEND_DESC *desc, struct d3d_blend_state **state) { + struct wined3d_blend_state_desc wined3d_desc; struct d3d_blend_state *object; struct wine_rb_entry *entry; D3D11_BLEND_DESC tmp_desc; @@ -337,9 +341,6 @@ HRESULT d3d_blend_state_create(struct d3d_device *device, const D3D11_BLEND_DESC tmp_desc.RenderTarget[i].RenderTargetWriteMask, i); }
- /* glSampleCoverage() */ - if (tmp_desc.AlphaToCoverageEnable) - FIXME("Ignoring AlphaToCoverageEnable %#x.\n", tmp_desc.AlphaToCoverageEnable); /* glEnableIndexedEXT(GL_BLEND, ...) */ if (tmp_desc.IndependentBlendEnable) FIXME("Per-rendertarget blend not implemented.\n"); @@ -363,24 +364,39 @@ HRESULT d3d_blend_state_create(struct d3d_device *device, const D3D11_BLEND_DESC return E_OUTOFMEMORY; }
- if (FAILED(hr = d3d_blend_state_init(object, device, &tmp_desc))) + object->ID3D11BlendState_iface.lpVtbl = &d3d11_blend_state_vtbl; + object->ID3D10BlendState1_iface.lpVtbl = &d3d10_blend_state_vtbl; + object->refcount = 1; + wined3d_private_store_init(&object->private_store); + object->desc = tmp_desc; + + if (wine_rb_put(&device->blend_states, &tmp_desc, &object->entry) == -1) { - WARN("Failed to initialize blend state, hr %#x.\n", hr); + ERR("Failed to insert blend state entry.\n"); + wined3d_private_store_cleanup(&object->private_store); heap_free(object); wined3d_mutex_unlock(); - return hr; + return E_FAIL; }
- if (wine_rb_put(&device->blend_states, desc, &object->entry) == -1) + wined3d_desc.alpha_to_coverage = desc->AlphaToCoverageEnable; + + /* We cannot fail after creating a wined3d_blend_state object. It + * would lead to double free. */ + if (FAILED(hr = wined3d_blend_state_create(device->wined3d_device, &wined3d_desc, + object, &d3d_blend_state_wined3d_parent_ops, &object->wined3d_state))) { - ERR("Failed to insert blend state entry.\n"); - d3d_blend_state_cleanup(object); + WARN("Failed to create wined3d blend state, hr %#x.\n", hr); + wined3d_private_store_cleanup(&object->private_store); + wine_rb_remove(&device->blend_states, &object->entry); heap_free(object); wined3d_mutex_unlock(); - return E_FAIL; + return hr; } wined3d_mutex_unlock();
+ ID3D11Device_AddRef(object->device = &device->ID3D11Device_iface); + TRACE("Created blend state %p.\n", object); *state = object;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/glsl_shader.c | 72 ++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 28 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 6f54b3177fe9..b3c6404a4d5b 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -5894,15 +5894,28 @@ static void shader_glsl_bufinfo(const struct wined3d_shader_instruction *ins) shader_addline(buffer, ", %u)%s);\n", resource_info->stride, dst_swizzle); }
+static BOOL is_multisampled(enum wined3d_shader_resource_type resource_type) +{ + return resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_2DMS + || resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY; +} + +static BOOL is_mipmapped(enum wined3d_shader_resource_type resource_type) +{ + return resource_type != WINED3D_SHADER_RESOURCE_BUFFER && !is_multisampled(resource_type); +} + static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins) { const struct wined3d_shader_version *version = &ins->ctx->reg_maps->shader_version; const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; + struct wined3d_string_buffer *buffer = ins->ctx->buffer; enum wined3d_shader_resource_type resource_type; enum wined3d_shader_register_type reg_type; unsigned int resource_idx, bind_idx, i; enum wined3d_data_type dst_data_type; struct glsl_src_param lod_param; + BOOL supports_mipmaps; char dst_swizzle[6]; DWORD write_mask;
@@ -5912,9 +5925,6 @@ static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins) else if (ins->flags) FIXME("Unhandled flags %#x.\n", ins->flags);
- write_mask = shader_glsl_append_dst_ext(ins->ctx->buffer, ins, &ins->dst[0], dst_data_type); - shader_glsl_get_swizzle(&ins->src[1], FALSE, write_mask, dst_swizzle); - reg_type = ins->src[1].reg.type; resource_idx = ins->src[1].reg.idx[0].offset; shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &lod_param); @@ -5933,46 +5943,55 @@ static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins) if (resource_type >= ARRAY_SIZE(resource_type_info)) { ERR("Unexpected resource type %#x.\n", resource_type); - resource_type = WINED3D_SHADER_RESOURCE_TEXTURE_2D; + return; }
+ write_mask = shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], dst_data_type); + shader_glsl_get_swizzle(&ins->src[1], FALSE, write_mask, dst_swizzle); + if (dst_data_type == WINED3D_DATA_UINT) - shader_addline(ins->ctx->buffer, "uvec4("); + shader_addline(buffer, "uvec4("); else - shader_addline(ins->ctx->buffer, "vec4("); + shader_addline(buffer, "vec4(");
if (reg_type == WINED3DSPR_RESOURCE) { - shader_addline(ins->ctx->buffer, "textureSize(%s_sampler%u, %s), ", - shader_glsl_get_prefix(version->type), bind_idx, lod_param.param_str); + shader_addline(buffer, "textureSize(%s_sampler%u", + shader_glsl_get_prefix(version->type), bind_idx); + } + else + { + shader_addline(buffer, "imageSize(%s_image%u", + shader_glsl_get_prefix(version->type), bind_idx); + }
- for (i = 0; i < 3 - resource_type_info[resource_type].resinfo_size; ++i) - shader_addline(ins->ctx->buffer, "0, "); + supports_mipmaps = is_mipmapped(resource_type) && reg_type != WINED3DSPR_UAV; + if (supports_mipmaps) + shader_addline(buffer, ", %s", lod_param.param_str); + shader_addline(buffer, "), ");
+ for (i = 0; i < 3 - resource_type_info[resource_type].resinfo_size; ++i) + shader_addline(buffer, "0, "); + + if (supports_mipmaps) + { if (gl_info->supported[ARB_TEXTURE_QUERY_LEVELS]) { - shader_addline(ins->ctx->buffer, "textureQueryLevels(%s_sampler%u)", + shader_addline(buffer, "textureQueryLevels(%s_sampler%u)", shader_glsl_get_prefix(version->type), bind_idx); } else { - FIXME("textureQueryLevels is not supported, returning 1 mipmap level.\n"); - shader_addline(ins->ctx->buffer, "1"); + FIXME("textureQueryLevels is not supported, returning 1 level.\n"); + shader_addline(buffer, "1"); } } else { - shader_addline(ins->ctx->buffer, "imageSize(%s_image%u), ", - shader_glsl_get_prefix(version->type), bind_idx); - - for (i = 0; i < 3 - resource_type_info[resource_type].resinfo_size; ++i) - shader_addline(ins->ctx->buffer, "0, "); - - /* For UAVs the returned miplevel count is always 1. */ - shader_addline(ins->ctx->buffer, "1"); + shader_addline(buffer, "1"); }
- shader_addline(ins->ctx->buffer, ")%s);\n", dst_swizzle); + shader_addline(buffer, ")%s);\n", dst_swizzle); }
static void shader_glsl_ld(const struct wined3d_shader_instruction *ins) @@ -5982,7 +6001,7 @@ static void shader_glsl_ld(const struct wined3d_shader_instruction *ins) unsigned int resource_idx, sampler_idx, sampler_bind_idx; struct glsl_sample_function sample_function; DWORD flags = WINED3D_GLSL_SAMPLE_LOAD; - BOOL has_lod_param, multisample; + BOOL has_lod_param;
if (wined3d_shader_instruction_has_texel_offset(ins)) flags |= WINED3D_GLSL_SAMPLE_OFFSET; @@ -5995,16 +6014,13 @@ static void shader_glsl_ld(const struct wined3d_shader_instruction *ins) ERR("Invalid resource index %u.\n", resource_idx); return; } - multisample = reg_maps->resource_info[resource_idx].type == WINED3D_SHADER_RESOURCE_TEXTURE_2DMS - || reg_maps->resource_info[resource_idx].type == WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY; - has_lod_param = reg_maps->resource_info[resource_idx].type != WINED3D_SHADER_RESOURCE_BUFFER - && !multisample; + has_lod_param = is_mipmapped(reg_maps->resource_info[resource_idx].type);
shader_glsl_get_sample_function(ins->ctx, resource_idx, sampler_idx, flags, &sample_function); shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &coord_param); shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &lod_param); sampler_bind_idx = shader_glsl_find_sampler(®_maps->sampler_map, resource_idx, sampler_idx); - if (multisample) + if (is_multisampled(reg_maps->resource_info[resource_idx].type)) { shader_glsl_add_src_param(ins, &ins->src[2], WINED3DSP_WRITEMASK_0, &sample_param); shader_glsl_gen_sample_code(ins, sampler_bind_idx, &sample_function, ins->src[1].swizzle,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/shader.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index c775df0cc24e..424025cb8d36 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -958,27 +958,19 @@ static HRESULT shader_record_shader_phase(struct wined3d_shader *shader, }
static HRESULT shader_calculate_clip_or_cull_distance_mask( - const struct wined3d_shader_signature_element *e, DWORD *mask) + const struct wined3d_shader_signature_element *e, unsigned int *mask) { - unsigned int i; - - *mask = 0; - - /* Cull and clip distances are packed in 4 component registers. 0 and 1 are + /* Clip and cull distances are packed in 4 component registers. 0 and 1 are * the only allowed semantic indices. */ if (e->semantic_idx >= MAX_CLIP_DISTANCES / 4) { + *mask = 0; WARN("Invalid clip/cull distance index %u.\n", e->semantic_idx); return WINED3DERR_INVALIDCALL; }
- for (i = 0; i < 4; ++i) - { - if (e->mask & (WINED3DSP_WRITEMASK_0 << i)) - *mask |= 1u << (4 * e->semantic_idx + i); - } - + *mask = (e->mask & WINED3DSP_WRITEMASK_ALL) << (4 * e->semantic_idx); return WINED3D_OK; }
@@ -1786,7 +1778,7 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st for (i = 0; i < output_signature->element_count; ++i) { const struct wined3d_shader_signature_element *e = &output_signature->elements[i]; - DWORD mask; + unsigned int mask;
reg_maps->output_registers |= 1u << e->register_idx; if (e->sysval_semantic == WINED3D_SV_CLIP_DISTANCE)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=35829
Your paranoid android.
=== w2008s64 (32 bit d3d11) === d3d11.c:5105: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5106: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5107: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5110: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5111: Test failed: Got unexpected CPrimitives count: 0.