Commit 298bd3c5 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

 wined3d: Store the bumpmap ARB constants in ARB structures.

parent e83fa982
...@@ -657,20 +657,21 @@ static void shader_glsl_load_constants( ...@@ -657,20 +657,21 @@ static void shader_glsl_load_constants(
/* Upload the environment bump map matrix if needed. The needsbumpmat member specifies the texture stage to load the matrix from. /* Upload the environment bump map matrix if needed. The needsbumpmat member specifies the texture stage to load the matrix from.
* It can't be 0 for a valid texbem instruction. * It can't be 0 for a valid texbem instruction.
*/ */
for(i = 0; i < ((IWineD3DPixelShaderImpl *) pshader)->numbumpenvmatconsts; i++) { for(i = 0; i < MAX_TEXTURES; i++) {
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) pshader; const float *data;
int stage = ps->luminanceconst[i].texunit;
const float *data = (const float *)&stateBlock->textureState[(int)ps->bumpenvmatconst[i].texunit][WINED3DTSS_BUMPENVMAT00]; if(prog->bumpenvmat_location[i] == -1) continue;
data = (const float *)&stateBlock->textureState[i][WINED3DTSS_BUMPENVMAT00];
GL_EXTCALL(glUniformMatrix2fvARB(prog->bumpenvmat_location[i], 1, 0, data)); GL_EXTCALL(glUniformMatrix2fvARB(prog->bumpenvmat_location[i], 1, 0, data));
checkGLcall("glUniformMatrix2fvARB"); checkGLcall("glUniformMatrix2fvARB");
/* texbeml needs the luminance scale and offset too. If texbeml is used, needsbumpmat /* texbeml needs the luminance scale and offset too. If texbeml is used, needsbumpmat
* is set too, so we can check that in the needsbumpmat check * is set too, so we can check that in the needsbumpmat check
*/ */
if(ps->baseShader.reg_maps.luminanceparams[stage]) { if(prog->luminancescale_location[i] != -1) {
const GLfloat *scale = (const GLfloat *)&stateBlock->textureState[stage][WINED3DTSS_BUMPENVLSCALE]; const GLfloat *scale = (const GLfloat *)&stateBlock->textureState[i][WINED3DTSS_BUMPENVLSCALE];
const GLfloat *offset = (const GLfloat *)&stateBlock->textureState[stage][WINED3DTSS_BUMPENVLOFFSET]; const GLfloat *offset = (const GLfloat *)&stateBlock->textureState[i][WINED3DTSS_BUMPENVLOFFSET];
GL_EXTCALL(glUniform1fvARB(prog->luminancescale_location[i], 1, scale)); GL_EXTCALL(glUniform1fvARB(prog->luminancescale_location[i], 1, scale));
checkGLcall("glUniform1fvARB"); checkGLcall("glUniform1fvARB");
...@@ -864,28 +865,20 @@ static void shader_generate_glsl_declarations(IWineD3DBaseShader *iface, const s ...@@ -864,28 +865,20 @@ static void shader_generate_glsl_declarations(IWineD3DBaseShader *iface, const s
shader_addline(buffer, "void order_ps_input();\n"); shader_addline(buffer, "void order_ps_input();\n");
} }
} else { } else {
IWineD3DPixelShaderImpl *ps_impl = (IWineD3DPixelShaderImpl *) This;
ps_impl->numbumpenvmatconsts = 0;
for(i = 0; i < (sizeof(reg_maps->bumpmat) / sizeof(reg_maps->bumpmat[0])); i++) { for(i = 0; i < (sizeof(reg_maps->bumpmat) / sizeof(reg_maps->bumpmat[0])); i++) {
if(!reg_maps->bumpmat[i]) { if(!reg_maps->bumpmat[i]) {
continue; continue;
} }
ps_impl->bumpenvmatconst[(int) ps_impl->numbumpenvmatconsts].texunit = i;
shader_addline(buffer, "uniform mat2 bumpenvmat%d;\n", i); shader_addline(buffer, "uniform mat2 bumpenvmat%d;\n", i);
if(reg_maps->luminanceparams) { if(reg_maps->luminanceparams) {
ps_impl->luminanceconst[(int) ps_impl->numbumpenvmatconsts].texunit = i;
shader_addline(buffer, "uniform float luminancescale%d;\n", i); shader_addline(buffer, "uniform float luminancescale%d;\n", i);
shader_addline(buffer, "uniform float luminanceoffset%d;\n", i); shader_addline(buffer, "uniform float luminanceoffset%d;\n", i);
extra_constants_needed++; extra_constants_needed++;
} else {
ps_impl->luminanceconst[(int) ps_impl->numbumpenvmatconsts].texunit = -1;
} }
extra_constants_needed++; extra_constants_needed++;
ps_impl->numbumpenvmatconsts++;
} }
if(ps_args->srgb_correction) { if(ps_args->srgb_correction) {
...@@ -4062,12 +4055,12 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use ...@@ -4062,12 +4055,12 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
char name[32]; char name[32];
WORD map; WORD map;
for(i = 0; i < ((IWineD3DPixelShaderImpl*)pshader)->numbumpenvmatconsts; i++) { for(i = 0; i < MAX_TEXTURES; i++) {
sprintf(name, "bumpenvmat%d", ((IWineD3DPixelShaderImpl*)pshader)->bumpenvmatconst[i].texunit); sprintf(name, "bumpenvmat%u", i);
entry->bumpenvmat_location[i] = GL_EXTCALL(glGetUniformLocationARB(programId, name)); entry->bumpenvmat_location[i] = GL_EXTCALL(glGetUniformLocationARB(programId, name));
sprintf(name, "luminancescale%d", ((IWineD3DPixelShaderImpl*)pshader)->luminanceconst[i].texunit); sprintf(name, "luminancescale%u", i);
entry->luminancescale_location[i] = GL_EXTCALL(glGetUniformLocationARB(programId, name)); entry->luminancescale_location[i] = GL_EXTCALL(glGetUniformLocationARB(programId, name));
sprintf(name, "luminanceoffset%d", ((IWineD3DPixelShaderImpl*)pshader)->luminanceconst[i].texunit); sprintf(name, "luminanceoffset%u", i);
entry->luminanceoffset_location[i] = GL_EXTCALL(glGetUniformLocationARB(programId, name)); entry->luminanceoffset_location[i] = GL_EXTCALL(glGetUniformLocationARB(programId, name));
} }
......
...@@ -733,11 +733,6 @@ enum vertexprocessing_mode { ...@@ -733,11 +733,6 @@ enum vertexprocessing_mode {
#define WINED3D_CONST_NUM_UNUSED ~0U #define WINED3D_CONST_NUM_UNUSED ~0U
struct stb_const_desc {
unsigned char texunit;
UINT const_num;
};
enum fogmode { enum fogmode {
FOG_OFF, FOG_OFF,
FOG_LINEAR, FOG_LINEAR,
...@@ -2690,9 +2685,6 @@ typedef struct IWineD3DPixelShaderImpl { ...@@ -2690,9 +2685,6 @@ typedef struct IWineD3DPixelShaderImpl {
void *backend_priv; void *backend_priv;
/* Some information about the shader behavior */ /* Some information about the shader behavior */
struct stb_const_desc bumpenvmatconst[MAX_TEXTURES];
unsigned char numbumpenvmatconsts;
struct stb_const_desc luminanceconst[MAX_TEXTURES];
char vpos_uniform; char vpos_uniform;
BOOL color0_mov; BOOL color0_mov;
......
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