Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 16 ++++++++++------ dlls/wined3d/stateblock.c | 7 ++++--- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 28e113ac81..18c775a7d7 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2708,18 +2708,22 @@ HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device, || count > d3d_info->limits.ps_uniform_count - start_idx) return WINED3DERR_INVALIDCALL;
- memcpy(&device->update_state->ps_consts_f[start_idx], constants, count * sizeof(*constants)); + memcpy(&device->update_stateblock_state->ps_consts_f[start_idx], constants, count * sizeof(*constants)); + if (device->recording) + { + memset(&device->recording->changed.ps_consts_f[start_idx], 1, + count * sizeof(*device->recording->changed.ps_consts_f)); + return WINED3D_OK; + } + + memcpy(&device->state.ps_consts_f[start_idx], constants, count * sizeof(*constants)); if (TRACE_ON(d3d)) { for (i = 0; i < count; ++i) TRACE("Set vec4 constant %u to %s.\n", start_idx + i, debug_vec4(&constants[i])); }
- if (device->recording) - memset(&device->recording->changed.ps_consts_f[start_idx], 1, - count * sizeof(*device->recording->changed.ps_consts_f)); - else - wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_F, start_idx, count, constants); + wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_F, start_idx, count, constants);
return WINED3D_OK; } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 2b916a9dd2..05d213bccf 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -743,9 +743,9 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) { unsigned int idx = stateblock->contained_ps_consts_f[i];
- TRACE("Setting ps_consts_f[%u] to %s.\n", idx, debug_vec4(&src_state->ps_consts_f[idx])); + TRACE("Setting ps_consts_f[%u] to %s.\n", idx, debug_vec4(&state->ps_consts_f[idx]));
- stateblock->state.ps_consts_f[idx] = src_state->ps_consts_f[idx]; + stateblock->stateblock_state.ps_consts_f[idx] = state->ps_consts_f[idx]; }
/* Pixel shader integer constants. */ @@ -1045,8 +1045,9 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) /* Pixel Shader Constants. */ for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i) { + state->ps_consts_f[i] = stateblock->stateblock_state.ps_consts_f[i]; wined3d_device_set_ps_consts_f(device, stateblock->contained_ps_consts_f[i], - 1, &stateblock->state.ps_consts_f[stateblock->contained_ps_consts_f[i]]); + 1, &stateblock->stateblock_state.ps_consts_f[stateblock->contained_ps_consts_f[i]]); } for (i = 0; i < stateblock->num_contained_ps_consts_i; ++i) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b638d8773c..6822874168 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2976,6 +2976,7 @@ struct wined3d_stateblock_state BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
struct wined3d_shader *ps; + struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F]; };
struct wined3d_device
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 17 +++++++++-------- dlls/wined3d/stateblock.c | 7 ++++--- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 18c775a7d7..d0e9d59c45 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2659,23 +2659,24 @@ HRESULT CDECL wined3d_device_set_ps_consts_i(struct wined3d_device *device,
if (count > WINED3D_MAX_CONSTS_I - start_idx) count = WINED3D_MAX_CONSTS_I - start_idx; - memcpy(&device->update_state->ps_consts_i[start_idx], constants, count * sizeof(*constants)); - if (TRACE_ON(d3d)) - { - for (i = 0; i < count; ++i) - TRACE("Set ivec4 constant %u to %s.\n", start_idx + i, debug_ivec4(&constants[i])); - }
+ memcpy(&device->update_stateblock_state->ps_consts_i[start_idx], constants, count * sizeof(*constants)); if (device->recording) { for (i = start_idx; i < count + start_idx; ++i) device->recording->changed.pixelShaderConstantsI |= (1u << i); + return WINED3D_OK; } - else + + memcpy(&device->state.ps_consts_i[start_idx], constants, count * sizeof(*constants)); + if (TRACE_ON(d3d)) { - wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_I, start_idx, count, constants); + for (i = 0; i < count; ++i) + TRACE("Set ivec4 constant %u to %s.\n", start_idx + i, debug_ivec4(&constants[i])); }
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_I, start_idx, count, constants); + return WINED3D_OK; }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 05d213bccf..340578c3b6 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -753,9 +753,9 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) { unsigned int idx = stateblock->contained_ps_consts_i[i];
- TRACE("Setting ps_consts_i[%u] to %s.\n", idx, debug_ivec4(&src_state->ps_consts_i[idx])); + TRACE("Setting ps_consts_i[%u] to %s.\n", idx, debug_ivec4(&state->ps_consts_i[idx]));
- stateblock->state.ps_consts_i[idx] = src_state->ps_consts_i[idx]; + stateblock->stateblock_state.ps_consts_i[idx] = state->ps_consts_i[idx]; }
/* Pixel shader boolean constants. */ @@ -1051,8 +1051,9 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) } for (i = 0; i < stateblock->num_contained_ps_consts_i; ++i) { + state->ps_consts_i[i] = stateblock->stateblock_state.ps_consts_i[i]; wined3d_device_set_ps_consts_i(device, stateblock->contained_ps_consts_i[i], - 1, &stateblock->state.ps_consts_i[stateblock->contained_ps_consts_i[i]]); + 1, &stateblock->stateblock_state.ps_consts_i[stateblock->contained_ps_consts_i[i]]); } for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 6822874168..227b7fb7bb 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2977,6 +2977,7 @@ struct wined3d_stateblock_state
struct wined3d_shader *ps; struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F]; + struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I]; };
struct wined3d_device
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 17 +++++++++-------- dlls/wined3d/stateblock.c | 8 +++++--- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index d0e9d59c45..2c2233175a 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2610,23 +2610,24 @@ HRESULT CDECL wined3d_device_set_ps_consts_b(struct wined3d_device *device,
if (count > WINED3D_MAX_CONSTS_B - start_idx) count = WINED3D_MAX_CONSTS_B - start_idx; - memcpy(&device->update_state->ps_consts_b[start_idx], constants, count * sizeof(*constants)); - if (TRACE_ON(d3d)) - { - for (i = 0; i < count; ++i) - TRACE("Set BOOL constant %u to %#x.\n", start_idx + i, constants[i]); - }
+ memcpy(&device->update_stateblock_state->ps_consts_b[start_idx], constants, count * sizeof(*constants)); if (device->recording) { for (i = start_idx; i < count + start_idx; ++i) device->recording->changed.pixelShaderConstantsB |= (1u << i); + return WINED3D_OK; } - else + + memcpy(&device->state.ps_consts_b[start_idx], constants, count * sizeof(*constants)); + if (TRACE_ON(d3d)) { - wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_B, start_idx, count, constants); + for (i = 0; i < count; ++i) + TRACE("Set BOOL constant %u to %#x.\n", start_idx + i, constants[i]); }
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_B, start_idx, count, constants); + return WINED3D_OK; }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 340578c3b6..a87e3ebbbf 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -762,10 +762,11 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i) { unsigned int idx = stateblock->contained_ps_consts_b[i]; + TRACE("Setting ps_consts_b[%u] to %s.\n", - idx, src_state->ps_consts_b[idx] ? "TRUE" : "FALSE"); + idx, state->ps_consts_b[idx] ? "TRUE" : "FALSE");
- stateblock->state.ps_consts_b[idx] = src_state->ps_consts_b[idx]; + stateblock->stateblock_state.ps_consts_b[idx] = state->ps_consts_b[idx]; }
/* Others + Render & Texture */ @@ -1057,8 +1058,9 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) } for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i) { + state->ps_consts_b[i] = stateblock->stateblock_state.ps_consts_b[i]; wined3d_device_set_ps_consts_b(device, stateblock->contained_ps_consts_b[i], - 1, &stateblock->state.ps_consts_b[stateblock->contained_ps_consts_b[i]]); + 1, &stateblock->stateblock_state.ps_consts_b[stateblock->contained_ps_consts_b[i]]); }
/* Render states. */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 227b7fb7bb..c347018723 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2978,6 +2978,7 @@ struct wined3d_stateblock_state struct wined3d_shader *ps; struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F]; struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I]; + BOOL ps_consts_b[WINED3D_MAX_CONSTS_B]; };
struct wined3d_device
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/stateblock.c | 256 +++++++++++++++++++------------------- 1 file changed, 130 insertions(+), 126 deletions(-)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index a87e3ebbbf..80d02a3414 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1159,7 +1159,7 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) TRACE("Applied stateblock %p.\n", stateblock); }
-static void state_init_default(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info) +static void init_default_render_states(DWORD rs[WINEHIGHEST_RENDER_STATE + 1], const struct wined3d_d3d_info *d3d_info) { union { @@ -1171,150 +1171,154 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d float f; DWORD d; } tmpfloat; - unsigned int i; - struct wined3d_matrix identity; - - TRACE("state %p, d3d_info %p.\n", state, d3d_info);
- get_identity_matrix(&identity); - state->gl_primitive_type = ~0u; - state->gl_patch_vertices = 0; - - /* Set some of the defaults for lights, transforms etc */ - state->transforms[WINED3D_TS_PROJECTION] = identity; - state->transforms[WINED3D_TS_VIEW] = identity; - for (i = 0; i < 256; ++i) - { - state->transforms[WINED3D_TS_WORLD_MATRIX(i)] = identity; - } - - TRACE("Render states\n"); - /* Render states: */ - state->render_states[WINED3D_RS_ZENABLE] = WINED3D_ZB_TRUE; - state->render_states[WINED3D_RS_FILLMODE] = WINED3D_FILL_SOLID; - state->render_states[WINED3D_RS_SHADEMODE] = WINED3D_SHADE_GOURAUD; + rs[WINED3D_RS_ZENABLE] = WINED3D_ZB_TRUE; + rs[WINED3D_RS_FILLMODE] = WINED3D_FILL_SOLID; + rs[WINED3D_RS_SHADEMODE] = WINED3D_SHADE_GOURAUD; lp.lp.repeat_factor = 0; lp.lp.line_pattern = 0; - state->render_states[WINED3D_RS_LINEPATTERN] = lp.d; - state->render_states[WINED3D_RS_ZWRITEENABLE] = TRUE; - state->render_states[WINED3D_RS_ALPHATESTENABLE] = FALSE; - state->render_states[WINED3D_RS_LASTPIXEL] = TRUE; - state->render_states[WINED3D_RS_SRCBLEND] = WINED3D_BLEND_ONE; - state->render_states[WINED3D_RS_DESTBLEND] = WINED3D_BLEND_ZERO; - state->render_states[WINED3D_RS_CULLMODE] = WINED3D_CULL_BACK; - state->render_states[WINED3D_RS_ZFUNC] = WINED3D_CMP_LESSEQUAL; - state->render_states[WINED3D_RS_ALPHAFUNC] = WINED3D_CMP_ALWAYS; - state->render_states[WINED3D_RS_ALPHAREF] = 0; - state->render_states[WINED3D_RS_DITHERENABLE] = FALSE; - state->render_states[WINED3D_RS_ALPHABLENDENABLE] = FALSE; - state->render_states[WINED3D_RS_FOGENABLE] = FALSE; - state->render_states[WINED3D_RS_SPECULARENABLE] = FALSE; - state->render_states[WINED3D_RS_ZVISIBLE] = 0; - state->render_states[WINED3D_RS_FOGCOLOR] = 0; - state->render_states[WINED3D_RS_FOGTABLEMODE] = WINED3D_FOG_NONE; + rs[WINED3D_RS_LINEPATTERN] = lp.d; + rs[WINED3D_RS_ZWRITEENABLE] = TRUE; + rs[WINED3D_RS_ALPHATESTENABLE] = FALSE; + rs[WINED3D_RS_LASTPIXEL] = TRUE; + rs[WINED3D_RS_SRCBLEND] = WINED3D_BLEND_ONE; + rs[WINED3D_RS_DESTBLEND] = WINED3D_BLEND_ZERO; + rs[WINED3D_RS_CULLMODE] = WINED3D_CULL_BACK; + rs[WINED3D_RS_ZFUNC] = WINED3D_CMP_LESSEQUAL; + rs[WINED3D_RS_ALPHAFUNC] = WINED3D_CMP_ALWAYS; + rs[WINED3D_RS_ALPHAREF] = 0; + rs[WINED3D_RS_DITHERENABLE] = FALSE; + rs[WINED3D_RS_ALPHABLENDENABLE] = FALSE; + rs[WINED3D_RS_FOGENABLE] = FALSE; + rs[WINED3D_RS_SPECULARENABLE] = FALSE; + rs[WINED3D_RS_ZVISIBLE] = 0; + rs[WINED3D_RS_FOGCOLOR] = 0; + rs[WINED3D_RS_FOGTABLEMODE] = WINED3D_FOG_NONE; tmpfloat.f = 0.0f; - state->render_states[WINED3D_RS_FOGSTART] = tmpfloat.d; + rs[WINED3D_RS_FOGSTART] = tmpfloat.d; tmpfloat.f = 1.0f; - state->render_states[WINED3D_RS_FOGEND] = tmpfloat.d; + rs[WINED3D_RS_FOGEND] = tmpfloat.d; tmpfloat.f = 1.0f; - state->render_states[WINED3D_RS_FOGDENSITY] = tmpfloat.d; - state->render_states[WINED3D_RS_EDGEANTIALIAS] = FALSE; - state->render_states[WINED3D_RS_RANGEFOGENABLE] = FALSE; - state->render_states[WINED3D_RS_STENCILENABLE] = FALSE; - state->render_states[WINED3D_RS_STENCILFAIL] = WINED3D_STENCIL_OP_KEEP; - state->render_states[WINED3D_RS_STENCILZFAIL] = WINED3D_STENCIL_OP_KEEP; - state->render_states[WINED3D_RS_STENCILPASS] = WINED3D_STENCIL_OP_KEEP; - state->render_states[WINED3D_RS_STENCILREF] = 0; - state->render_states[WINED3D_RS_STENCILMASK] = 0xffffffff; - state->render_states[WINED3D_RS_STENCILFUNC] = WINED3D_CMP_ALWAYS; - state->render_states[WINED3D_RS_STENCILWRITEMASK] = 0xffffffff; - state->render_states[WINED3D_RS_TEXTUREFACTOR] = 0xffffffff; - state->render_states[WINED3D_RS_WRAP0] = 0; - state->render_states[WINED3D_RS_WRAP1] = 0; - state->render_states[WINED3D_RS_WRAP2] = 0; - state->render_states[WINED3D_RS_WRAP3] = 0; - state->render_states[WINED3D_RS_WRAP4] = 0; - state->render_states[WINED3D_RS_WRAP5] = 0; - state->render_states[WINED3D_RS_WRAP6] = 0; - state->render_states[WINED3D_RS_WRAP7] = 0; - state->render_states[WINED3D_RS_CLIPPING] = TRUE; - state->render_states[WINED3D_RS_LIGHTING] = TRUE; - state->render_states[WINED3D_RS_AMBIENT] = 0; - state->render_states[WINED3D_RS_FOGVERTEXMODE] = WINED3D_FOG_NONE; - state->render_states[WINED3D_RS_COLORVERTEX] = TRUE; - state->render_states[WINED3D_RS_LOCALVIEWER] = TRUE; - state->render_states[WINED3D_RS_NORMALIZENORMALS] = FALSE; - state->render_states[WINED3D_RS_DIFFUSEMATERIALSOURCE] = WINED3D_MCS_COLOR1; - state->render_states[WINED3D_RS_SPECULARMATERIALSOURCE] = WINED3D_MCS_COLOR2; - state->render_states[WINED3D_RS_AMBIENTMATERIALSOURCE] = WINED3D_MCS_MATERIAL; - state->render_states[WINED3D_RS_EMISSIVEMATERIALSOURCE] = WINED3D_MCS_MATERIAL; - state->render_states[WINED3D_RS_VERTEXBLEND] = WINED3D_VBF_DISABLE; - state->render_states[WINED3D_RS_CLIPPLANEENABLE] = 0; - state->render_states[WINED3D_RS_SOFTWAREVERTEXPROCESSING] = FALSE; + rs[WINED3D_RS_FOGDENSITY] = tmpfloat.d; + rs[WINED3D_RS_EDGEANTIALIAS] = FALSE; + rs[WINED3D_RS_RANGEFOGENABLE] = FALSE; + rs[WINED3D_RS_STENCILENABLE] = FALSE; + rs[WINED3D_RS_STENCILFAIL] = WINED3D_STENCIL_OP_KEEP; + rs[WINED3D_RS_STENCILZFAIL] = WINED3D_STENCIL_OP_KEEP; + rs[WINED3D_RS_STENCILPASS] = WINED3D_STENCIL_OP_KEEP; + rs[WINED3D_RS_STENCILREF] = 0; + rs[WINED3D_RS_STENCILMASK] = 0xffffffff; + rs[WINED3D_RS_STENCILFUNC] = WINED3D_CMP_ALWAYS; + rs[WINED3D_RS_STENCILWRITEMASK] = 0xffffffff; + rs[WINED3D_RS_TEXTUREFACTOR] = 0xffffffff; + rs[WINED3D_RS_WRAP0] = 0; + rs[WINED3D_RS_WRAP1] = 0; + rs[WINED3D_RS_WRAP2] = 0; + rs[WINED3D_RS_WRAP3] = 0; + rs[WINED3D_RS_WRAP4] = 0; + rs[WINED3D_RS_WRAP5] = 0; + rs[WINED3D_RS_WRAP6] = 0; + rs[WINED3D_RS_WRAP7] = 0; + rs[WINED3D_RS_CLIPPING] = TRUE; + rs[WINED3D_RS_LIGHTING] = TRUE; + rs[WINED3D_RS_AMBIENT] = 0; + rs[WINED3D_RS_FOGVERTEXMODE] = WINED3D_FOG_NONE; + rs[WINED3D_RS_COLORVERTEX] = TRUE; + rs[WINED3D_RS_LOCALVIEWER] = TRUE; + rs[WINED3D_RS_NORMALIZENORMALS] = FALSE; + rs[WINED3D_RS_DIFFUSEMATERIALSOURCE] = WINED3D_MCS_COLOR1; + rs[WINED3D_RS_SPECULARMATERIALSOURCE] = WINED3D_MCS_COLOR2; + rs[WINED3D_RS_AMBIENTMATERIALSOURCE] = WINED3D_MCS_MATERIAL; + rs[WINED3D_RS_EMISSIVEMATERIALSOURCE] = WINED3D_MCS_MATERIAL; + rs[WINED3D_RS_VERTEXBLEND] = WINED3D_VBF_DISABLE; + rs[WINED3D_RS_CLIPPLANEENABLE] = 0; + rs[WINED3D_RS_SOFTWAREVERTEXPROCESSING] = FALSE; tmpfloat.f = 1.0f; - state->render_states[WINED3D_RS_POINTSIZE] = tmpfloat.d; + rs[WINED3D_RS_POINTSIZE] = tmpfloat.d; tmpfloat.f = 1.0f; - state->render_states[WINED3D_RS_POINTSIZE_MIN] = tmpfloat.d; - state->render_states[WINED3D_RS_POINTSPRITEENABLE] = FALSE; - state->render_states[WINED3D_RS_POINTSCALEENABLE] = FALSE; + rs[WINED3D_RS_POINTSIZE_MIN] = tmpfloat.d; + rs[WINED3D_RS_POINTSPRITEENABLE] = FALSE; + rs[WINED3D_RS_POINTSCALEENABLE] = FALSE; tmpfloat.f = 1.0f; - state->render_states[WINED3D_RS_POINTSCALE_A] = tmpfloat.d; + rs[WINED3D_RS_POINTSCALE_A] = tmpfloat.d; tmpfloat.f = 0.0f; - state->render_states[WINED3D_RS_POINTSCALE_B] = tmpfloat.d; + rs[WINED3D_RS_POINTSCALE_B] = tmpfloat.d; tmpfloat.f = 0.0f; - state->render_states[WINED3D_RS_POINTSCALE_C] = tmpfloat.d; - state->render_states[WINED3D_RS_MULTISAMPLEANTIALIAS] = TRUE; - state->render_states[WINED3D_RS_MULTISAMPLEMASK] = 0xffffffff; - state->render_states[WINED3D_RS_PATCHEDGESTYLE] = WINED3D_PATCH_EDGE_DISCRETE; + rs[WINED3D_RS_POINTSCALE_C] = tmpfloat.d; + rs[WINED3D_RS_MULTISAMPLEANTIALIAS] = TRUE; + rs[WINED3D_RS_MULTISAMPLEMASK] = 0xffffffff; + rs[WINED3D_RS_PATCHEDGESTYLE] = WINED3D_PATCH_EDGE_DISCRETE; tmpfloat.f = 1.0f; - state->render_states[WINED3D_RS_PATCHSEGMENTS] = tmpfloat.d; - state->render_states[WINED3D_RS_DEBUGMONITORTOKEN] = 0xbaadcafe; + rs[WINED3D_RS_PATCHSEGMENTS] = tmpfloat.d; + rs[WINED3D_RS_DEBUGMONITORTOKEN] = 0xbaadcafe; tmpfloat.f = d3d_info->limits.pointsize_max; - state->render_states[WINED3D_RS_POINTSIZE_MAX] = tmpfloat.d; - state->render_states[WINED3D_RS_INDEXEDVERTEXBLENDENABLE] = FALSE; - state->render_states[WINED3D_RS_COLORWRITEENABLE] = 0x0000000f; + rs[WINED3D_RS_POINTSIZE_MAX] = tmpfloat.d; + rs[WINED3D_RS_INDEXEDVERTEXBLENDENABLE] = FALSE; + rs[WINED3D_RS_COLORWRITEENABLE] = 0x0000000f; tmpfloat.f = 0.0f; - state->render_states[WINED3D_RS_TWEENFACTOR] = tmpfloat.d; - state->render_states[WINED3D_RS_BLENDOP] = WINED3D_BLEND_OP_ADD; - state->render_states[WINED3D_RS_POSITIONDEGREE] = WINED3D_DEGREE_CUBIC; - state->render_states[WINED3D_RS_NORMALDEGREE] = WINED3D_DEGREE_LINEAR; + rs[WINED3D_RS_TWEENFACTOR] = tmpfloat.d; + rs[WINED3D_RS_BLENDOP] = WINED3D_BLEND_OP_ADD; + rs[WINED3D_RS_POSITIONDEGREE] = WINED3D_DEGREE_CUBIC; + rs[WINED3D_RS_NORMALDEGREE] = WINED3D_DEGREE_LINEAR; /* states new in d3d9 */ - state->render_states[WINED3D_RS_SCISSORTESTENABLE] = FALSE; - state->render_states[WINED3D_RS_SLOPESCALEDEPTHBIAS] = 0; + rs[WINED3D_RS_SCISSORTESTENABLE] = FALSE; + rs[WINED3D_RS_SLOPESCALEDEPTHBIAS] = 0; tmpfloat.f = 1.0f; - state->render_states[WINED3D_RS_MINTESSELLATIONLEVEL] = tmpfloat.d; - state->render_states[WINED3D_RS_MAXTESSELLATIONLEVEL] = tmpfloat.d; - state->render_states[WINED3D_RS_ANTIALIASEDLINEENABLE] = FALSE; + rs[WINED3D_RS_MINTESSELLATIONLEVEL] = tmpfloat.d; + rs[WINED3D_RS_MAXTESSELLATIONLEVEL] = tmpfloat.d; + rs[WINED3D_RS_ANTIALIASEDLINEENABLE] = FALSE; tmpfloat.f = 0.0f; - state->render_states[WINED3D_RS_ADAPTIVETESS_X] = tmpfloat.d; - state->render_states[WINED3D_RS_ADAPTIVETESS_Y] = tmpfloat.d; + rs[WINED3D_RS_ADAPTIVETESS_X] = tmpfloat.d; + rs[WINED3D_RS_ADAPTIVETESS_Y] = tmpfloat.d; tmpfloat.f = 1.0f; - state->render_states[WINED3D_RS_ADAPTIVETESS_Z] = tmpfloat.d; + rs[WINED3D_RS_ADAPTIVETESS_Z] = tmpfloat.d; tmpfloat.f = 0.0f; - state->render_states[WINED3D_RS_ADAPTIVETESS_W] = tmpfloat.d; - state->render_states[WINED3D_RS_ENABLEADAPTIVETESSELLATION] = FALSE; - state->render_states[WINED3D_RS_TWOSIDEDSTENCILMODE] = FALSE; - state->render_states[WINED3D_RS_BACK_STENCILFAIL] = WINED3D_STENCIL_OP_KEEP; - state->render_states[WINED3D_RS_BACK_STENCILZFAIL] = WINED3D_STENCIL_OP_KEEP; - state->render_states[WINED3D_RS_BACK_STENCILPASS] = WINED3D_STENCIL_OP_KEEP; - state->render_states[WINED3D_RS_BACK_STENCILFUNC] = WINED3D_CMP_ALWAYS; - state->render_states[WINED3D_RS_COLORWRITEENABLE1] = 0x0000000f; - state->render_states[WINED3D_RS_COLORWRITEENABLE2] = 0x0000000f; - state->render_states[WINED3D_RS_COLORWRITEENABLE3] = 0x0000000f; - state->render_states[WINED3D_RS_SRGBWRITEENABLE] = 0; - state->render_states[WINED3D_RS_DEPTHBIAS] = 0; - state->render_states[WINED3D_RS_WRAP8] = 0; - state->render_states[WINED3D_RS_WRAP9] = 0; - state->render_states[WINED3D_RS_WRAP10] = 0; - state->render_states[WINED3D_RS_WRAP11] = 0; - state->render_states[WINED3D_RS_WRAP12] = 0; - state->render_states[WINED3D_RS_WRAP13] = 0; - state->render_states[WINED3D_RS_WRAP14] = 0; - state->render_states[WINED3D_RS_WRAP15] = 0; - state->render_states[WINED3D_RS_SEPARATEALPHABLENDENABLE] = FALSE; - state->render_states[WINED3D_RS_SRCBLENDALPHA] = WINED3D_BLEND_ONE; - state->render_states[WINED3D_RS_DESTBLENDALPHA] = WINED3D_BLEND_ZERO; - state->render_states[WINED3D_RS_BLENDOPALPHA] = WINED3D_BLEND_OP_ADD; + rs[WINED3D_RS_ADAPTIVETESS_W] = tmpfloat.d; + rs[WINED3D_RS_ENABLEADAPTIVETESSELLATION] = FALSE; + rs[WINED3D_RS_TWOSIDEDSTENCILMODE] = FALSE; + rs[WINED3D_RS_BACK_STENCILFAIL] = WINED3D_STENCIL_OP_KEEP; + rs[WINED3D_RS_BACK_STENCILZFAIL] = WINED3D_STENCIL_OP_KEEP; + rs[WINED3D_RS_BACK_STENCILPASS] = WINED3D_STENCIL_OP_KEEP; + rs[WINED3D_RS_BACK_STENCILFUNC] = WINED3D_CMP_ALWAYS; + rs[WINED3D_RS_COLORWRITEENABLE1] = 0x0000000f; + rs[WINED3D_RS_COLORWRITEENABLE2] = 0x0000000f; + rs[WINED3D_RS_COLORWRITEENABLE3] = 0x0000000f; + rs[WINED3D_RS_SRGBWRITEENABLE] = 0; + rs[WINED3D_RS_DEPTHBIAS] = 0; + rs[WINED3D_RS_WRAP8] = 0; + rs[WINED3D_RS_WRAP9] = 0; + rs[WINED3D_RS_WRAP10] = 0; + rs[WINED3D_RS_WRAP11] = 0; + rs[WINED3D_RS_WRAP12] = 0; + rs[WINED3D_RS_WRAP13] = 0; + rs[WINED3D_RS_WRAP14] = 0; + rs[WINED3D_RS_WRAP15] = 0; + rs[WINED3D_RS_SEPARATEALPHABLENDENABLE] = FALSE; + rs[WINED3D_RS_SRCBLENDALPHA] = WINED3D_BLEND_ONE; + rs[WINED3D_RS_DESTBLENDALPHA] = WINED3D_BLEND_ZERO; + rs[WINED3D_RS_BLENDOPALPHA] = WINED3D_BLEND_OP_ADD; +} + +static void state_init_default(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info) +{ + unsigned int i; + struct wined3d_matrix identity; + + TRACE("state %p, d3d_info %p.\n", state, d3d_info); + + get_identity_matrix(&identity); + state->gl_primitive_type = ~0u; + state->gl_patch_vertices = 0; + + /* Set some of the defaults for lights, transforms etc */ + state->transforms[WINED3D_TS_PROJECTION] = identity; + state->transforms[WINED3D_TS_VIEW] = identity; + for (i = 0; i < 256; ++i) + { + state->transforms[WINED3D_TS_WORLD_MATRIX(i)] = identity; + } + + init_default_render_states(state->render_states, d3d_info);
/* Texture Stage States - Put directly into state block, we will call function below */ for (i = 0; i < MAX_TEXTURES; ++i)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 13 +++++++------ dlls/wined3d/stateblock.c | 21 ++++++++++++++++++--- dlls/wined3d/wined3d_private.h | 4 ++++ 3 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 2c2233175a..dee99dcde2 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2033,8 +2033,6 @@ struct wined3d_rasterizer_state * CDECL wined3d_device_get_rasterizer_state(stru void CDECL wined3d_device_set_render_state(struct wined3d_device *device, enum wined3d_render_state state, DWORD value) { - DWORD old_value; - TRACE("device %p, state %s (%#x), value %#x.\n", device, debug_d3drenderstate(state), state, value);
if (state > WINEHIGHEST_RENDER_STATE) @@ -2043,8 +2041,7 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device, return; }
- old_value = device->state.render_states[state]; - device->update_state->render_states[state] = value; + device->update_stateblock_state->rs[state] = value;
/* Handle recording of state blocks. */ if (device->recording) @@ -2054,11 +2051,13 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device, return; }
- /* Compared here and not before the assignment to allow proper stateblock recording. */ - if (value == old_value) + if (value == device->state.render_states[state]) TRACE("Application is setting the old value over, nothing to do.\n"); else + { + device->state.render_states[state] = value; wined3d_cs_emit_set_render_state(device->cs, state, value); + }
if (state == WINED3D_RS_POINTSIZE && value == WINED3D_RESZ_CODE) { @@ -5038,6 +5037,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, state_init(&device->state, &device->fb, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); device->update_state = &device->state; memset(&device->stateblock_state, 0, sizeof(device->stateblock_state)); + wined3d_stateblock_state_init(&device->stateblock_state, device, WINED3D_STATE_INIT_DEFAULT); device->update_stateblock_state = &device->stateblock_state;
device_init_swapchain_state(device, swapchain); @@ -5313,6 +5313,7 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
state_init(&device->state, &device->fb, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); device->update_state = &device->state; + wined3d_stateblock_state_init(&device->stateblock_state, device, WINED3D_STATE_INIT_DEFAULT); device->update_stateblock_state = &device->stateblock_state;
device->max_frame_latency = 3; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 80d02a3414..1c8e6aded4 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -916,9 +916,9 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) { enum wined3d_render_state rs = stateblock->contained_render_states[i];
- TRACE("Updating render state %#x to %u.\n", rs, src_state->render_states[rs]); + TRACE("Updating render state %#x to %u.\n", rs, state->rs[rs]);
- stateblock->state.render_states[rs] = src_state->render_states[rs]; + stateblock->stateblock_state.rs[rs] = state->rs[rs]; }
/* Texture states */ @@ -1066,8 +1066,9 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) /* Render states. */ for (i = 0; i < stateblock->num_contained_render_states; ++i) { + state->rs[i] = stateblock->stateblock_state.rs[i]; wined3d_device_set_render_state(device, stateblock->contained_render_states[i], - stateblock->state.render_states[stateblock->contained_render_states[i]]); + stateblock->stateblock_state.rs[stateblock->contained_render_states[i]]); }
/* Texture states. */ @@ -1387,6 +1388,19 @@ void state_init(struct wined3d_state *state, struct wined3d_fb_state *fb, state_init_default(state, d3d_info); }
+static void stateblock_state_init_default(struct wined3d_stateblock_state *state, + const struct wined3d_d3d_info *d3d_info) +{ + init_default_render_states(state->rs, d3d_info); +} + +void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state, + const struct wined3d_device *device, DWORD flags) +{ + if (flags & WINED3D_STATE_INIT_DEFAULT) + stateblock_state_init_default(state, &device->adapter->d3d_info); +} + static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, struct wined3d_device *device, enum wined3d_stateblock_type type) { @@ -1395,6 +1409,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, stateblock->ref = 1; stateblock->device = device; state_init(&stateblock->state, NULL, d3d_info, 0); + wined3d_stateblock_state_init(&stateblock->stateblock_state, device, 0);
if (type == WINED3D_SBT_RECORDED) return WINED3D_OK; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index c347018723..1e3ec28d6b 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2979,6 +2979,8 @@ struct wined3d_stateblock_state struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F]; struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I]; BOOL ps_consts_b[WINED3D_MAX_CONSTS_B]; + + DWORD rs[WINEHIGHEST_RENDER_STATE + 1]; };
struct wined3d_device @@ -3598,6 +3600,8 @@ struct wined3d_stateblock
void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
+void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state, + const struct wined3d_device *device, DWORD flags) DECLSPEC_HIDDEN; void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) DECLSPEC_HIDDEN;
void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com