Commit 5ef7a8c2 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Explicitly pass parameters to shader_load_np2fixup_constants().

parent 6dd91093
...@@ -480,20 +480,13 @@ static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl *This, con ...@@ -480,20 +480,13 @@ static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl *This, con
/** /**
* Loads the texture dimensions for NP2 fixup into the currently set ARB_[vertex/fragment]_programs. * Loads the texture dimensions for NP2 fixup into the currently set ARB_[vertex/fragment]_programs.
*/ */
static void shader_arb_load_np2fixup_constants( static void shader_arb_load_np2fixup_constants(void *shader_priv,
IWineD3DDevice* device, const struct wined3d_gl_info *gl_info, const struct wined3d_state *state)
char usePixelShader, {
char useVertexShader) { const struct shader_arb_priv * priv = shader_priv;
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl *) device; /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
const struct shader_arb_priv* const priv = (const struct shader_arb_priv *) deviceImpl->shader_priv; if (!use_ps(state)) return;
IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info;
if (!usePixelShader) {
/* NP2 texcoord fixup is (currently) only done for pixelshaders. */
return;
}
if (priv->compiled_fprog && priv->compiled_fprog->np2fixup_info.super.active) { if (priv->compiled_fprog && priv->compiled_fprog->np2fixup_info.super.active) {
const struct arb_ps_np2fixup_info* const fixup = &priv->compiled_fprog->np2fixup_info; const struct arb_ps_np2fixup_info* const fixup = &priv->compiled_fprog->np2fixup_info;
...@@ -501,9 +494,10 @@ static void shader_arb_load_np2fixup_constants( ...@@ -501,9 +494,10 @@ static void shader_arb_load_np2fixup_constants(
WORD active = fixup->super.active; WORD active = fixup->super.active;
GLfloat np2fixup_constants[4 * MAX_FRAGMENT_SAMPLERS]; GLfloat np2fixup_constants[4 * MAX_FRAGMENT_SAMPLERS];
for (i = 0; active; active >>= 1, ++i) { for (i = 0; active; active >>= 1, ++i)
{
const IWineD3DBaseTextureImpl *tex = state->textures[i];
const unsigned char idx = fixup->super.idx[i]; const unsigned char idx = fixup->super.idx[i];
const IWineD3DBaseTextureImpl *tex = stateBlock->state.textures[i];
GLfloat *tex_dim = &np2fixup_constants[(idx >> 1) * 4]; GLfloat *tex_dim = &np2fixup_constants[(idx >> 1) * 4];
if (!(active & 1)) continue; if (!(active & 1)) continue;
...@@ -4574,7 +4568,7 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS, ...@@ -4574,7 +4568,7 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS,
/* Force constant reloading for the NP2 fixup (see comment in shader_glsl_select for more info) */ /* Force constant reloading for the NP2 fixup (see comment in shader_glsl_select for more info) */
if (compiled->np2fixup_info.super.active) if (compiled->np2fixup_info.super.active)
shader_arb_load_np2fixup_constants((IWineD3DDevice *)This, usePS, useVS); shader_arb_load_np2fixup_constants(priv, gl_info, state);
} }
else if (gl_info->supported[ARB_FRAGMENT_PROGRAM] && !priv->use_arbfp_fixed_func) else if (gl_info->supported[ARB_FRAGMENT_PROGRAM] && !priv->use_arbfp_fixed_func)
{ {
......
...@@ -681,34 +681,28 @@ static void reset_program_constant_version(struct wine_rb_entry *entry, void *co ...@@ -681,34 +681,28 @@ static void reset_program_constant_version(struct wine_rb_entry *entry, void *co
* Loads the texture dimensions for NP2 fixup into the currently set GLSL program. * Loads the texture dimensions for NP2 fixup into the currently set GLSL program.
*/ */
/* GL locking is done by the caller (state handler) */ /* GL locking is done by the caller (state handler) */
static void shader_glsl_load_np2fixup_constants( static void shader_glsl_load_np2fixup_constants(void *shader_priv,
IWineD3DDevice* device, const struct wined3d_gl_info *gl_info, const struct wined3d_state *state)
char usePixelShader, {
char useVertexShader) { struct shader_glsl_priv *glsl_priv = shader_priv;
const struct glsl_shader_prog_link *prog = glsl_priv->glsl_program;
const IWineD3DDeviceImpl* deviceImpl = (const IWineD3DDeviceImpl*) device;
const struct glsl_shader_prog_link* prog = ((struct shader_glsl_priv *)(deviceImpl->shader_priv))->glsl_program;
if (!prog) { /* No GLSL program set - nothing to do. */
/* No GLSL program set - nothing to do. */ if (!prog) return;
return;
}
if (!usePixelShader) { /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
/* NP2 texcoord fixup is (currently) only done for pixelshaders. */ if (!use_ps(state)) return;
return;
}
if (prog->ps_args.np2_fixup && -1 != prog->np2Fixup_location) { if (prog->ps_args.np2_fixup && prog->np2Fixup_location != -1)
const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info; {
const IWineD3DStateBlockImpl* stateBlock = (const IWineD3DStateBlockImpl*) deviceImpl->stateBlock;
UINT i; UINT i;
UINT fixup = prog->ps_args.np2_fixup; UINT fixup = prog->ps_args.np2_fixup;
GLfloat np2fixup_constants[4 * MAX_FRAGMENT_SAMPLERS]; GLfloat np2fixup_constants[4 * MAX_FRAGMENT_SAMPLERS];
for (i = 0; fixup; fixup >>= 1, ++i) { for (i = 0; fixup; fixup >>= 1, ++i)
{
const IWineD3DBaseTextureImpl *tex = state->textures[i];
const unsigned char idx = prog->np2Fixup_info->idx[i]; const unsigned char idx = prog->np2Fixup_info->idx[i];
const IWineD3DBaseTextureImpl *tex = stateBlock->state.textures[i];
GLfloat *tex_dim = &np2fixup_constants[(idx >> 1) * 4]; GLfloat *tex_dim = &np2fixup_constants[(idx >> 1) * 4];
if (!tex) if (!tex)
...@@ -4619,7 +4613,7 @@ static void shader_glsl_select(const struct wined3d_context *context, BOOL usePS ...@@ -4619,7 +4613,7 @@ static void shader_glsl_select(const struct wined3d_context *context, BOOL usePS
* called between selecting the shader and using it, which results in wrong fixup for some frames. */ * called between selecting the shader and using it, which results in wrong fixup for some frames. */
if (priv->glsl_program && priv->glsl_program->np2Fixup_info) if (priv->glsl_program && priv->glsl_program->np2Fixup_info)
{ {
shader_glsl_load_np2fixup_constants((IWineD3DDevice *)device, usePS, useVS); shader_glsl_load_np2fixup_constants(priv, gl_info, &device->stateBlock->state);
} }
} }
......
...@@ -1508,7 +1508,8 @@ static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {} ...@@ -1508,7 +1508,8 @@ static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {} static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {} static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {} static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {}
static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {} static void shader_none_load_np2fixup_constants(void *shader_priv,
const struct wined3d_gl_info *gl_info, const struct wined3d_state *state) {}
static void shader_none_destroy(IWineD3DBaseShader *iface) {} static void shader_none_destroy(IWineD3DBaseShader *iface) {}
static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;} static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
static void shader_none_free(IWineD3DDevice *iface) {} static void shader_none_free(IWineD3DDevice *iface) {}
......
...@@ -3614,7 +3614,8 @@ static void sampler_texmatrix(DWORD state, IWineD3DStateBlockImpl *stateblock, s ...@@ -3614,7 +3614,8 @@ static void sampler_texmatrix(DWORD state, IWineD3DStateBlockImpl *stateblock, s
static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
DWORD sampler = state_id - STATE_SAMPLER(0); DWORD sampler = state_id - STATE_SAMPLER(0);
DWORD mapped_stage = stateblock->device->texUnitMap[sampler]; IWineD3DDeviceImpl *device = stateblock->device;
DWORD mapped_stage = 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; const struct wined3d_state *state = &stateblock->state;
union { union {
...@@ -3673,9 +3674,7 @@ static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct w ...@@ -3673,9 +3674,7 @@ static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct w
/* Trigger shader constant reloading (for NP2 texcoord fixup) */ /* Trigger shader constant reloading (for NP2 texcoord fixup) */
if (!state->textures[sampler]->baseTexture.pow2Matrix_identity) if (!state->textures[sampler]->baseTexture.pow2Matrix_identity)
{ {
IWineD3DDeviceImpl *d3ddevice = stateblock->device; device->shader_backend->shader_load_np2fixup_constants(device->shader_priv, gl_info, state);
d3ddevice->shader_backend->shader_load_np2fixup_constants(
(IWineD3DDevice*)d3ddevice, use_ps(state), use_vs(state));
} }
} }
else if (mapped_stage < gl_info->limits.textures) else if (mapped_stage < gl_info->limits.textures)
...@@ -3691,8 +3690,8 @@ static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct w ...@@ -3691,8 +3690,8 @@ static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct w
state_alpha(WINED3DRS_COLORKEYENABLE, stateblock, context); state_alpha(WINED3DRS_COLORKEYENABLE, stateblock, context);
} }
} /* Otherwise tex_colorop disables the stage */ } /* Otherwise tex_colorop disables the stage */
glBindTexture(GL_TEXTURE_2D, stateblock->device->dummyTextureName[sampler]); glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[sampler]);
checkGLcall("glBindTexture(GL_TEXTURE_2D, stateblock->device->dummyTextureName[sampler])"); checkGLcall("glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[sampler])");
} }
} }
......
...@@ -723,6 +723,7 @@ struct vs_compile_args { ...@@ -723,6 +723,7 @@ struct vs_compile_args {
}; };
struct wined3d_context; struct wined3d_context;
struct wined3d_state;
typedef struct { typedef struct {
void (*shader_handle_instruction)(const struct wined3d_shader_instruction *); void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
...@@ -732,7 +733,8 @@ typedef struct { ...@@ -732,7 +733,8 @@ typedef struct {
void (*shader_update_float_vertex_constants)(IWineD3DDevice *iface, UINT start, UINT count); void (*shader_update_float_vertex_constants)(IWineD3DDevice *iface, UINT start, UINT count);
void (*shader_update_float_pixel_constants)(IWineD3DDevice *iface, UINT start, UINT count); void (*shader_update_float_pixel_constants)(IWineD3DDevice *iface, UINT start, UINT count);
void (*shader_load_constants)(const struct wined3d_context *context, char usePS, char useVS); void (*shader_load_constants)(const struct wined3d_context *context, char usePS, char useVS);
void (*shader_load_np2fixup_constants)(IWineD3DDevice *iface, char usePS, char useVS); void (*shader_load_np2fixup_constants)(void *shader_priv, const struct wined3d_gl_info *gl_info,
const struct wined3d_state *state);
void (*shader_destroy)(IWineD3DBaseShader *iface); void (*shader_destroy)(IWineD3DBaseShader *iface);
HRESULT (*shader_alloc_private)(IWineD3DDevice *iface); HRESULT (*shader_alloc_private)(IWineD3DDevice *iface);
void (*shader_free_private)(IWineD3DDevice *iface); void (*shader_free_private)(IWineD3DDevice *iface);
......
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