[PATCH 2/5] wined3d: Explicitly pass the state to shader_load_constants (try 2)
Stefan Dösinger
stefan at codeweavers.com
Tue May 14 10:38:17 CDT 2013
try 2: Change parameter order, get rid of use_vs / use_ps.
This patch drops the stateBlock->changed.*ShaderConstants{B/I} checks from GLSL as
well. The changed.*ShaderConstantF checks remain, they are necessary to correctly
grow the constant heap. The plan for those is to maintain a copy of this
information in the GLSL backend's private data and use the stateblock information
only for stateblock recording.
---
dlls/wined3d/arb_program_shader.c | 10 +++++-----
dlls/wined3d/context.c | 3 ++-
dlls/wined3d/glsl_shader.c | 21 +++++++++------------
dlls/wined3d/shader.c | 3 ++-
dlls/wined3d/wined3d_private.h | 4 +++-
5 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index a7dc253..d7959cf 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -719,13 +719,13 @@ static void shader_arb_load_constants_internal(struct shader_arb_priv *priv,
}
}
-static void shader_arb_load_constants(const struct wined3d_context *context, BOOL ps, BOOL vs)
+static void shader_arb_load_constants(void *shader_priv, const struct wined3d_context *context,
+ const struct wined3d_state *state)
{
- struct wined3d_device *device = context->swapchain->device;
- const struct wined3d_stateblock *stateblock = device->stateBlock;
- const struct wined3d_state *state = &stateblock->state;
+ BOOL vs = use_vs(state);
+ BOOL ps = use_ps(state);
- shader_arb_load_constants_internal(device->shader_priv, context, state, ps, vs, FALSE);
+ shader_arb_load_constants_internal(shader_priv, context, state, ps, vs, FALSE);
}
static void shader_arb_update_float_vertex_constants(struct wined3d_device *device, UINT start, UINT count)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 6d30f1c..3cfdb04 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2411,7 +2411,8 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de
if (context->load_constants)
{
- device->shader_backend->shader_load_constants(context, use_ps(state), use_vs(state));
+ device->shader_backend->shader_load_constants(device->shader_priv,
+ context, state);
context->load_constants = 0;
}
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 16054ed..674f263 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -725,14 +725,11 @@ static void shader_glsl_load_np2fixup_constants(void *shader_priv,
}
/* Context activation is done by the caller (state handler). */
-static void shader_glsl_load_constants(const struct wined3d_context *context,
- BOOL usePixelShader, BOOL useVertexShader)
+static void shader_glsl_load_constants(void *shader_priv, const struct wined3d_context *context,
+ const struct wined3d_state *state)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
- struct wined3d_device *device = context->swapchain->device;
- struct wined3d_stateblock *stateBlock = device->stateBlock;
- const struct wined3d_state *state = &stateBlock->state;
- struct shader_glsl_priv *priv = device->shader_priv;
+ struct shader_glsl_priv *priv = shader_priv;
float position_fixup[4];
GLhandleARB programId;
@@ -747,7 +744,7 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
programId = prog->programId;
constant_version = prog->constant_version;
- if (useVertexShader)
+ if (use_vs(state))
{
const struct wined3d_shader *vshader = state->vertex_shader;
@@ -757,11 +754,11 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
/* Load DirectX 9 integer constants/uniforms for vertex shader */
shader_glsl_load_constantsI(vshader, gl_info, prog->vs.uniform_i_locations, state->vs_consts_i,
- stateBlock->changed.vertexShaderConstantsI & vshader->reg_maps.integer_constants);
+ vshader->reg_maps.integer_constants);
/* Load DirectX 9 boolean constants/uniforms for vertex shader */
shader_glsl_load_constantsB(vshader, gl_info, programId, state->vs_consts_b,
- stateBlock->changed.vertexShaderConstantsB & vshader->reg_maps.boolean_constants);
+ vshader->reg_maps.boolean_constants);
/* Upload the position fixup params */
shader_get_position_fixup(context, state, position_fixup);
@@ -769,7 +766,7 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
checkGLcall("glUniform4fvARB");
}
- if (usePixelShader)
+ if (use_ps(state))
{
const struct wined3d_shader *pshader = state->pixel_shader;
@@ -779,11 +776,11 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
/* Load DirectX 9 integer constants/uniforms for pixel shader */
shader_glsl_load_constantsI(pshader, gl_info, prog->ps.uniform_i_locations, state->ps_consts_i,
- stateBlock->changed.pixelShaderConstantsI & pshader->reg_maps.integer_constants);
+ pshader->reg_maps.integer_constants);
/* Load DirectX 9 boolean constants/uniforms for pixel shader */
shader_glsl_load_constantsB(pshader, gl_info, programId, state->ps_consts_b,
- stateBlock->changed.pixelShaderConstantsB & pshader->reg_maps.boolean_constants);
+ pshader->reg_maps.boolean_constants);
/* Upload the environment bump map matrix if needed. The needsbumpmat
* member specifies the texture stage to load the matrix from. It
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index d9528d2..515caed 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -1509,7 +1509,8 @@ static void shader_none_select_depth_blt(void *shader_priv, const struct wined3d
static void shader_none_deselect_depth_blt(void *shader_priv, const struct wined3d_gl_info *gl_info) {}
static void shader_none_update_float_vertex_constants(struct wined3d_device *device, UINT start, UINT count) {}
static void shader_none_update_float_pixel_constants(struct wined3d_device *device, UINT start, UINT count) {}
-static void shader_none_load_constants(const struct wined3d_context *context, BOOL usePS, BOOL useVS) {}
+static void shader_none_load_constants(void *shader_priv, const struct wined3d_context *context,
+ const struct wined3d_state *state) {}
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(struct wined3d_shader *shader) {}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index abf44c9..9af9e79 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -5,6 +5,7 @@
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2002-2003, 2004 Jason Edmeades
* Copyright 2005 Oliver Stieber
+ * Copyright 2006-2011, 2013 Stefan Dösinger for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -806,7 +807,8 @@ struct wined3d_shader_backend_ops
void (*shader_deselect_depth_blt)(void *shader_priv, const struct wined3d_gl_info *gl_info);
void (*shader_update_float_vertex_constants)(struct wined3d_device *device, UINT start, UINT count);
void (*shader_update_float_pixel_constants)(struct wined3d_device *device, UINT start, UINT count);
- void (*shader_load_constants)(const struct wined3d_context *context, BOOL usePS, BOOL useVS);
+ void (*shader_load_constants)(void *shader_priv, const struct wined3d_context *context,
+ const struct wined3d_state *state);
void (*shader_load_np2fixup_constants)(void *shader_priv, const struct wined3d_gl_info *gl_info,
const struct wined3d_state *state);
void (*shader_destroy)(struct wined3d_shader *shader);
--
1.8.1.5
More information about the wine-patches
mailing list