Commit 9224751a authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Pass a wined3d_state structure to use_vs().

parent e59fdb83
......@@ -4396,6 +4396,8 @@ static inline void find_arb_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWi
int i;
WORD int_skip;
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);
/* 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++)
{
if (stateblock->state.ps_consts_b[i])
if (state->ps_consts_b[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
* duplicate the shader than have a no-op KIL instruction in every shader
*/
if ((!((IWineD3DDeviceImpl *)shader->baseShader.device)->vs_clipping) && use_vs(stateblock)
&& stateblock->state.render_states[WINED3DRS_CLIPPING]
&& stateblock->state.render_states[WINED3DRS_CLIPPLANEENABLE])
if ((!((IWineD3DDeviceImpl *)shader->baseShader.device)->vs_clipping) && use_vs(state)
&& state->render_states[WINED3DRS_CLIPPING]
&& state->render_states[WINED3DRS_CLIPPLANEENABLE])
args->clip = 1;
else
args->clip = 0;
......@@ -4436,9 +4438,9 @@ static inline void find_arb_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWi
}
else
{
args->loop_ctrl[i][0] = stateblock->state.ps_consts_i[i * 4];
args->loop_ctrl[i][1] = stateblock->state.ps_consts_i[i * 4 + 1];
args->loop_ctrl[i][2] = stateblock->state.ps_consts_i[i * 4 + 2];
args->loop_ctrl[i][0] = state->ps_consts_i[i * 4];
args->loop_ctrl[i][1] = state->ps_consts_i[i * 4 + 1];
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;
IWineD3DDeviceImpl *device = stateblock->device;
struct shader_arb_priv *priv = device->fragment_priv;
BOOL use_vshader = use_vs(&stateblock->state);
BOOL use_pshader = use_ps(stateblock);
BOOL use_vshader = use_vs(stateblock);
struct ffp_frag_settings settings;
const struct arbfp_ffp_desc *desc;
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
* 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;
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)) {
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;
}
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;
else
new_source = FOGSOURCE_FFP;
......
......@@ -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;
BOOL use_vshader = use_vs(stateblock);
BOOL use_vshader = use_vs(state);
context->last_was_pshader = use_ps(stateblock);
/* The ATIFS code does not support pixel shaders currently, but we have to provide a state handler
......
......@@ -401,6 +401,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
IWineD3DDeviceImpl *device = This->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_stream_info *si = &device->strided_streams;
const struct wined3d_state *state = &device->stateBlock->state;
UINT stride_this_run = 0;
BOOL float16_used = 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
* texcoord needs no conversion while a FLOAT4 positiont needs one
*/
if (use_vs(device->stateBlock))
if (use_vs(state))
{
TRACE("vshader\n");
/* 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
* 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)
{
......
......@@ -466,13 +466,14 @@ static void device_preload_texture(IWineD3DStateBlockImpl *stateblock, unsigned
void device_preload_textures(IWineD3DDeviceImpl *device)
{
IWineD3DStateBlockImpl *stateblock = device->stateBlock;
const struct wined3d_state *state = &stateblock->state;
unsigned int i;
if (use_vs(stateblock))
if (use_vs(state))
{
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);
}
}
......@@ -481,7 +482,7 @@ void device_preload_textures(IWineD3DDeviceImpl *device)
{
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);
}
}
......@@ -3585,7 +3586,7 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps, const struct
void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This)
{
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);
/*
* Rules are:
......
......@@ -576,12 +576,13 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
const struct wined3d_state *state = &This->stateBlock->state;
struct wined3d_context *context;
unsigned int i;
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 */
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
* that we never copy the stencil data.*/
DWORD location = context->render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN;
if (This->stateBlock->state.render_states[WINED3DRS_ZWRITEENABLE]
|| This->stateBlock->state.render_states[WINED3DRS_ZENABLE])
if (state->render_states[WINED3DRS_ZWRITEENABLE] || state->render_states[WINED3DRS_ZENABLE])
{
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))
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,
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]
|| (!glPointParameteri && !context->gl_info->supported[NV_POINT_SPRITE]))
&& context->render_offscreen
&& This->stateBlock->state.render_states[WINED3DRS_POINTSPRITEENABLE]
&& This->stateBlock->state.gl_primitive_type == GL_POINTS)
&& state->render_states[WINED3DRS_POINTSPRITEENABLE]
&& state->gl_primitive_type == GL_POINTS)
{
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 */
ENTER_GL();
{
GLenum glPrimType = This->stateBlock->state.gl_primitive_type;
GLenum glPrimType = state->gl_primitive_type;
BOOL emulation = FALSE;
const struct wined3d_stream_info *stream_info = &This->strided_streams;
struct wined3d_stream_info stridedlcl;
if (!use_vs(This->stateBlock))
if (!use_vs(state))
{
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;
if (!warned) {
......@@ -678,7 +678,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
}
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
* 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 */
if (use_vs(This->stateBlock))
if (use_vs(state))
{
static BOOL warned;
if (!warned) {
......
......@@ -917,6 +917,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
{
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
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 wined3d_gl_info *gl_info = context->gl_info;
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);
break;
case WINED3DSTT_2D:
texture = device->stateBlock->state.textures[i];
texture = state->textures[i];
if (pshader && ps_args->shadow & (1 << i))
{
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 (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));
} else {
......
......@@ -2070,12 +2070,13 @@ static const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args)
{
const struct wined3d_state *state = &stateblock->state;
IWineD3DBaseTextureImpl *texture;
IWineD3DDeviceImpl *device = stateblock->device;
UINT i;
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];
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)
{
if (!shader->baseShader.reg_maps.sampler_type[i]) continue;
texture = stateblock->state.textures[i];
texture = state->textures[i];
if (!texture)
{
args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
......@@ -2109,7 +2110,7 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
{
args->vp_mode = pretransformed;
}
else if (use_vs(stateblock))
else if (use_vs(state))
{
args->vp_mode = vertexshader;
}
......@@ -2122,18 +2123,18 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
else
{
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:
if (device->strided_streams.position_transformed || use_vs(stateblock))
if (device->strided_streams.position_transformed || use_vs(state))
{
args->fog = FOG_LINEAR;
break;
}
switch (stateblock->state.render_states[WINED3DRS_FOGVERTEXMODE])
switch (state->render_states[WINED3DRS_FOGVERTEXMODE])
{
case WINED3DFOG_NONE: /* Fall through. */
case WINED3DFOG_LINEAR: args->fog = FOG_LINEAR; break;
......
......@@ -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)
{
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;
}
......@@ -2944,7 +2944,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
} else {
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])
{
/* No need to emulate clipplanes if GL supports native vertex shader clipping or if
......
......@@ -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,
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
* IWineD3DDeviceImpl_FindTexUnitMap(). This is safe because
* stateblock->vertexShader implies a vertex declaration instead of ddraw
* style strided data. */
return stateblock->state.vertex_shader
&& !stateblock->state.vertex_declaration->position_transformed;
return state->vertex_shader && !state->vertex_declaration->position_transformed;
}
static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment