From 7b8665762563b57f8f54ca64eebe14f21d4eb4f3 Mon Sep 17 00:00:00 2001 From: Tobias Jakobi Date: Thu, 9 Apr 2009 01:43:02 +0200 Subject: [wined3d] GLSL: enable load_np2fixup_constants --- dlls/wined3d/arb_program_shader.c | 6 ++++ dlls/wined3d/glsl_shader.c | 52 +++++++++++++++++++++++------------- dlls/wined3d/state.c | 7 ++--- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index a64ce90..3801005 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -669,6 +669,12 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD } else { tex_type = "2D"; } + if(shader_is_pshader_version(ins->reg_maps->shader_version)) { + const IWineD3DPixelShaderImpl* const ps = (const IWineD3DPixelShaderImpl*)This; + if(ps->cur_args->texrect_fixup & (1 << sampler_idx)) { + FIXME("NP2 texcoord fixup is currently not implemented in ARB mode (use GLSL instead)."); + } + } break; case WINED3DSTT_VOLUME: diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 46a6883..bcdc85f 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -489,7 +489,39 @@ static void shader_glsl_load_np2fixup_constants( IWineD3DDevice* device, char usePixelShader, char useVertexShader) { - /* not implemented */ + + 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. */ + return; + } + + if (!usePixelShader) { + /* NP2 texcoord fixup is (currently) only done for pixelshaders. */ + return; + } + + if (prog->ps_args.texrect_fixup) { + UINT i; + UINT fixup = prog->ps_args.texrect_fixup; + const WineD3D_GL_Info* gl_info = &deviceImpl->adapter->gl_info; + const IWineD3DStateBlockImpl* stateBlock = (const IWineD3DStateBlockImpl*) deviceImpl->stateBlock; + + for (i = 0; fixup; fixup >>= 1, ++i) { + if (-1 != prog->rectFixup_location[i]) { + const IWineD3DBaseTextureImpl* const tex = (const IWineD3DBaseTextureImpl*) stateBlock->textures[i]; + if (!tex) { + FIXME("Non-existant texture is flagged for NP2 texcoord fixup\n"); + continue; + } else { + const float tex_dim[2] = {tex->baseTexture.pow2Matrix[0], tex->baseTexture.pow2Matrix[5]}; + GL_EXTCALL(glUniform2fvARB(prog->rectFixup_location[i], 1, tex_dim)); + } + } + } + } } /** @@ -598,24 +630,6 @@ static void shader_glsl_load_constants( } GL_EXTCALL(glUniform4fvARB(prog->ycorrection_location, 1, correction_params)); } - - /* Constant loading for texture rect coord fixup. */ - if (prog->ps_args.texrect_fixup) { - UINT fixup = prog->ps_args.texrect_fixup; - - for (i = 0; fixup; fixup >>= 1, ++i) { - if (-1 != prog->rectFixup_location[i]) { - const IWineD3DBaseTextureImpl* const tex = (const IWineD3DBaseTextureImpl*) stateBlock->textures[i]; - if (!tex) { - FIXME("Non-existant texture is flagged for NP2 texcoord fixup\n"); - continue; - } else { - const float tex_dim[2] = {tex->baseTexture.pow2Matrix[0], tex->baseTexture.pow2Matrix[5]}; - GL_EXTCALL(glUniform2fvARB(prog->rectFixup_location[i], 1, tex_dim)); - } - } - } - } } if (priv->next_constant_version == UINT_MAX) diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 47a94a0..d4602ec 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3367,11 +3367,10 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont /* Trigger shader constant reloading (for NP2 texcoord fixup) * Only do this if pshaders are used (note: fixup is currently only implemented in GLSL). */ - if (!tex_impl->baseTexture.pow2Matrix_identity && use_ps(stateblock)) { + if (!tex_impl->baseTexture.pow2Matrix_identity) { IWineD3DDeviceImpl* d3ddevice = stateblock->wineD3DDevice; - /* FIXME: add something like shader_load_rectfixup_consts to the backend to only reload the - * constants that are used for the fixup (and not the other ones too) */ - d3ddevice->shader_backend->shader_load_constants((IWineD3DDevice*)d3ddevice, use_ps(stateblock), use_vs(stateblock)); + d3ddevice->shader_backend->shader_load_np2fixup_constants( + (IWineD3DDevice*)d3ddevice, use_ps(stateblock)), use_vs(stateblock)); } } else if(mapped_stage < GL_LIMITS(textures)) { if(sampler < stateblock->lowest_disabled_stage) { -- 1.6.0.6