wined3d: Pass a wined3d_state structure to use_vs().

This commit is contained in:
Henri Verbeet 2010-09-28 12:00:23 +02:00 committed by Alexandre Julliard
parent e59fdb83a6
commit 9224751a13
10 changed files with 121 additions and 104 deletions

View File

@ -4396,6 +4396,8 @@ static inline void find_arb_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWi
int i; int i;
WORD int_skip; WORD int_skip;
const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)shader->baseShader.device)->adapter->gl_info; const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)shader->baseShader.device)->adapter->gl_info;
const struct wined3d_state *state = &stateblock->state;
find_ps_compile_args(shader, stateblock, &args->super); find_ps_compile_args(shader, stateblock, &args->super);
/* This forces all local boolean constants to 1 to make them stateblock independent */ /* This forces all local boolean constants to 1 to make them stateblock independent */
@ -4403,7 +4405,7 @@ static inline void find_arb_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWi
for(i = 0; i < MAX_CONST_B; i++) for(i = 0; i < MAX_CONST_B; i++)
{ {
if (stateblock->state.ps_consts_b[i]) if (state->ps_consts_b[i])
args->bools |= ( 1 << i); args->bools |= ( 1 << i);
} }
@ -4411,9 +4413,9 @@ static inline void find_arb_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWi
* is quite expensive because it forces the driver to disable early Z discards. It is cheaper to * is quite expensive because it forces the driver to disable early Z discards. It is cheaper to
* duplicate the shader than have a no-op KIL instruction in every shader * duplicate the shader than have a no-op KIL instruction in every shader
*/ */
if ((!((IWineD3DDeviceImpl *)shader->baseShader.device)->vs_clipping) && use_vs(stateblock) if ((!((IWineD3DDeviceImpl *)shader->baseShader.device)->vs_clipping) && use_vs(state)
&& stateblock->state.render_states[WINED3DRS_CLIPPING] && state->render_states[WINED3DRS_CLIPPING]
&& stateblock->state.render_states[WINED3DRS_CLIPPLANEENABLE]) && state->render_states[WINED3DRS_CLIPPLANEENABLE])
args->clip = 1; args->clip = 1;
else else
args->clip = 0; args->clip = 0;
@ -4436,9 +4438,9 @@ static inline void find_arb_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWi
} }
else else
{ {
args->loop_ctrl[i][0] = stateblock->state.ps_consts_i[i * 4]; args->loop_ctrl[i][0] = state->ps_consts_i[i * 4];
args->loop_ctrl[i][1] = stateblock->state.ps_consts_i[i * 4 + 1]; args->loop_ctrl[i][1] = state->ps_consts_i[i * 4 + 1];
args->loop_ctrl[i][2] = stateblock->state.ps_consts_i[i * 4 + 2]; args->loop_ctrl[i][2] = state->ps_consts_i[i * 4 + 2];
} }
} }
} }
@ -6152,8 +6154,8 @@ static void fragment_prog_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock,
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
IWineD3DDeviceImpl *device = stateblock->device; IWineD3DDeviceImpl *device = stateblock->device;
struct shader_arb_priv *priv = device->fragment_priv; struct shader_arb_priv *priv = device->fragment_priv;
BOOL use_vshader = use_vs(&stateblock->state);
BOOL use_pshader = use_ps(stateblock); BOOL use_pshader = use_ps(stateblock);
BOOL use_vshader = use_vs(stateblock);
struct ffp_frag_settings settings; struct ffp_frag_settings settings;
const struct arbfp_ffp_desc *desc; const struct arbfp_ffp_desc *desc;
unsigned int i; unsigned int i;
@ -6244,26 +6246,28 @@ static void fragment_prog_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock,
* is that changing the fog start and fog end(which links to FOGENABLE in vertex) results in the * is that changing the fog start and fog end(which links to FOGENABLE in vertex) results in the
* fragment_prog_arbfp function being called because FOGENABLE is dirty, which calls this function here * fragment_prog_arbfp function being called because FOGENABLE is dirty, which calls this function here
*/ */
static void state_arbfp_fog(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void state_arbfp_fog(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
const struct wined3d_state *state = &stateblock->state;
enum fogsource new_source; enum fogsource new_source;
TRACE("state %#x, stateblock %p, context %p\n", state, stateblock, context); TRACE("state_id %#x, stateblock %p, context %p\n", state_id, stateblock, context);
if(!isStateDirty(context, STATE_PIXELSHADER)) { if(!isStateDirty(context, STATE_PIXELSHADER)) {
fragment_prog_arbfp(state, stateblock, context); fragment_prog_arbfp(state_id, stateblock, context);
} }
if (!stateblock->state.render_states[WINED3DRS_FOGENABLE]) return; if (!state->render_states[WINED3DRS_FOGENABLE]) return;
if (stateblock->state.render_states[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) if (state->render_states[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
{ {
if(use_vs(stateblock)) { if (use_vs(state))
{
new_source = FOGSOURCE_VS; new_source = FOGSOURCE_VS;
} }
else else
{ {
if (stateblock->state.render_states[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE || context->last_was_rhw) if (state->render_states[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE || context->last_was_rhw)
new_source = FOGSOURCE_COORD; new_source = FOGSOURCE_COORD;
else else
new_source = FOGSOURCE_FFP; new_source = FOGSOURCE_FFP;

View File

@ -887,10 +887,11 @@ static void textransform(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
} }
} }
static void atifs_apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void atifs_apply_pixelshader(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
const struct wined3d_state *state = &stateblock->state;
IWineD3DDeviceImpl *device = stateblock->device; IWineD3DDeviceImpl *device = stateblock->device;
BOOL use_vshader = use_vs(stateblock); BOOL use_vshader = use_vs(state);
context->last_was_pshader = use_ps(stateblock); context->last_was_pshader = use_ps(stateblock);
/* The ATIFS code does not support pixel shaders currently, but we have to provide a state handler /* The ATIFS code does not support pixel shaders currently, but we have to provide a state handler

View File

@ -401,6 +401,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
IWineD3DDeviceImpl *device = This->resource.device; IWineD3DDeviceImpl *device = This->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_stream_info *si = &device->strided_streams; const struct wined3d_stream_info *si = &device->strided_streams;
const struct wined3d_state *state = &device->stateBlock->state;
UINT stride_this_run = 0; UINT stride_this_run = 0;
BOOL float16_used = FALSE; BOOL float16_used = FALSE;
BOOL ret = FALSE; BOOL ret = FALSE;
@ -460,14 +461,14 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
* conversion types depend on the semantic as well, for example a FLOAT4 * conversion types depend on the semantic as well, for example a FLOAT4
* texcoord needs no conversion while a FLOAT4 positiont needs one * texcoord needs no conversion while a FLOAT4 positiont needs one
*/ */
if (use_vs(device->stateBlock)) if (use_vs(state))
{ {
TRACE("vshader\n"); TRACE("vshader\n");
/* If the current vertex declaration is marked for no half float conversion don't bother to /* If the current vertex declaration is marked for no half float conversion don't bother to
* analyse the strided streams in depth, just set them up for no conversion. Return decl changed * analyse the strided streams in depth, just set them up for no conversion. Return decl changed
* if we used conversion before * if we used conversion before
*/ */
if (!device->stateBlock->state.vertex_declaration->half_float_conv_needed) if (!state->vertex_declaration->half_float_conv_needed)
{ {
if (This->conversion_map) if (This->conversion_map)
{ {

View File

@ -466,13 +466,14 @@ static void device_preload_texture(IWineD3DStateBlockImpl *stateblock, unsigned
void device_preload_textures(IWineD3DDeviceImpl *device) void device_preload_textures(IWineD3DDeviceImpl *device)
{ {
IWineD3DStateBlockImpl *stateblock = device->stateBlock; IWineD3DStateBlockImpl *stateblock = device->stateBlock;
const struct wined3d_state *state = &stateblock->state;
unsigned int i; unsigned int i;
if (use_vs(stateblock)) if (use_vs(state))
{ {
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i)
{ {
if (stateblock->state.vertex_shader->baseShader.reg_maps.sampler_type[i]) if (state->vertex_shader->baseShader.reg_maps.sampler_type[i])
device_preload_texture(stateblock, MAX_FRAGMENT_SAMPLERS + i); device_preload_texture(stateblock, MAX_FRAGMENT_SAMPLERS + i);
} }
} }
@ -481,7 +482,7 @@ void device_preload_textures(IWineD3DDeviceImpl *device)
{ {
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
{ {
if (stateblock->state.pixel_shader->baseShader.reg_maps.sampler_type[i]) if (state->pixel_shader->baseShader.reg_maps.sampler_type[i])
device_preload_texture(stateblock, i); device_preload_texture(stateblock, i);
} }
} }
@ -3585,7 +3586,7 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps, const struct
void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This)
{ {
const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
BOOL vs = use_vs(This->stateBlock); BOOL vs = use_vs(&This->stateBlock->state);
BOOL ps = use_ps(This->stateBlock); BOOL ps = use_ps(This->stateBlock);
/* /*
* Rules are: * Rules are:

View File

@ -576,12 +576,13 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
{ {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
const struct wined3d_state *state = &This->stateBlock->state;
struct wined3d_context *context; struct wined3d_context *context;
unsigned int i; unsigned int i;
if (!index_count) return; if (!index_count) return;
if (This->stateBlock->state.render_states[WINED3DRS_COLORWRITEENABLE]) if (state->render_states[WINED3DRS_COLORWRITEENABLE])
{ {
/* Invalidate the back buffer memory so LockRect will read it the next time */ /* Invalidate the back buffer memory so LockRect will read it the next time */
for (i = 0; i < This->adapter->gl_info.limits.buffers; ++i) for (i = 0; i < This->adapter->gl_info.limits.buffers; ++i)
@ -616,8 +617,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
* depthstencil for D3DCMP_NEVER and D3DCMP_ALWAYS as well. Also note * depthstencil for D3DCMP_NEVER and D3DCMP_ALWAYS as well. Also note
* that we never copy the stencil data.*/ * that we never copy the stencil data.*/
DWORD location = context->render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN; DWORD location = context->render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN;
if (This->stateBlock->state.render_states[WINED3DRS_ZWRITEENABLE] if (state->render_states[WINED3DRS_ZWRITEENABLE] || state->render_states[WINED3DRS_ZENABLE])
|| This->stateBlock->state.render_states[WINED3DRS_ZENABLE])
{ {
RECT current_rect, draw_rect, r; RECT current_rect, draw_rect, r;
@ -637,7 +637,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
if (!EqualRect(&r, &draw_rect)) if (!EqualRect(&r, &draw_rect))
surface_load_ds_location(This->depth_stencil, context, location); surface_load_ds_location(This->depth_stencil, context, location);
if (This->stateBlock->state.render_states[WINED3DRS_ZWRITEENABLE]) if (state->render_states[WINED3DRS_ZWRITEENABLE])
{ {
surface_modify_ds_location(This->depth_stencil, location, surface_modify_ds_location(This->depth_stencil, location,
This->depth_stencil->ds_current_size.cx, This->depth_stencil->ds_current_size.cx,
@ -650,8 +650,8 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
if ((!context->gl_info->supported[WINED3D_GL_VERSION_2_0] if ((!context->gl_info->supported[WINED3D_GL_VERSION_2_0]
|| (!glPointParameteri && !context->gl_info->supported[NV_POINT_SPRITE])) || (!glPointParameteri && !context->gl_info->supported[NV_POINT_SPRITE]))
&& context->render_offscreen && context->render_offscreen
&& This->stateBlock->state.render_states[WINED3DRS_POINTSPRITEENABLE] && state->render_states[WINED3DRS_POINTSPRITEENABLE]
&& This->stateBlock->state.gl_primitive_type == GL_POINTS) && state->gl_primitive_type == GL_POINTS)
{ {
FIXME("Point sprite coordinate origin switching not supported.\n"); FIXME("Point sprite coordinate origin switching not supported.\n");
} }
@ -659,15 +659,15 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
/* Ok, we will be updating the screen from here onwards so grab the lock */ /* Ok, we will be updating the screen from here onwards so grab the lock */
ENTER_GL(); ENTER_GL();
{ {
GLenum glPrimType = This->stateBlock->state.gl_primitive_type; GLenum glPrimType = state->gl_primitive_type;
BOOL emulation = FALSE; BOOL emulation = FALSE;
const struct wined3d_stream_info *stream_info = &This->strided_streams; const struct wined3d_stream_info *stream_info = &This->strided_streams;
struct wined3d_stream_info stridedlcl; struct wined3d_stream_info stridedlcl;
if (!use_vs(This->stateBlock)) if (!use_vs(state))
{ {
if (!This->strided_streams.position_transformed && context->num_untracked_materials if (!This->strided_streams.position_transformed && context->num_untracked_materials
&& This->stateBlock->state.render_states[WINED3DRS_LIGHTING]) && state->render_states[WINED3DRS_LIGHTING])
{ {
static BOOL warned; static BOOL warned;
if (!warned) { if (!warned) {
@ -678,7 +678,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
} }
emulation = TRUE; emulation = TRUE;
} }
else if (context->fog_coord && This->stateBlock->state.render_states[WINED3DRS_FOGENABLE]) else if (context->fog_coord && state->render_states[WINED3DRS_FOGENABLE])
{ {
/* Either write a pipeline replacement shader or convert the specular alpha from unsigned byte /* Either write a pipeline replacement shader or convert the specular alpha from unsigned byte
* to a float in the vertex buffer * to a float in the vertex buffer
@ -700,9 +700,10 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
} }
} }
if (This->useDrawStridedSlow || emulation) { if (This->useDrawStridedSlow || emulation)
{
/* Immediate mode drawing */ /* Immediate mode drawing */
if (use_vs(This->stateBlock)) if (use_vs(state))
{ {
static BOOL warned; static BOOL warned;
if (!warned) { if (!warned) {

View File

@ -917,6 +917,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
{ {
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface; IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
const struct wined3d_state *state = &device->stateBlock->state;
const struct ps_compile_args *ps_args = ctx_priv->cur_ps_args; const struct ps_compile_args *ps_args = ctx_priv->cur_ps_args;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int i, extra_constants_needed = 0; unsigned int i, extra_constants_needed = 0;
@ -1062,7 +1063,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
shader_addline(buffer, "uniform sampler1D %csampler%u;\n", prefix, i); shader_addline(buffer, "uniform sampler1D %csampler%u;\n", prefix, i);
break; break;
case WINED3DSTT_2D: case WINED3DSTT_2D:
texture = device->stateBlock->state.textures[i]; texture = state->textures[i];
if (pshader && ps_args->shadow & (1 << i)) if (pshader && ps_args->shadow & (1 << i))
{ {
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB) if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
@ -1142,7 +1143,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
*/ */
if (pshader && reg_maps->shader_version.major >= 3) if (pshader && reg_maps->shader_version.major >= 3)
{ {
if (use_vs(device->stateBlock)) if (use_vs(state))
{ {
shader_addline(buffer, "varying vec4 IN[%u];\n", vec4_varyings(reg_maps->shader_version.major, gl_info)); shader_addline(buffer, "varying vec4 IN[%u];\n", vec4_varyings(reg_maps->shader_version.major, gl_info));
} else { } else {

View File

@ -2070,12 +2070,13 @@ static const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args) IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args)
{ {
const struct wined3d_state *state = &stateblock->state;
IWineD3DBaseTextureImpl *texture; IWineD3DBaseTextureImpl *texture;
IWineD3DDeviceImpl *device = stateblock->device; IWineD3DDeviceImpl *device = stateblock->device;
UINT i; UINT i;
memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */ memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */
if (stateblock->state.render_states[WINED3DRS_SRGBWRITEENABLE]) if (state->render_states[WINED3DRS_SRGBWRITEENABLE])
{ {
IWineD3DSurfaceImpl *rt = device->render_targets[0]; IWineD3DSurfaceImpl *rt = device->render_targets[0];
if(rt->resource.format->Flags & WINED3DFMT_FLAG_SRGB_WRITE) args->srgb_correction = 1; if(rt->resource.format->Flags & WINED3DFMT_FLAG_SRGB_WRITE) args->srgb_correction = 1;
@ -2086,7 +2087,7 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
{ {
if (!shader->baseShader.reg_maps.sampler_type[i]) continue; if (!shader->baseShader.reg_maps.sampler_type[i]) continue;
texture = stateblock->state.textures[i]; texture = state->textures[i];
if (!texture) if (!texture)
{ {
args->color_fixup[i] = COLOR_FIXUP_IDENTITY; args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
@ -2109,7 +2110,7 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
{ {
args->vp_mode = pretransformed; args->vp_mode = pretransformed;
} }
else if (use_vs(stateblock)) else if (use_vs(state))
{ {
args->vp_mode = vertexshader; args->vp_mode = vertexshader;
} }
@ -2122,18 +2123,18 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
else else
{ {
args->vp_mode = vertexshader; args->vp_mode = vertexshader;
if (stateblock->state.render_states[WINED3DRS_FOGENABLE]) if (state->render_states[WINED3DRS_FOGENABLE])
{ {
switch (stateblock->state.render_states[WINED3DRS_FOGTABLEMODE]) switch (state->render_states[WINED3DRS_FOGTABLEMODE])
{ {
case WINED3DFOG_NONE: case WINED3DFOG_NONE:
if (device->strided_streams.position_transformed || use_vs(stateblock)) if (device->strided_streams.position_transformed || use_vs(state))
{ {
args->fog = FOG_LINEAR; args->fog = FOG_LINEAR;
break; break;
} }
switch (stateblock->state.render_states[WINED3DRS_FOGVERTEXMODE]) switch (state->render_states[WINED3DRS_FOGVERTEXMODE])
{ {
case WINED3DFOG_NONE: /* Fall through. */ case WINED3DFOG_NONE: /* Fall through. */
case WINED3DFOG_LINEAR: args->fog = FOG_LINEAR; break; case WINED3DFOG_LINEAR: args->fog = FOG_LINEAR; break;

View File

@ -547,20 +547,21 @@ static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
} }
} }
static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void state_clipping(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
DWORD enable = 0xFFFFFFFF; DWORD enable = 0xFFFFFFFF;
DWORD disable = 0x00000000; DWORD disable = 0x00000000;
if (!stateblock->device->vs_clipping && use_vs(stateblock)) if (!stateblock->device->vs_clipping && use_vs(state))
{ {
/* The spec says that opengl clipping planes are disabled when using shaders. Direct3D planes aren't, /* The spec says that opengl clipping planes are disabled when using shaders. Direct3D planes aren't,
* so that is an issue. The MacOS ATI driver keeps clipping planes activated with shaders in some * so that is an issue. The MacOS ATI driver keeps clipping planes activated with shaders in some
* conditions I got sick of tracking down. The shader state handler disables all clip planes because * conditions I got sick of tracking down. The shader state handler disables all clip planes because
* of that - don't do anything here and keep them disabled * of that - don't do anything here and keep them disabled
*/ */
if (stateblock->state.render_states[WINED3DRS_CLIPPLANEENABLE]) if (state->render_states[WINED3DRS_CLIPPLANEENABLE])
{ {
static BOOL warned = FALSE; static BOOL warned = FALSE;
if(!warned) { if(!warned) {
@ -578,10 +579,10 @@ static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
/* If enabling / disabling all /* If enabling / disabling all
* TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum? * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
*/ */
if (stateblock->state.render_states[WINED3DRS_CLIPPING]) if (state->render_states[WINED3DRS_CLIPPING])
{ {
enable = stateblock->state.render_states[WINED3DRS_CLIPPLANEENABLE]; enable = state->render_states[WINED3DRS_CLIPPLANEENABLE];
disable = ~stateblock->state.render_states[WINED3DRS_CLIPPLANEENABLE]; disable = ~state->render_states[WINED3DRS_CLIPPLANEENABLE];
if (gl_info->supported[ARB_DEPTH_CLAMP]) if (gl_info->supported[ARB_DEPTH_CLAMP])
{ {
glDisable(GL_DEPTH_CLAMP); glDisable(GL_DEPTH_CLAMP);
@ -1049,13 +1050,14 @@ void state_fogstartend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct w
TRACE("Fog End == %f\n", fogend); TRACE("Fog End == %f\n", fogend);
} }
void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) void state_fog_fragpart(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
const struct wined3d_state *state = &stateblock->state;
enum fogsource new_source; enum fogsource new_source;
TRACE("state %#x, stateblock %p, context %p\n", state, stateblock, context); TRACE("state_id %#x, stateblock %p, context %p\n", state_id, stateblock, context);
if (!stateblock->state.render_states[WINED3DRS_FOGENABLE]) if (!state->render_states[WINED3DRS_FOGENABLE])
{ {
/* No fog? Disable it, and we're done :-) */ /* No fog? Disable it, and we're done :-) */
glDisableWINE(GL_FOG); glDisableWINE(GL_FOG);
@ -1109,14 +1111,17 @@ void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
/* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes, /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
* the system will apply only pixel(=table) fog effects." * the system will apply only pixel(=table) fog effects."
*/ */
if (stateblock->state.render_states[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) if (state->render_states[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
{ {
if(use_vs(stateblock)) { if (use_vs(state))
{
glFogi(GL_FOG_MODE, GL_LINEAR); glFogi(GL_FOG_MODE, GL_LINEAR);
checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)"); checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
new_source = FOGSOURCE_VS; new_source = FOGSOURCE_VS;
} else { }
switch (stateblock->state.render_states[WINED3DRS_FOGVERTEXMODE]) else
{
switch (state->render_states[WINED3DRS_FOGVERTEXMODE])
{ {
/* If processed vertices are used, fall through to the NONE case */ /* If processed vertices are used, fall through to the NONE case */
case WINED3DFOG_EXP: case WINED3DFOG_EXP:
@ -1158,14 +1163,14 @@ void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
default: default:
FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %#x.\n", FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %#x.\n",
stateblock->state.render_states[WINED3DRS_FOGVERTEXMODE]); state->render_states[WINED3DRS_FOGVERTEXMODE]);
new_source = FOGSOURCE_FFP; /* Make the compiler happy */ new_source = FOGSOURCE_FFP; /* Make the compiler happy */
} }
} }
} else { } else {
new_source = FOGSOURCE_FFP; new_source = FOGSOURCE_FFP;
switch (stateblock->state.render_states[WINED3DRS_FOGTABLEMODE]) switch (state->render_states[WINED3DRS_FOGTABLEMODE])
{ {
case WINED3DFOG_EXP: case WINED3DFOG_EXP:
glFogi(GL_FOG_MODE, GL_EXP); glFogi(GL_FOG_MODE, GL_EXP);
@ -1185,7 +1190,7 @@ void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
case WINED3DFOG_NONE: /* Won't happen */ case WINED3DFOG_NONE: /* Won't happen */
default: default:
FIXME("Unexpected WINED3DRS_FOGTABLEMODE %#x.\n", FIXME("Unexpected WINED3DRS_FOGTABLEMODE %#x.\n",
stateblock->state.render_states[WINED3DRS_FOGTABLEMODE]); state->render_states[WINED3DRS_FOGTABLEMODE]);
} }
} }
@ -3257,16 +3262,17 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d
} }
} }
static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void transform_texture(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
DWORD texUnit = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD texUnit = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
DWORD mapped_stage = stateblock->device->texUnitMap[texUnit]; DWORD mapped_stage = stateblock->device->texUnitMap[texUnit];
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
BOOL generated; BOOL generated;
int coordIdx; int coordIdx;
/* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */ /* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */
if (use_vs(stateblock) || isStateDirty(context, STATE_VDECL)) if (use_vs(state) || isStateDirty(context, STATE_VDECL))
{ {
TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n"); TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n");
return; return;
@ -3277,12 +3283,11 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, s
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage)); GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB"); checkGLcall("glActiveTextureARB");
generated = (stateblock->state.texture_states[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xffff0000) generated = (state->texture_states[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xffff0000) != WINED3DTSS_TCI_PASSTHRU;
!= WINED3DTSS_TCI_PASSTHRU; coordIdx = min(state->texture_states[texUnit][WINED3DTSS_TEXCOORDINDEX & 0x0000ffff], MAX_TEXTURES - 1);
coordIdx = min(stateblock->state.texture_states[texUnit][WINED3DTSS_TEXCOORDINDEX & 0x0000ffff], MAX_TEXTURES - 1);
set_texture_matrix(&stateblock->state.transforms[WINED3DTS_TEXTURE0 + texUnit].u.m[0][0], set_texture_matrix(&state->transforms[WINED3DTS_TEXTURE0 + texUnit].u.m[0][0],
stateblock->state.texture_states[texUnit][WINED3DTSS_TEXTURETRANSFORMFLAGS], state->texture_states[texUnit][WINED3DTSS_TEXTURETRANSFORMFLAGS],
generated, context->last_was_rhw, generated, context->last_was_rhw,
stateblock->device->strided_streams.use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx)) stateblock->device->strided_streams.use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx))
? stateblock->device->strided_streams.elements[WINED3D_FFP_TEXCOORD0 + coordIdx].format->id ? stateblock->device->strided_streams.elements[WINED3D_FFP_TEXCOORD0 + coordIdx].format->id
@ -3290,7 +3295,7 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, s
stateblock->device->frag_pipe->ffp_proj_control); stateblock->device->frag_pipe->ffp_proj_control);
/* The sampler applying function calls us if this changes */ /* The sampler applying function calls us if this changes */
if ((context->lastWasPow2Texture & (1 << texUnit)) && stateblock->state.textures[texUnit]) if ((context->lastWasPow2Texture & (1 << texUnit)) && state->textures[texUnit])
{ {
if(generated) { if(generated) {
FIXME("Non-power2 texture being used with generated texture coords\n"); FIXME("Non-power2 texture being used with generated texture coords\n");
@ -3299,7 +3304,7 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, s
fixed-function-pipeline fixup via pow2Matrix when no PS is used. */ fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
if (!use_ps(stateblock)) { if (!use_ps(stateblock)) {
TRACE("Non power two matrix multiply fixup\n"); TRACE("Non power two matrix multiply fixup\n");
glMultMatrixf(stateblock->state.textures[texUnit]->baseTexture.pow2Matrix); glMultMatrixf(state->textures[texUnit]->baseTexture.pow2Matrix);
} }
} }
} }
@ -3554,7 +3559,7 @@ static void shaderconstant(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
return; return;
} }
device->shader_backend->shader_load_constants(context, use_ps(stateblock), use_vs(stateblock)); device->shader_backend->shader_load_constants(context, use_ps(stateblock), use_vs(&stateblock->state));
} }
static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
@ -3602,11 +3607,12 @@ static void sampler_texmatrix(DWORD state, IWineD3DStateBlockImpl *stateblock, s
} }
} }
static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
DWORD sampler = state - STATE_SAMPLER(0); DWORD sampler = state_id - STATE_SAMPLER(0);
DWORD mapped_stage = stateblock->device->texUnitMap[sampler]; DWORD mapped_stage = stateblock->device->texUnitMap[sampler];
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
union { union {
float f; float f;
DWORD d; DWORD d;
@ -3630,28 +3636,28 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage)); GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB"); checkGLcall("glActiveTextureARB");
if (stateblock->state.textures[sampler]) if (state->textures[sampler])
{ {
IWineD3DBaseTexture *texture = (IWineD3DBaseTexture *)stateblock->state.textures[sampler]; IWineD3DBaseTexture *texture = (IWineD3DBaseTexture *)state->textures[sampler];
BOOL srgb = stateblock->state.sampler_states[sampler][WINED3DSAMP_SRGBTEXTURE]; BOOL srgb = state->sampler_states[sampler][WINED3DSAMP_SRGBTEXTURE];
IWineD3DBaseTexture_BindTexture(texture, srgb); IWineD3DBaseTexture_BindTexture(texture, srgb);
basetexture_apply_state_changes(texture, basetexture_apply_state_changes(texture,
stateblock->state.texture_states[sampler], state->texture_states[sampler],
stateblock->state.sampler_states[sampler], gl_info); state->sampler_states[sampler], gl_info);
if (gl_info->supported[EXT_TEXTURE_LOD_BIAS]) if (gl_info->supported[EXT_TEXTURE_LOD_BIAS])
{ {
tmpvalue.d = stateblock->state.sampler_states[sampler][WINED3DSAMP_MIPMAPLODBIAS]; tmpvalue.d = state->sampler_states[sampler][WINED3DSAMP_MIPMAPLODBIAS];
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
GL_TEXTURE_LOD_BIAS_EXT, GL_TEXTURE_LOD_BIAS_EXT,
tmpvalue.f); tmpvalue.f);
checkGLcall("glTexEnvi(GL_TEXTURE_LOD_BIAS_EXT, ...)"); checkGLcall("glTexEnvi(GL_TEXTURE_LOD_BIAS_EXT, ...)");
} }
if (!use_ps(stateblock) && sampler < stateblock->state.lowest_disabled_stage) if (!use_ps(stateblock) && sampler < state->lowest_disabled_stage)
{ {
if (stateblock->state.render_states[WINED3DRS_COLORKEYENABLE] && !sampler) if (state->render_states[WINED3DRS_COLORKEYENABLE] && !sampler)
{ {
/* If color keying is enabled update the alpha test, it depends on the existence /* If color keying is enabled update the alpha test, it depends on the existence
* of a color key in stage 0 * of a color key in stage 0
@ -3661,19 +3667,19 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine
} }
/* Trigger shader constant reloading (for NP2 texcoord fixup) */ /* Trigger shader constant reloading (for NP2 texcoord fixup) */
if (!stateblock->state.textures[sampler]->baseTexture.pow2Matrix_identity) if (!state->textures[sampler]->baseTexture.pow2Matrix_identity)
{ {
IWineD3DDeviceImpl *d3ddevice = stateblock->device; IWineD3DDeviceImpl *d3ddevice = stateblock->device;
d3ddevice->shader_backend->shader_load_np2fixup_constants( d3ddevice->shader_backend->shader_load_np2fixup_constants(
(IWineD3DDevice*)d3ddevice, use_ps(stateblock), use_vs(stateblock)); (IWineD3DDevice*)d3ddevice, use_ps(stateblock), use_vs(state));
} }
} }
else if (mapped_stage < gl_info->limits.textures) else if (mapped_stage < gl_info->limits.textures)
{ {
if (sampler < stateblock->state.lowest_disabled_stage) if (sampler < state->lowest_disabled_stage)
{ {
/* TODO: What should I do with pixel shaders here ??? */ /* TODO: What should I do with pixel shaders here ??? */
if (stateblock->state.render_states[WINED3DRS_COLORKEYENABLE] && !sampler) if (state->render_states[WINED3DRS_COLORKEYENABLE] && !sampler)
{ {
/* If color keying is enabled update the alpha test, it depends on the existence /* If color keying is enabled update the alpha test, it depends on the existence
* of a color key in stage 0 * of a color key in stage 0
@ -3689,8 +3695,8 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine
void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
IWineD3DDeviceImpl *device = stateblock->device; IWineD3DDeviceImpl *device = stateblock->device;
BOOL use_vshader = use_vs(&stateblock->state);
BOOL use_pshader = use_ps(stateblock); BOOL use_pshader = use_ps(stateblock);
BOOL use_vshader = use_vs(stateblock);
unsigned int i; unsigned int i;
if (use_pshader) { if (use_pshader) {
@ -3779,9 +3785,10 @@ static void transform_world(DWORD state, IWineD3DStateBlockImpl *stateblock, str
} }
} }
static void clipplane(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void clipplane(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
UINT index = state - STATE_CLIPPLANE(0); const struct wined3d_state *state = &stateblock->state;
UINT index = state_id - STATE_CLIPPLANE(0);
if (isStateDirty(context, STATE_TRANSFORM(WINED3DTS_VIEW)) || index >= context->gl_info->limits.clipplanes) if (isStateDirty(context, STATE_TRANSFORM(WINED3DTS_VIEW)) || index >= context->gl_info->limits.clipplanes)
{ {
@ -3789,10 +3796,11 @@ static void clipplane(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi
} }
/* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */ /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
if(!use_vs(stateblock)) { if (!use_vs(state))
{
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
glLoadMatrixf(&stateblock->state.transforms[WINED3DTS_VIEW].u.m[0][0]); glLoadMatrixf(&state->transforms[WINED3DTS_VIEW].u.m[0][0]);
} }
else else
{ {
@ -3806,12 +3814,12 @@ static void clipplane(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi
if (context->render_offscreen) glScalef(1.0f, -1.0f, 1.0f); if (context->render_offscreen) glScalef(1.0f, -1.0f, 1.0f);
} }
TRACE("Clipplane [%f,%f,%f,%f]\n", TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n",
stateblock->state.clip_planes[index][0], state->clip_planes[index][0],
stateblock->state.clip_planes[index][1], state->clip_planes[index][1],
stateblock->state.clip_planes[index][2], state->clip_planes[index][2],
stateblock->state.clip_planes[index][3]); state->clip_planes[index][3]);
glClipPlane(GL_CLIP_PLANE0 + index, stateblock->state.clip_planes[index]); glClipPlane(GL_CLIP_PLANE0 + index, state->clip_planes[index]);
checkGLcall("glClipPlane"); checkGLcall("glClipPlane");
glPopMatrix(); glPopMatrix();
@ -4573,8 +4581,8 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
IWineD3DDeviceImpl *device = stateblock->device; IWineD3DDeviceImpl *device = stateblock->device;
BOOL load_numbered = use_vs(stateblock) && !device->useDrawStridedSlow; BOOL load_numbered = use_vs(&stateblock->state) && !device->useDrawStridedSlow;
BOOL load_named = !use_vs(stateblock) && !device->useDrawStridedSlow; BOOL load_named = !use_vs(&stateblock->state) && !device->useDrawStridedSlow;
if (context->numberedArraysLoaded && !load_numbered) if (context->numberedArraysLoaded && !load_numbered)
{ {
@ -4606,7 +4614,7 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, s
{ {
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
BOOL updateFog = FALSE; BOOL updateFog = FALSE;
BOOL useVertexShaderFunction = use_vs(stateblock); BOOL useVertexShaderFunction = use_vs(&stateblock->state);
BOOL usePixelShaderFunction = use_ps(stateblock); BOOL usePixelShaderFunction = use_ps(stateblock);
IWineD3DDeviceImpl *device = stateblock->device; IWineD3DDeviceImpl *device = stateblock->device;
BOOL transformed; BOOL transformed;

View File

@ -2901,7 +2901,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
} }
else if (stateblock->state.render_states[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) else if (stateblock->state.render_states[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
{ {
if (use_vs(stateblock) || stateblock->state.vertex_declaration->position_transformed) if (use_vs(&stateblock->state) || stateblock->state.vertex_declaration->position_transformed)
{ {
settings->fog = FOG_LINEAR; settings->fog = FOG_LINEAR;
} }
@ -2944,7 +2944,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
} else { } else {
settings->sRGB_write = 0; settings->sRGB_write = 0;
} }
if (device->vs_clipping || !use_vs(stateblock) || !stateblock->state.render_states[WINED3DRS_CLIPPING] if (device->vs_clipping || !use_vs(&stateblock->state) || !stateblock->state.render_states[WINED3DRS_CLIPPING]
|| !stateblock->state.render_states[WINED3DRS_CLIPPLANEENABLE]) || !stateblock->state.render_states[WINED3DRS_CLIPPLANEENABLE])
{ {
/* No need to emulate clipplanes if GL supports native vertex shader clipping or if /* No need to emulate clipplanes if GL supports native vertex shader clipping or if

View File

@ -3017,14 +3017,13 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format,
DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
const WINED3DCOLORVALUE *color) DECLSPEC_HIDDEN; const WINED3DCOLORVALUE *color) DECLSPEC_HIDDEN;
static inline BOOL use_vs(IWineD3DStateBlockImpl *stateblock) static inline BOOL use_vs(const struct wined3d_state *state)
{ {
/* Check stateblock->vertexDecl to allow this to be used from /* Check stateblock->vertexDecl to allow this to be used from
* IWineD3DDeviceImpl_FindTexUnitMap(). This is safe because * IWineD3DDeviceImpl_FindTexUnitMap(). This is safe because
* stateblock->vertexShader implies a vertex declaration instead of ddraw * stateblock->vertexShader implies a vertex declaration instead of ddraw
* style strided data. */ * style strided data. */
return stateblock->state.vertex_shader return state->vertex_shader && !state->vertex_declaration->position_transformed;
&& !stateblock->state.vertex_declaration->position_transformed;
} }
static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock) static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock)