Module: wine
Branch: master
Commit: 05c4d0a8b0a98c5b16a7ccf36d94aabf57abb87f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=05c4d0a8b0a98c5b16a7ccf36…
Author: Tobias Jakobi <liquid.acid(a)gmx.net>
Date: Wed Jul 1 18:36:51 2009 +0200
wined3d: Fix comments about NP2 fixup.
---
dlls/wined3d/state.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 855bb59..8d441b7 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3035,8 +3035,8 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, W
if(generated) {
FIXME("Non-power2 texture being used with generated texture coords\n");
}
- /* NP2 texcoord fixup is implemented for pixelshaders (currently only in GLSL backend) so
- only enable the fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
+ /* NP2 texcoord fixup is implemented for pixelshaders so only enable the
+ fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
if (!use_ps(stateblock)) {
TRACE("Non power two matrix multiply fixup\n");
glMultMatrixf(((IWineD3DTextureImpl *) stateblock->textures[texUnit])->baseTexture.pow2Matrix);
@@ -3379,8 +3379,7 @@ 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). */
+ /* Trigger shader constant reloading (for NP2 texcoord fixup) */
if (!tex_impl->baseTexture.pow2Matrix_identity) {
IWineD3DDeviceImpl* d3ddevice = stateblock->wineD3DDevice;
d3ddevice->shader_backend->shader_load_np2fixup_constants(
Module: wine
Branch: master
Commit: 0caebe5f514e1e34f646197bc2d909cc5e7697eb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0caebe5f514e1e34f646197bc…
Author: Tobias Jakobi <liquid.acid(a)gmx.net>
Date: Wed Jul 1 18:36:50 2009 +0200
wined3d: Force NP2 constant reload in shader_arb_select.
---
dlls/wined3d/arb_program_shader.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 75f05c8..cdc5b10 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -4248,6 +4248,9 @@ static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
{
shader_arb_ps_local_constants(This);
}
+
+ /* Force constant reloading for the NP2 fixup (see comment in shader_glsl_select for more info) */
+ if (compiled->np2fixup_info.super.active) This->shader_backend->shader_load_np2fixup_constants(iface, usePS, useVS);
} else if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && !priv->use_arbfp_fixed_func) {
/* Disable only if we're not using arbfp fixed function fragment processing. If this is used,
* keep GL_FRAGMENT_PROGRAM_ARB enabled, and the fixed function pipeline will bind the fixed function
Module: wine
Branch: master
Commit: 034fa4268c4c717377a1654be3f1d76edcc72fef
URL: http://source.winehq.org/git/wine.git/?a=commit;h=034fa4268c4c717377a1654be…
Author: Tobias Jakobi <liquid.acid(a)gmx.net>
Date: Wed Jul 1 18:36:47 2009 +0200
wined3d: Add NP2 fixup code to shader_arb_generate_pshader.
---
dlls/wined3d/arb_program_shader.c | 38 +++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index b9e5e82..87b74b2 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -3377,6 +3377,44 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This,
compiled->ycorrection = WINED3D_CONST_NUM_UNUSED;
}
+ /* Load constants to fixup NP2 texcoords if there are still free constants left:
+ * Constants (texture dimensions) for the NP2 fixup are loaded as local program parameters. This will consume
+ * at most 8 (MAX_FRAGMENT_SAMPLERS / 2) parameters, which is highly unlikely, since the application had to
+ * use 16 NP2 textures at the same time. In case that we run out of constants the fixup is simply not
+ * applied / activated. This will probably result in wrong rendering of the texture, but will save us from
+ * shader compilation errors and the subsequent errors when drawing with this shader. */
+ if (priv_ctx.cur_ps_args->super.np2_fixup) {
+
+ struct arb_ps_np2fixup_info* const fixup = priv_ctx.cur_np2fixup_info;
+ const WORD map = priv_ctx.cur_ps_args->super.np2_fixup;
+ const UINT max_lconsts = gl_info->ps_arb_max_local_constants;
+
+ fixup->offset = next_local;
+ fixup->super.active = 0;
+
+ cur = 0;
+ for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
+ if (!(map & (1 << i))) continue;
+
+ if (fixup->offset + (cur >> 1) < max_lconsts) {
+ fixup->super.active |= (1 << i);
+ fixup->super.idx[i] = cur++;
+ } else {
+ FIXME("No free constant found to load NP2 fixup data into shader. "
+ "Sampling from this texture will probably look wrong.\n");
+ break;
+ }
+ }
+
+ fixup->super.num_consts = (cur + 1) >> 1;
+ if (fixup->super.num_consts) {
+ shader_addline(buffer, "PARAM np2fixup[%u] = { program.env[%u..%u] };\n",
+ fixup->super.num_consts, fixup->offset, fixup->super.num_consts + fixup->offset - 1);
+ }
+
+ next_local += fixup->super.num_consts;
+ }
+
if(shader_priv->clipplane_emulation)
{
shader_addline(buffer, "KIL fragment.texcoord[%u];\n", shader_priv->clipplane_emulation - 1);