Stefan Dösinger : wined3d: Store the compile args in the compile context, not the shader.
Alexandre Julliard
julliard at winehq.org
Thu May 28 09:39:42 CDT 2009
Module: wine
Branch: master
Commit: 5865d9c01b2aed1ed7a2f5987f587de952cb2ad9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5865d9c01b2aed1ed7a2f5987f587de952cb2ad9
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Tue May 26 13:27:54 2009 +0200
wined3d: Store the compile args in the compile context, not the shader.
---
dlls/wined3d/arb_program_shader.c | 21 +++++++++++++--------
dlls/wined3d/glsl_shader.c | 26 ++++++++++++++++++++------
dlls/wined3d/pixelshader.c | 2 --
dlls/wined3d/vertexshader.c | 2 --
dlls/wined3d/wined3d_private.h | 4 ----
5 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 4ace13b..db19fe5 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -93,6 +93,9 @@ struct shader_arb_ctx_priv {
/* GL_NV_vertex_program3 or GL_NV_fragment_program2 */
NV3
} target_version;
+
+ const struct vs_compile_args *cur_vs_args;
+ const struct ps_compile_args *cur_ps_args;
};
/********************************************************
@@ -543,7 +546,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
}
else
{
- if (((IWineD3DVertexShaderImpl *)This)->cur_args->swizzle_map & (1 << reg->idx)) *is_color = TRUE;
+ if (ctx->cur_vs_args->swizzle_map & (1 << reg->idx)) *is_color = TRUE;
sprintf(register_name, "vertex.attrib[%u]", reg->idx);
}
break;
@@ -606,7 +609,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
case WINED3DSPR_COLOROUT:
if (reg->idx == 0)
{
- if(((IWineD3DPixelShaderImpl *)This)->cur_args->srgb_correction)
+ if(ctx->cur_ps_args->srgb_correction)
{
strcpy(register_name, "TMP_COLOR");
}
@@ -739,6 +742,7 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
const char *tex_type;
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
+ struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
switch(sampler_type) {
case WINED3DSTT_1D:
@@ -754,10 +758,10 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
}
if (shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type))
{
- const IWineD3DPixelShaderImpl* const ps = (const IWineD3DPixelShaderImpl*)This;
- if(ps->cur_args->np2_fixup & (1 << sampler_idx)) {
- FIXME("NP2 texcoord fixup is currently not implemented in ARB mode (use GLSL instead).\n");
- }
+ if(priv->cur_ps_args->np2_fixup & (1 << sampler_idx))
+ {
+ FIXME("NP2 texcoord fixup is currently not implemented in ARB mode (use GLSL instead).\n");
+ }
}
break;
@@ -787,9 +791,8 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
if (shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type))
{
- IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
gen_color_correction(buffer, dst_str, ins->dst[0].write_mask,
- "one", "coefmul.x", ps->cur_args->color_fixup[sampler_idx]);
+ "one", "coefmul.x", priv->cur_ps_args->color_fixup[sampler_idx]);
}
}
@@ -2128,6 +2131,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShader *iface,
/* Create the hw ARB shader */
memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.cur_ps_args = args;
shader_addline(buffer, "!!ARBfp1.0\n");
if(GL_SUPPORT(NV_FRAGMENT_PROGRAM_OPTION)) {
shader_addline(buffer, "OPTION NV_fragment_program;\n");
@@ -2240,6 +2244,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShader *iface,
struct shader_arb_ctx_priv priv_ctx;
memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.cur_vs_args = args;
/* Create the hw ARB shader */
shader_addline(buffer, "!!ARBvp1.0\n");
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index f576e67..8eaffe8 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -122,6 +122,11 @@ typedef struct {
struct vs_compile_args vs_args;
} glsl_program_key_t;
+struct shader_glsl_ctx_priv {
+ const struct vs_compile_args *cur_vs_args;
+ const struct ps_compile_args *cur_ps_args;
+};
+
/* Extract a line from the info log.
* Note that this modifies the source string. */
static char *get_info_log_line(char **ptr)
@@ -1123,7 +1128,8 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
/* vertex shaders */
if (!pshader)
{
- if (((IWineD3DVertexShaderImpl *)This)->cur_args->swizzle_map & (1 << reg->idx)) *is_color = TRUE;
+ struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
+ if (priv->cur_vs_args->swizzle_map & (1 << reg->idx)) *is_color = TRUE;
sprintf(register_name, "attrib%u", reg->idx);
break;
}
@@ -1657,11 +1663,11 @@ static void PRINTF_ATTR(8, 9) shader_glsl_gen_sample_code(const struct wined3d_s
if (shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type))
{
- IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
- fixup = This->cur_args->color_fixup[sampler];
+ struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
+ fixup = priv->cur_ps_args->color_fixup[sampler];
sampler_base = "Psampler";
- if(This->cur_args->np2_fixup & (1 << sampler)) {
+ if(priv->cur_ps_args->np2_fixup & (1 << sampler)) {
if(bias) {
FIXME("Biased sampling from NP2 textures is unsupported\n");
} else {
@@ -4164,10 +4170,14 @@ static GLuint shader_glsl_generate_pshader(IWineD3DPixelShader *iface,
CONST DWORD *function = This->baseShader.function;
const char *fragcolor;
const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
+ struct shader_glsl_ctx_priv priv_ctx;
/* Create the hw GLSL shader object and assign it as the shader->prgId */
GLhandleARB shader_obj = GL_EXTCALL(glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB));
+ memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.cur_ps_args = args;
+
shader_addline(buffer, "#version 120\n");
if (GL_SUPPORT(ARB_DRAW_BUFFERS)) {
@@ -4193,7 +4203,7 @@ static GLuint shader_glsl_generate_pshader(IWineD3DPixelShader *iface,
}
/* Base Shader Body */
- shader_generate_main((IWineD3DBaseShader *)This, buffer, reg_maps, function, NULL);
+ shader_generate_main((IWineD3DBaseShader *)This, buffer, reg_maps, function, &priv_ctx);
/* Pixel shaders < 2.0 place the resulting color in R0 implicitly */
if (reg_maps->shader_version.major < 2)
@@ -4270,17 +4280,21 @@ static GLuint shader_glsl_generate_vshader(IWineD3DVertexShader *iface,
const struct shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
CONST DWORD *function = This->baseShader.function;
const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
+ struct shader_glsl_ctx_priv priv_ctx;
/* Create the hw GLSL shader program and assign it as the shader->prgId */
GLhandleARB shader_obj = GL_EXTCALL(glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB));
shader_addline(buffer, "#version 120\n");
+ memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.cur_vs_args = args;
+
/* Base Declarations */
shader_generate_glsl_declarations( (IWineD3DBaseShader*) This, reg_maps, buffer, &GLINFO_LOCATION, NULL);
/* Base Shader Body */
- shader_generate_main((IWineD3DBaseShader*)This, buffer, reg_maps, function, NULL);
+ shader_generate_main((IWineD3DBaseShader*)This, buffer, reg_maps, function, &priv_ctx);
/* Unpack 3.0 outputs */
if (reg_maps->shader_version.major >= 3) shader_addline(buffer, "order_ps_input(OUT);\n");
diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c
index 839b9bb..f1966a1 100644
--- a/dlls/wined3d/pixelshader.c
+++ b/dlls/wined3d/pixelshader.c
@@ -358,11 +358,9 @@ static GLuint pixelshader_compile(IWineD3DPixelShaderImpl *This, const struct ps
/* Generate the HW shader */
TRACE("(%p) : Generating hardware program\n", This);
- This->cur_args = args;
shader_buffer_init(&buffer);
retval = device->shader_backend->shader_generate_pshader((IWineD3DPixelShader *)This, &buffer, args);
shader_buffer_free(&buffer);
- This->cur_args = NULL;
return retval;
}
diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c
index 99108a8..9ae52f9 100644
--- a/dlls/wined3d/vertexshader.c
+++ b/dlls/wined3d/vertexshader.c
@@ -341,9 +341,7 @@ static GLuint vertexshader_compile(IWineD3DVertexShaderImpl *This, const struct
/* Generate the HW shader */
TRACE("(%p) : Generating hardware program\n", This);
shader_buffer_init(&buffer);
- This->cur_args = args;
ret = deviceImpl->shader_backend->shader_generate_vshader((IWineD3DVertexShader *)This, &buffer, args);
- This->cur_args = NULL;
shader_buffer_free(&buffer);
return ret;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 1698504..c830d35 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2687,8 +2687,6 @@ typedef struct IWineD3DVertexShaderImpl {
UINT rel_offset;
UINT recompile_count;
-
- const struct vs_compile_args *cur_args;
} IWineD3DVertexShaderImpl;
extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
@@ -2728,8 +2726,6 @@ typedef struct IWineD3DPixelShaderImpl {
unsigned char numbumpenvmatconsts;
struct stb_const_desc luminanceconst[MAX_TEXTURES];
char vpos_uniform;
-
- const struct ps_compile_args *cur_args;
} IWineD3DPixelShaderImpl;
extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
More information about the wine-cvs
mailing list