From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index a9db5e072919..a54e18efd9cf 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -4162,7 +4162,7 @@ static void init_debug_buffer(struct debug_buffer *buffer, const char *default_s buffer->size = ARRAY_SIZE(buffer->str); }
-static BOOL debug_append(struct debug_buffer *buffer, const char *str, const char *separator) +static void debug_append(struct debug_buffer *buffer, const char *str, const char *separator) { int size;
@@ -4172,12 +4172,12 @@ static BOOL debug_append(struct debug_buffer *buffer, const char *str, const cha if (size == -1 || size >= buffer->size) { buffer->size = 0; - return FALSE; + strcpy(&buffer->str[ARRAY_SIZE(buffer->str) - 4], "..."); + return; }
buffer->ptr += size; buffer->size -= size; - return TRUE; }
const char *wined3d_debug_resource_access(DWORD access)
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d9/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index e8798a746ccd..aac0961d559e 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1625,7 +1625,7 @@ static HRESULT WINAPI d3d9_device_StretchRect(IDirect3DDevice9Ex *iface, IDirect
if (dst->texture && !(dst_desc.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL))) { - WARN("Destination is a texture.\n"); + WARN("Destination is a regular texture.\n"); goto done; }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d9/tests/d3d9ex.c | 10 +-- dlls/d3d9/tests/device.c | 4 +- dlls/d3d9/tests/stateblock.c | 16 +++-- dlls/d3d9/tests/visual.c | 149 +++++++++++++++++++++---------------------- 4 files changed, 89 insertions(+), 90 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c index 1a3af3285486..6d7bd2282a89 100644 --- a/dlls/d3d9/tests/d3d9ex.c +++ b/dlls/d3d9/tests/d3d9ex.c @@ -26,6 +26,8 @@ #include <initguid.h> #include <d3d9.h>
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) + static HMODULE d3d9_handle = 0; static DEVMODEW registry_mode;
@@ -697,7 +699,7 @@ static void test_create_depth_stencil_surface_ex(void) warp = adapter_is_warp(&identifier); IDirect3D9_Release(d3d);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { surface = (IDirect3DSurface9 *)0xdeadbeef; hr = IDirect3DDevice9Ex_CreateDepthStencilSurfaceEx(device, 64, 64, D3DFMT_D24S8, @@ -2809,7 +2811,7 @@ static void test_wndproc(void) memset(&devmode, 0, sizeof(devmode)); devmode.dmSize = sizeof(devmode);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; devmode.dmPelsWidth = user32_width; @@ -3424,7 +3426,7 @@ static void test_window_style(void)
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | tests[i].style_flags, 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0); @@ -3668,7 +3670,7 @@ static void test_swapchain_parameters(void) mode.Format = D3DFMT_X8R8G8B8; mode.ScanLineOrdering = 0;
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { memset(&present_parameters, 0, sizeof(present_parameters)); present_parameters.BackBufferWidth = registry_mode.dmPelsWidth; diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 6084fd209a79..9fa6a7ebec52 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -12290,7 +12290,7 @@ static void test_stretch_rect(void) ok(hr == D3D_OK, "Failed to get caps, hr %#x.\n", hr); can_stretch_textures = caps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
- for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i) + for (i = 0; i < ARRAY_SIZE(formats); ++i) { src_format = formats[i]; if (FAILED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, @@ -12302,7 +12302,7 @@ static void test_stretch_rect(void) continue; }
- for (j = 0; j < sizeof(formats) / sizeof(*formats); ++j) + for (j = 0; j < ARRAY_SIZE(formats); ++j) { dst_format = formats[j]; if (FAILED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, diff --git a/dlls/d3d9/tests/stateblock.c b/dlls/d3d9/tests/stateblock.c index bb89ba011e69..aec698a58e84 100644 --- a/dlls/d3d9/tests/stateblock.c +++ b/dlls/d3d9/tests/stateblock.c @@ -21,6 +21,8 @@ #include <d3d9.h> #include "wine/test.h"
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) + static DWORD texture_stages;
/* ============================ State Testing Framework ========================== */ @@ -1190,7 +1192,7 @@ const D3DRENDERSTATETYPE render_state_indices[] =
struct render_state_data { - DWORD states[sizeof(render_state_indices) / sizeof(*render_state_indices)]; + DWORD states[ARRAY_SIZE(render_state_indices)]; };
struct render_state_arg @@ -1214,7 +1216,7 @@ static void render_state_apply_data(IDirect3DDevice9 *device, const struct state HRESULT hret; unsigned int i;
- for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i) + for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i) { hret = IDirect3DDevice9_SetRenderState(device, render_state_indices[i], rsdata->states[i]); ok(hret == D3D_OK, "SetRenderState returned %#x.\n", hret); @@ -1229,7 +1231,7 @@ static void render_state_check_data(IDirect3DDevice9 *device, const struct state unsigned int i; HRESULT hr;
- for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i) + for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i) { DWORD value = ctx->poison_data_buffer.states[i]; hr = IDirect3DDevice9_GetRenderState(device, render_state_indices[i], &value); @@ -1359,7 +1361,7 @@ static void render_state_poison_data_init(struct render_state_data *data) { unsigned int i;
- for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i) + for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i) { data->states[i] = 0x1337c0de; } @@ -1608,10 +1610,10 @@ static HRESULT render_state_test_init(IDirect3DDevice9 *device, struct state_tes render_state_test_data_init(&ctx->test_data_all_buffer); render_state_poison_data_init(&ctx->poison_data_buffer);
- for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i) + for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i) { ctx->test_data_vertex_buffer.states[i] = ctx->default_data_buffer.states[i]; - for (j = 0; j < sizeof(states_vertex) / sizeof(*states_vertex); ++j) + for (j = 0; j < ARRAY_SIZE(states_vertex); ++j) { if (render_state_indices[i] == states_vertex[j]) { @@ -1621,7 +1623,7 @@ static HRESULT render_state_test_init(IDirect3DDevice9 *device, struct state_tes }
ctx->test_data_pixel_buffer.states[i] = ctx->default_data_buffer.states[i]; - for (j = 0; j < sizeof(states_pixel) / sizeof(*states_pixel); ++j) + for (j = 0; j < ARRAY_SIZE(states_pixel); ++j) { if (render_state_indices[i] == states_pixel[j]) { diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 08d1849b36da..557631cddaee 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -34,6 +34,8 @@ #include <d3d9.h> #include "wine/test.h"
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) + struct vec2 { float x, y; @@ -495,7 +497,7 @@ static void lighting_test(void) hr = IDirect3DDevice9_LightEnable(device, 0, TRUE); ok(SUCCEEDED(hr), "Failed to enable light 0, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, tests[i].world_matrix); ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr); @@ -758,22 +760,14 @@ static void test_specular_lighting(void) } tests[] = { - {&directional, FALSE, 30.0f, expected_directional, - sizeof(expected_directional) / sizeof(expected_directional[0])}, - {&directional, TRUE, 30.0f, expected_directional_local, - sizeof(expected_directional_local) / sizeof(expected_directional_local[0])}, - {&point, FALSE, 30.0f, expected_point, - sizeof(expected_point) / sizeof(expected_point[0])}, - {&point, TRUE, 30.0f, expected_point_local, - sizeof(expected_point_local) / sizeof(expected_point_local[0])}, - {&spot, FALSE, 30.0f, expected_spot, - sizeof(expected_spot) / sizeof(expected_spot[0])}, - {&spot, TRUE, 30.0f, expected_spot_local, - sizeof(expected_spot_local) / sizeof(expected_spot_local[0])}, - {&point_range, FALSE, 30.0f, expected_point_range, - sizeof(expected_point_range) / sizeof(expected_point_range[0])}, - {&point_side, TRUE, 0.0f, expected_point_side, - sizeof(expected_point_side) / sizeof(expected_point_side[0])}, + {&directional, FALSE, 30.0f, expected_directional, ARRAY_SIZE(expected_directional)}, + {&directional, TRUE, 30.0f, expected_directional_local, ARRAY_SIZE(expected_directional_local)}, + {&point, FALSE, 30.0f, expected_point, ARRAY_SIZE(expected_point)}, + {&point, TRUE, 30.0f, expected_point_local, ARRAY_SIZE(expected_point_local)}, + {&spot, FALSE, 30.0f, expected_spot, ARRAY_SIZE(expected_spot)}, + {&spot, TRUE, 30.0f, expected_spot_local, ARRAY_SIZE(expected_spot_local)}, + {&point_range, FALSE, 30.0f, expected_point_range, ARRAY_SIZE(expected_point_range)}, + {&point_side, TRUE, 0.0f, expected_point_side, ARRAY_SIZE(expected_point_side)}, }; IDirect3DDevice9 *device; D3DMATERIAL9 material; @@ -847,7 +841,7 @@ static void test_specular_lighting(void) hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SPECULARENABLE, TRUE); ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice9_SetLight(device, 0, tests[i].light); ok(SUCCEEDED(hr), "Failed to set light parameters, hr %#x.\n", hr); @@ -1442,7 +1436,7 @@ static void color_fill_test(void)
IDirect3DSurface9_Release(surface);
- for (i = 0; i < sizeof(resource_types) / sizeof(resource_types[0]); i++) + for (i = 0; i < ARRAY_SIZE(resource_types); i++) { texture = NULL; hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 1, resource_types[i].usage, @@ -1459,7 +1453,7 @@ static void color_fill_test(void) IDirect3DTexture9_Release(texture); }
- for (i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) + for (i = 0; i < ARRAY_SIZE(formats); i++) { if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_SURFACE, formats[i].format) != D3D_OK) @@ -1634,9 +1628,9 @@ static void test_mova(void)
hr = IDirect3DDevice9_SetVertexShader(device, mov_shader); ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr); - for (j = 0; j < sizeof(test_data) / sizeof(*test_data); ++j) + for (j = 0; j < ARRAY_SIZE(test_data); ++j) { - for (i = 0; i < sizeof(*test_data) / sizeof(**test_data); ++i) + for (i = 0; i < ARRAY_SIZE(*test_data); ++i) { DWORD color;
@@ -2366,7 +2360,7 @@ static void test_cube_wrap(void) hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
- for (x = 0; x < (sizeof(address_modes) / sizeof(*address_modes)); ++x) + for (x = 0; x < ARRAY_SIZE(address_modes); ++x) { DWORD color;
@@ -2874,7 +2868,7 @@ static void fog_with_shader_test(void) hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, end.i); ok(hr == D3D_OK, "Setting fog end failed (%08x)\n", hr);
- for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++) + for (i = 0; i < ARRAY_SIZE(test_data); i++) { hr = IDirect3DDevice9_SetVertexShader(device, vertex_shader[test_data[i].vshader]); ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr); @@ -4128,7 +4122,7 @@ static void test_multisample_stretch_rect(void) hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt); ok(hr == D3D_OK, "Failed to set render target, hr %#x.\n", hr);
- for (i = 0; i < sizeof(filters) / sizeof(*filters); ++i) + for (i = 0; i < ARRAY_SIZE(filters); ++i) { hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr); @@ -4140,7 +4134,7 @@ static void test_multisample_stretch_rect(void)
/* Scaling */ SetRect(&rect, 0, 0, 64, 64); - for (i = 0; i < sizeof(filters) / sizeof(*filters); ++i) + for (i = 0; i < ARRAY_SIZE(filters); ++i) { hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr); @@ -4178,7 +4172,7 @@ static void test_multisample_stretch_rect(void) goto done; }
- for (i = 0; i < sizeof(filters) / sizeof(*filters); ++i) + for (i = 0; i < ARRAY_SIZE(filters); ++i) { hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr); @@ -7832,7 +7826,7 @@ static void pretransformed_varying_test(void) hr = IDirect3DDevice9_SetVertexDeclaration(device, decl); ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %08x\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { IDirect3DPixelShader9 *shader;
@@ -8880,7 +8874,7 @@ static void test_shademode(void) /* Try it first with a TRIANGLESTRIP. Do it with different geometry because * the color fixups we have to do for FLAT shading will be dependent on that. */
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { if (tests[i].vs->version) { @@ -11377,7 +11371,7 @@ static void test_pointsize(void) goto cleanup; }
- for (i = 0; i < sizeof(test_setups) / sizeof(test_setups[0]); ++i) + for (i = 0; i < ARRAY_SIZE(test_setups); ++i) { if (caps.VertexShaderVersion < test_setups[i].vs->version || caps.PixelShaderVersion < test_setups[i].ps->version) @@ -11409,7 +11403,7 @@ static void test_pointsize(void) hr = IDirect3DDevice9_SetPixelShader(device, ps); ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
- for (j = 0; j < sizeof(tests) / sizeof(tests[0]); ++j) + for (j = 0; j < ARRAY_SIZE(tests); ++j) { BOOL allow_broken = test_setups[i].allow_broken; unsigned int size = tests[j].override_min ? 63 : tests[j].zero_size ? 0 : tests[j].scale @@ -11819,7 +11813,7 @@ static void pixelshader_blending_test(void) hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer); ok(hr == D3D_OK, "Can't get back buffer, hr = %08x\n", hr);
- for (fmt_index = 0; fmt_index < sizeof(test_formats) / sizeof(*test_formats); ++fmt_index) + for (fmt_index = 0; fmt_index < ARRAY_SIZE(test_formats); ++fmt_index) { D3DFORMAT fmt = test_formats[fmt_index].textureFormat;
@@ -12268,7 +12262,7 @@ static void stream_test(void) ok(hr == D3D_OK, "IDirect3DDevice9_SetIndices failed with %08x\n", hr);
/* run all tests */ - for( i = 0; i < sizeof(testcases)/sizeof(testcases[0]); ++i) + for( i = 0; i < ARRAY_SIZE(testcases); ++i) { struct testdata act = testcases[i]; decl[0].Stream = act.strVertex; @@ -12590,7 +12584,7 @@ static void texop_test(void) hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0); ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
- for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i) + for (i = 0; i < ARRAY_SIZE(test_data); ++i) { if (!(caps.TextureOpCaps & test_data[i].caps_flag)) { @@ -12703,7 +12697,7 @@ static void yuv_color_test(void) hr = IDirect3DSurface9_GetDesc(target, &desc); ok(SUCCEEDED(hr), "Failed to get surface description, hr %#x.\n", hr);
- for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) + for (i = 0; i < ARRAY_SIZE(test_data); i++) { /* Some(all?) Windows drivers do not support YUV 3D textures, only 2D surfaces in StretchRect. * Thus use StretchRect to draw the YUV surface onto the screen instead of drawPrimitive. */ @@ -12849,7 +12843,7 @@ static void yuv_layout_test(void) hr = IDirect3DSurface9_GetDesc(target, &desc); ok(SUCCEEDED(hr), "Failed to get surface description, hr %#x.\n", hr);
- for (fmt = 0; fmt < sizeof(formats) / sizeof(formats[0]); fmt++) + for (fmt = 0; fmt < ARRAY_SIZE(formats); fmt++) { format = formats[fmt].format; fmt_string = formats[fmt].str; @@ -12873,7 +12867,7 @@ static void yuv_layout_test(void) hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height, format, D3DPOOL_DEFAULT, &surface, NULL); ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface failed, hr = %#x.\n", hr);
- for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) + for (i = 0; i < ARRAY_SIZE(test_data); i++) { hr = IDirect3DSurface9_LockRect(surface, &lr, NULL, 0); ok(hr == D3D_OK, "IDirect3DSurface9_LockRect failed, hr = %#x.\n", hr); @@ -13439,7 +13433,8 @@ static void alphatest_test(void) IDirect3DPixelShader9_Release(ps); }
- for(i = 0; i < (sizeof(testdata)/sizeof(testdata[0])); i++) { + for(i = 0; i < ARRAY_SIZE(testdata); i++) + { hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAFUNC, testdata[i].func); ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
@@ -14845,7 +14840,7 @@ static void intz_test(void) ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
get_rt_readback(original_rt, &rb); - for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { D3DCOLOR color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 1), @@ -14899,7 +14894,7 @@ static void intz_test(void) ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
get_rt_readback(original_rt, &rb); - for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { D3DCOLOR color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 1), @@ -14966,7 +14961,7 @@ static void intz_test(void) ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
get_rt_readback(original_rt, &rb); - for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { D3DCOLOR color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 1), @@ -15112,7 +15107,7 @@ static void shadow_test(void) hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT); ok(SUCCEEDED(hr), "SetSamplerState failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i) + for (i = 0; i < ARRAY_SIZE(formats); ++i) { D3DFORMAT format = formats[i].format; IDirect3DTexture9 *texture; @@ -15176,7 +15171,7 @@ static void shadow_test(void) IDirect3DTexture9_Release(texture);
get_rt_readback(original_rt, &rb); - for (j = 0; j < sizeof(expected_colors) / sizeof(*expected_colors); ++j) + for (j = 0; j < ARRAY_SIZE(expected_colors); ++j) { D3DCOLOR color = get_readback_color(&rb, expected_colors[j].x, expected_colors[j].y); /* Geforce 7 on Windows returns 1.0 in alpha when the depth format is D24S8 or D24X8, @@ -15534,7 +15529,7 @@ static void fp_special_test(void) hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0); ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(vs_body) / sizeof(*vs_body); ++i) + for (i = 0; i < ARRAY_SIZE(vs_body); ++i) { if (vs_body[i].size > body_size) body_size = vs_body[i].size; } @@ -15542,9 +15537,9 @@ static void fp_special_test(void) vs_code = HeapAlloc(GetProcessHeap(), 0, sizeof(vs_header) + body_size + sizeof(vs_footer)); memcpy(vs_code, vs_header, sizeof(vs_header));
- for (i = 0; i < sizeof(vs_body) / sizeof(*vs_body); ++i) + for (i = 0; i < ARRAY_SIZE(vs_body); ++i) { - DWORD offset = sizeof(vs_header) / sizeof(*vs_header); + DWORD offset = ARRAY_SIZE(vs_header); IDirect3DVertexShader9 *vs; D3DCOLOR color;
@@ -15648,7 +15643,7 @@ static void srgbwrite_format_test(void) hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x80808080); ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
- for(i = 0; i < (sizeof(formats) / sizeof(*formats)); i++) + for(i = 0; i < ARRAY_SIZE(formats); i++) { if (FAILED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, formats[i].fmt))) @@ -16120,7 +16115,7 @@ static void update_surface_test(void) ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr); }
- for (i = 0; i < sizeof(block_size_tests) / sizeof(*block_size_tests); ++i) + for (i = 0; i < ARRAY_SIZE(block_size_tests); ++i) { hr = IDirect3DTexture9_GetSurfaceLevel(src_tex, block_size_tests[i].src_level, &src_surface); ok(SUCCEEDED(hr), "Failed to get texture surface, hr %#x.\n", hr); @@ -16172,7 +16167,7 @@ static void update_surface_test(void) hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 0), @@ -16390,7 +16385,7 @@ static void multisampled_depth_buffer_test(void) hr = IDirect3DDevice9_StretchRect(device, rt, NULL, readback, NULL, D3DTEXF_POINT); ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { D3DCOLOR color = getPixelColorFromSurface(readback, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 1), @@ -16438,7 +16433,7 @@ static void multisampled_depth_buffer_test(void) hr = IDirect3DDevice9_StretchRect(device, original_rt, NULL, readback, NULL, D3DTEXF_POINT); ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { D3DCOLOR color = getPixelColorFromSurface(readback, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 1), @@ -16536,7 +16531,7 @@ static void multisampled_depth_buffer_test(void) hr = IDirect3DDevice9_StretchRect(device, original_rt, NULL, readback, NULL, D3DTEXF_POINT); ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { D3DCOLOR color = getPixelColorFromSurface(readback, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 1), @@ -16784,7 +16779,7 @@ static void resz_test(void) hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 1), @@ -16921,7 +16916,7 @@ static void resz_test(void) hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 1), @@ -17005,7 +17000,7 @@ static void resz_test(void) hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 1), @@ -17360,7 +17355,7 @@ static void fog_special_test(void) hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND, conv.d); ok(SUCCEEDED(hr), "Failed to set fog end, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); i++) { hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0); ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr); @@ -17526,7 +17521,7 @@ static void volume_srgb_test(void) IDirect3DVolumeTexture9_Release(tex1); }
- for (j = 0; j < sizeof(tests) / sizeof(*tests); j++) + for (j = 0; j < ARRAY_SIZE(tests); j++) { hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, tests[j].srgb); ok(SUCCEEDED(hr), "Failed to set srgb state, hr %#x.\n", hr); @@ -18634,7 +18629,7 @@ static void test_fog_interpolation(void) hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &ident_mat); ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); i++) { if(!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog) continue; @@ -18789,7 +18784,7 @@ static void test_negative_fixedfunction_fog(void) hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE); ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); i++) { if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog) continue; @@ -18978,7 +18973,7 @@ static void test_position_index(void) hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(expected_colors[0]); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { color = getPixelColor(device, expected_colors[i].position.x, expected_colors[i].position.y); ok (color_match(color, expected_colors[i].expected_color, 1) @@ -18998,7 +18993,7 @@ static void test_position_index(void) hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(expected_colors[0]); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { color = getPixelColor(device, expected_colors[i].position.x, expected_colors[i].position.y); ok (color_match(color, expected_colors[i].expected_color, 1) @@ -19018,7 +19013,7 @@ static void test_position_index(void) hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(expected_colors[0]); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { color = getPixelColor(device, expected_colors[i].position.x, expected_colors[i].position.y); ok (color_match(color, expected_colors[i].expected_color, 1), @@ -19124,7 +19119,7 @@ static void test_table_fog_zw(void) hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE); ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0); ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); @@ -19375,7 +19370,7 @@ static void test_signed_formats(void) hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_alpha, &shader_alpha); ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
- for (i = 0; i < sizeof(formats) / sizeof(*formats); i++) + for (i = 0; i < ARRAY_SIZE(formats); i++) { hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, formats[i].format); @@ -19385,7 +19380,7 @@ static void test_signed_formats(void) continue; }
- for (j = 0; j < sizeof(tests) / sizeof(*tests); j++) + for (j = 0; j < ARRAY_SIZE(tests); j++) { texture_sysmem = NULL; hr = IDirect3DDevice9_CreateTexture(device, tests[j].width, 4, 1, 0, @@ -20130,7 +20125,7 @@ static void test_vertex_blending(void) hr = IDirect3DDevice9_SetRenderState(device, D3DRS_VERTEXBLEND, D3DVBF_3WEIGHTS); ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed %08x\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { const POINT *point;
@@ -20329,7 +20324,7 @@ static void test_updatetexture(void) hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE); ok(hr == D3D_OK, "Failed to set texture stage state, hr %#x.\n", hr);
- for (t = 0; t < sizeof(texture_types) / sizeof(*texture_types); ++t) + for (t = 0; t < ARRAY_SIZE(texture_types); ++t) { if (!(caps.TextureCaps & texture_types[t].cap)) { @@ -20361,7 +20356,7 @@ static void test_updatetexture(void) hr = IDirect3DDevice9_SetFVF(device, texture_types[t].fvf); ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { if (tests[i].dst_format == D3DFMT_R32F && !r32f_supported) continue; @@ -20614,7 +20609,7 @@ static void test_depthbias(void) hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ); ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
- for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i) + for (i = 0; i < ARRAY_SIZE(formats); ++i) { if (FAILED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, formats[i]))) @@ -20746,7 +20741,7 @@ static void test_flip(void) return; }
- for (i = 0; i < sizeof(back_buffers) / sizeof(*back_buffers); ++i) + for (i = 0; i < ARRAY_SIZE(back_buffers); ++i) { hr = IDirect3DDevice9_GetBackBuffer(device, 0, i, D3DBACKBUFFER_TYPE_MONO, &back_buffers[i]); ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr); @@ -20776,7 +20771,7 @@ static void test_flip(void) IDirect3DSurface9_Release(test_surface);
/* Backbuffer surface pointers are unmodified */ - for (i = 0; i < sizeof(back_buffers) / sizeof(*back_buffers); ++i) + for (i = 0; i < ARRAY_SIZE(back_buffers); ++i) { hr = IDirect3DDevice9_GetBackBuffer(device, 0, i, D3DBACKBUFFER_TYPE_MONO, &test_surface); ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr); @@ -20808,7 +20803,7 @@ static void test_flip(void) color = getPixelColorFromSurface(back_buffers[0], 1, 1); ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
- for (i = 0; i < sizeof(back_buffers) / sizeof(*back_buffers); ++i) + for (i = 0; i < ARRAY_SIZE(back_buffers); ++i) IDirect3DSurface9_Release(back_buffers[i]);
refcount = IDirect3DDevice9_Release(device); @@ -21107,7 +21102,7 @@ static void test_uninitialized_varyings(void) hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ); ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { if (caps.VertexShaderVersion < tests[i].vs_version || caps.PixelShaderVersion < tests[i].ps_version) @@ -21986,7 +21981,7 @@ static void test_texture_blending(void) hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); ok(hr == D3D_OK, "Failed to disable lighting, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { const struct test *current_test = &tests[i];
@@ -22224,7 +22219,7 @@ static void test_color_clamping(void) hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ); ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { if (caps.VertexShaderVersion < tests[i].vs_version || caps.PixelShaderVersion < tests[i].ps_version) @@ -23508,7 +23503,7 @@ static void test_null_format(void) hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i) + for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y); todo_wine_if(expected_colors[i].todo) ok(color_match(color, expected_colors[i].color, 1), @@ -23691,7 +23686,7 @@ static void test_map_synchronisation(void) } size = (tri_count + 2) * sizeof(*quad1.strip);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice9_CreateVertexBuffer(device, size, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &buffer, NULL);
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=36228
Your paranoid android.
=== w1064 (32 bit visual) === visual.c:8493: Test failed: Got unexpected color 0x00007580 for quad 2 (different colors).
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/context.c | 76 ++++++++++++++++-------------------------- dlls/wined3d/wined3d_private.h | 6 ++-- 2 files changed, 30 insertions(+), 52 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 04853c99b722..df416891463d 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -372,18 +372,19 @@ void context_check_fbo_status(const struct wined3d_context *context, GLenum targ const struct wined3d_gl_info *gl_info = context->gl_info; GLenum status;
- if (!FIXME_ON(d3d)) return; + if (!FIXME_ON(d3d)) + return;
status = gl_info->fbo_ops.glCheckFramebufferStatus(target); if (status == GL_FRAMEBUFFER_COMPLETE) { - TRACE("FBO complete\n"); + TRACE("FBO complete.\n"); } else { unsigned int i;
- FIXME("FBO status %s (%#x)\n", debug_fbostatus(status), status); + FIXME("FBO status %s (%#x).\n", debug_fbostatus(status), status);
if (!context->current_fbo) { @@ -396,7 +397,6 @@ void context_check_fbo_status(const struct wined3d_context *context, GLenum targ
for (i = 0; i < gl_info->limits.buffers; ++i) context_dump_fbo_attachment(gl_info, target, GL_COLOR_ATTACHMENT0 + i); - checkGLcall("Dump FBO attachments"); } }
@@ -493,16 +493,18 @@ static inline void context_set_fbo_key_for_render_target(const struct wined3d_co
static void context_generate_fbo_key(const struct wined3d_context *context, struct wined3d_fbo_entry_key *key, const struct wined3d_rendertarget_info *render_targets, - const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, - DWORD ds_location) + const struct wined3d_rendertarget_info *depth_stencil, DWORD color_location, DWORD ds_location) { + unsigned int buffers = context->gl_info->limits.buffers; unsigned int i;
key->rb_namespace = 0; context_set_fbo_key_for_render_target(context, key, 0, depth_stencil, ds_location);
- for (i = 0; i < context->gl_info->limits.buffers; ++i) + for (i = 0; i < buffers; ++i) context_set_fbo_key_for_render_target(context, key, i + 1, &render_targets[i], color_location); + + memset(&key->objects[buffers + 1], 0, (ARRAY_SIZE(key->objects) - buffers - 1) * sizeof(*key->objects)); }
static struct fbo_entry *context_create_fbo_entry(const struct wined3d_context *context, @@ -510,11 +512,9 @@ static struct fbo_entry *context_create_fbo_entry(const struct wined3d_context * DWORD color_location, DWORD ds_location) { const struct wined3d_gl_info *gl_info = context->gl_info; - unsigned int object_count = gl_info->limits.buffers + 1; struct fbo_entry *entry;
- entry = heap_alloc(FIELD_OFFSET(struct fbo_entry, key.objects[object_count])); - memset(&entry->key, 0, FIELD_OFFSET(struct wined3d_fbo_entry_key, objects[object_count])); + entry = heap_alloc(sizeof(*entry)); context_generate_fbo_key(context, &entry->key, render_targets, depth_stencil, color_location, ds_location); entry->flags = 0; if (depth_stencil->resource) @@ -573,8 +573,8 @@ static struct fbo_entry *context_find_fbo_entry(struct wined3d_context *context, { static const struct wined3d_rendertarget_info ds_null = {{0}}; const struct wined3d_gl_info *gl_info = context->gl_info; - unsigned int object_count = gl_info->limits.buffers + 1; struct wined3d_texture *rt_texture, *ds_texture; + struct wined3d_fbo_entry_key fbo_key; unsigned int i, ds_level, rt_level; struct fbo_entry *entry;
@@ -611,8 +611,7 @@ static struct fbo_entry *context_find_fbo_entry(struct wined3d_context *context, } }
- context_generate_fbo_key(context, context->fbo_key, render_targets, depth_stencil, color_location, - ds_location); + context_generate_fbo_key(context, &fbo_key, render_targets, depth_stencil, color_location, ds_location);
if (TRACE_ON(d3d)) { @@ -642,8 +641,8 @@ static struct fbo_entry *context_find_fbo_entry(struct wined3d_context *context,
TRACE(" Color attachment %u: %p, %u format %s, %s %u, %ux%u, %u samples.\n", i, resource, render_targets[i].sub_resource_idx, debug_d3dformat(resource->format->id), - context->fbo_key->rb_namespace & (1 << (i + 1)) ? "renderbuffer" : resource_type, - context->fbo_key->objects[i + 1].object, width, height, resource->multisample_type); + fbo_key.rb_namespace & (1 << (i + 1)) ? "renderbuffer" : resource_type, + fbo_key.objects[i + 1].object, width, height, resource->multisample_type); } } if ((resource = depth_stencil->resource)) @@ -665,14 +664,14 @@ static struct fbo_entry *context_find_fbo_entry(struct wined3d_context *context,
TRACE(" Depth attachment: %p, %u format %s, %s %u, %ux%u, %u samples.\n", resource, depth_stencil->sub_resource_idx, debug_d3dformat(resource->format->id), - context->fbo_key->rb_namespace & (1 << 0) ? "renderbuffer" : resource_type, - context->fbo_key->objects[0].object, width, height, resource->multisample_type); + fbo_key.rb_namespace & (1 << 0) ? "renderbuffer" : resource_type, + fbo_key.objects[0].object, width, height, resource->multisample_type); } }
LIST_FOR_EACH_ENTRY(entry, &context->fbo_list, struct fbo_entry, entry) { - if (memcmp(context->fbo_key, &entry->key, FIELD_OFFSET(struct wined3d_fbo_entry_key, objects[object_count]))) + if (memcmp(&fbo_key, &entry->key, sizeof(fbo_key))) continue;
list_remove(&entry->entry); @@ -782,7 +781,7 @@ static void context_apply_fbo_state(struct wined3d_context *context, GLenum targ void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target, struct wined3d_surface *render_target, struct wined3d_surface *depth_stencil, DWORD location) { - memset(context->blit_targets, 0, context->gl_info->limits.buffers * sizeof(*context->blit_targets)); + memset(context->blit_targets, 0, sizeof(context->blit_targets)); if (render_target) { context->blit_targets[0].resource = &render_target->container->resource; @@ -1021,7 +1020,7 @@ typedef void (context_fbo_entry_func_t)(struct wined3d_context *context, struct static void context_enum_fbo_entries(const struct wined3d_device *device, GLuint name, BOOL rb_namespace, context_fbo_entry_func_t *callback) { - UINT i; + unsigned int i, j;
for (i = 0; i < device->context_count; ++i) { @@ -1031,8 +1030,6 @@ static void context_enum_fbo_entries(const struct wined3d_device *device,
LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_list, struct fbo_entry, entry) { - UINT j; - for (j = 0; j < gl_info->limits.buffers + 1; ++j) { if (entry->key.objects[j].object == name @@ -1888,16 +1885,6 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, if (!(ret = heap_alloc_zero(sizeof(*ret)))) return NULL;
- if (!(ret->blit_targets = heap_calloc(gl_info->limits.buffers, sizeof(*ret->blit_targets)))) - goto out; - - if (!(ret->draw_buffers = heap_calloc(gl_info->limits.buffers, sizeof(*ret->draw_buffers)))) - goto out; - - if (!(ret->fbo_key = heap_alloc_zero(FIELD_OFFSET(struct wined3d_fbo_entry_key, - objects[gl_info->limits.buffers + 1])))) - goto out; - ret->free_timestamp_query_size = 4; if (!(ret->free_timestamp_queries = heap_calloc(ret->free_timestamp_query_size, sizeof(*ret->free_timestamp_queries)))) @@ -2272,9 +2259,6 @@ out: heap_free(ret->free_fences); heap_free(ret->free_occlusion_queries); heap_free(ret->free_timestamp_queries); - heap_free(ret->fbo_key); - heap_free(ret->draw_buffers); - heap_free(ret->blit_targets); heap_free(ret); return NULL; } @@ -2318,9 +2302,6 @@ void context_destroy(struct wined3d_device *device, struct wined3d_context *cont device->shader_backend->shader_free_context_data(context); device->adapter->fragment_pipe->free_context_data(context); heap_free(context->texture_type); - heap_free(context->fbo_key); - heap_free(context->draw_buffers); - heap_free(context->blit_targets); device_context_remove(device, context); if (destroy) heap_free(context); @@ -2649,16 +2630,15 @@ static inline GLenum draw_buffer_from_rt_mask(DWORD rt_mask) static void context_apply_draw_buffers(struct wined3d_context *context, DWORD rt_mask) { const struct wined3d_gl_info *gl_info = context->gl_info; + GLenum draw_buffers[MAX_RENDER_TARGET_VIEWS];
if (!rt_mask) { gl_info->gl_ops.gl.p_glDrawBuffer(GL_NONE); - checkGLcall("glDrawBuffer()"); } else if (is_rt_mask_onscreen(rt_mask)) { gl_info->gl_ops.gl.p_glDrawBuffer(draw_buffer_from_rt_mask(rt_mask)); - checkGLcall("glDrawBuffer()"); } else { @@ -2669,9 +2649,9 @@ static void context_apply_draw_buffers(struct wined3d_context *context, DWORD rt while (rt_mask) { if (rt_mask & 1) - context->draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i; + draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i; else - context->draw_buffers[i] = GL_NONE; + draw_buffers[i] = GL_NONE;
rt_mask >>= 1; ++i; @@ -2679,13 +2659,11 @@ static void context_apply_draw_buffers(struct wined3d_context *context, DWORD rt
if (gl_info->supported[ARB_DRAW_BUFFERS]) { - GL_EXTCALL(glDrawBuffers(i, context->draw_buffers)); - checkGLcall("glDrawBuffers()"); + GL_EXTCALL(glDrawBuffers(i, draw_buffers)); } else { - gl_info->gl_ops.gl.p_glDrawBuffer(context->draw_buffers[0]); - checkGLcall("glDrawBuffer()"); + gl_info->gl_ops.gl.p_glDrawBuffer(draw_buffers[0]); } } else @@ -2693,6 +2671,8 @@ static void context_apply_draw_buffers(struct wined3d_context *context, DWORD rt ERR("Unexpected draw buffers mask with backbuffer ORM.\n"); } } + + checkGLcall("apply draw buffers"); }
/* Context activation is done by the caller. */ @@ -3057,7 +3037,7 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win
if (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource)) { - memset(context->blit_targets, 0, gl_info->limits.buffers * sizeof(*context->blit_targets)); + memset(context->blit_targets, 0, sizeof(context->blit_targets)); for (i = 0; i < rt_count; ++i) { if (rts[i]) @@ -3192,7 +3172,7 @@ void context_state_fb(struct wined3d_context *context, const struct wined3d_stat { unsigned int i;
- memset(context->blit_targets, 0, context->gl_info->limits.buffers * sizeof (*context->blit_targets)); + memset(context->blit_targets, 0, sizeof(context->blit_targets)); for (i = 0; i < context->gl_info->limits.buffers; ++i) { if (fb->render_targets[i]) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 7813df5b6ef3..f085f2d8b85e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1945,9 +1945,7 @@ struct wined3d_context struct fbo_entry *current_fbo; GLuint fbo_read_binding; GLuint fbo_draw_binding; - struct wined3d_rendertarget_info *blit_targets; - struct wined3d_fbo_entry_key *fbo_key; - GLenum *draw_buffers; + struct wined3d_rendertarget_info blit_targets[MAX_RENDER_TARGET_VIEWS]; DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
/* Queries */ @@ -3299,7 +3297,7 @@ struct fbo_entry struct wined3d_fbo_entry_key { DWORD rb_namespace; - struct wined3d_fbo_resource objects[1]; + struct wined3d_fbo_resource objects[MAX_RENDER_TARGET_VIEWS + 1]; } key; };
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/context.c | 55 +++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 21 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index df416891463d..32126b7dc078 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -4170,6 +4170,26 @@ static void context_setup_target(struct wined3d_context *context, context_set_render_offscreen(context, render_offscreen); }
+static void context_activate(struct wined3d_context *context, + struct wined3d_texture *texture, unsigned int sub_resource_idx) +{ + context_enter(context); + context_update_window(context); + context_setup_target(context, texture, sub_resource_idx); + if (!context->valid) + return; + + if (context != context_get_current()) + { + if (!context_set_current(context)) + ERR("Failed to activate the new context.\n"); + } + else if (context->needs_set) + { + context_set_gl_context(context); + } +} + struct wined3d_context *context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx) { @@ -4228,21 +4248,7 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, context = swapchain_get_context(device->swapchains[0]); }
- context_enter(context); - context_update_window(context); - context_setup_target(context, texture, sub_resource_idx); - if (!context->valid) - return context; - - if (context != current_context) - { - if (!context_set_current(context)) - ERR("Failed to activate the new context.\n"); - } - else if (context->needs_set) - { - context_set_gl_context(context); - } + context_activate(context, texture, sub_resource_idx);
return context; } @@ -4250,16 +4256,23 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, struct wined3d_context *context_reacquire(const struct wined3d_device *device, struct wined3d_context *context) { - struct wined3d_context *current_context; + struct wined3d_context *acquired_context; + + wined3d_from_cs(device->cs);
if (!context || context->tid != GetCurrentThreadId()) return NULL;
- current_context = context_acquire(device, context->current_rt.texture, - context->current_rt.sub_resource_idx); - if (current_context != context) - ERR("Acquired context %p instead of %p.\n", current_context, context); - return current_context; + if (context->current_rt.texture) + { + context_activate(context, context->current_rt.texture, context->current_rt.sub_resource_idx); + return context; + } + + acquired_context = context_acquire(device, NULL, 0); + if (acquired_context != context) + ERR("Acquired context %p instead of %p.\n", acquired_context, context); + return acquired_context; }
void dispatch_compute(struct wined3d_device *device, const struct wined3d_state *state,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com