Module: wine
Branch: master
Commit: d7f282f241e154c43f1fef2bc61945d0bb634771
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d7f282f241e154c43f1fef2bc…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Thu May 7 19:02:45 2009 +0200
WineD3D: Support more constants in ARB shaders.
GL_LIMIT - 1 for vertex programs and the GL limit in fragment programs. The
indirect addressing limitation in GLSL applies here as well.
---
dlls/wined3d/arb_program_shader.c | 34 +++++++++++++++++++++++-----------
1 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index bfd2d7d..93f84d5 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -59,15 +59,10 @@ static unsigned int reserved_vs_const(const WineD3D_GL_Info *gl_info) {
else return 1;
}
-/* The arb shader only loads the bump mapping environment matrix into the shader if it finds
- * a free constant to do that, so only reduce the number of available constants by 2 for the fog states.
- */
-#define ARB_SHADER_RESERVED_PS_CONSTS 2
-
/* Internally used shader constants. Applications can use constants 0 to GL_LIMITS(vshader_constantsF) - 1,
* so upload them above that
*/
-#define ARB_SHADER_PRIVCONST_BASE (GL_LIMITS(vshader_constantsF) - reserved_vs_const(&GLINFO_LOCATION))
+#define ARB_SHADER_PRIVCONST_BASE (GL_LIMITS(vshader_constantsF) - 1)
#define ARB_SHADER_PRIVCONST_POS ARB_SHADER_PRIVCONST_BASE + 0
/* ARB_program_shader private data */
@@ -316,11 +311,28 @@ static void shader_generate_arb_declarations(IWineD3DBaseShader *iface, const sh
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
DWORD i, cur, next_local = 0;
char pshader = shader_is_pshader_version(reg_maps->shader_version.type);
- unsigned max_constantsF = min(This->baseShader.limits.constant_float,
- (pshader ? GL_LIMITS(pshader_constantsF) - ARB_SHADER_RESERVED_PS_CONSTS :
- GL_LIMITS(vshader_constantsF) - reserved_vs_const(gl_info)));
+ unsigned max_constantsF;
const local_constant *lconst;
+ /* In pixel shaders, all private constants are program local, we don't need anything
+ * from program.env. Thus we can advertise the full set of constants in pixel shaders.
+ * If we need a private constant the GL implementation will squeeze it in somewhere
+ *
+ * With vertex shaders we need the posFixup and on some GL implementations 4 helper
+ * immediate values. The posFixup is loaded using program.env for now, so always
+ * subtract one from the number of constants. If the shader uses indirect addressing,
+ * account for the helper const too because we have to declare all availabke d3d constants
+ * and don't know which are actually used.
+ */
+ if(pshader) {
+ max_constantsF = GL_LIMITS(pshader_constantsF);
+ } else {
+ if(This->baseShader.reg_maps.usesrelconstF) {
+ max_constantsF = GL_LIMITS(vshader_constantsF) - reserved_vs_const(gl_info);
+ } else {
+ max_constantsF = GL_LIMITS(vshader_constantsF) - 1;
+ }
+ }
/* Temporary Output register */
shader_addline(buffer, "TEMP TMP_OUT;\n");
@@ -2092,14 +2104,14 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *g
if(GL_SUPPORT(ARB_VERTEX_PROGRAM)) {
pCaps->VertexShaderVersion = WINED3DVS_VERSION(1,1);
TRACE_(d3d_caps)("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n");
- pCaps->MaxVertexShaderConst = GL_LIMITS(vshader_constantsF) - reserved_vs_const(gl_info);
+ pCaps->MaxVertexShaderConst = GL_LIMITS(vshader_constantsF) - 1;
}
if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) {
pCaps->PixelShaderVersion = WINED3DPS_VERSION(1,4);
pCaps->PixelShader1xMaxValue = 8.0;
TRACE_(d3d_caps)("Hardware pixel shader version 1.4 enabled (ARB_PROGRAM)\n");
- pCaps->MaxPixelShaderConst = GL_LIMITS(pshader_constantsF) - ARB_SHADER_RESERVED_PS_CONSTS;
+ pCaps->MaxPixelShaderConst = GL_LIMITS(pshader_constantsF);
}
pCaps->VSClipping = FALSE; /* TODO: GL_NV_vertex_program2_option provides this */
Module: wine
Branch: master
Commit: 2cb8f42168aa9b00b8dd511a6e5828b45088cbba
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2cb8f42168aa9b00b8dd511a6…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Fri May 8 17:24:01 2009 +0200
wined3d: Support clipplanes with GLSL.
This is the Nth attemt to make clipping work with GLSL shaders. The patch now
uses the GLSL quirk table to handle cards that need a custom varying for
gl_ClipPos, and the code is adapted to the changed state table and shader
backend system.
---
dlls/wined3d/arb_program_shader.c | 2 +
dlls/wined3d/directx.c | 22 ++++++++++++++++++
dlls/wined3d/glsl_shader.c | 34 ++++++++++++++++++++-------
dlls/wined3d/state.c | 45 ++++++++++++++++++++++++------------
dlls/wined3d/wined3d_gl.h | 1 +
dlls/wined3d/wined3d_private.h | 3 ++
6 files changed, 83 insertions(+), 24 deletions(-)
Diff: http://source.winehq.org/git/wine.git/?a=commitdiff;h=2cb8f42168aa9b00b8dd5…
Module: wine
Branch: master
Commit: 45563979bd5f6bb1a91205ba3b10564291cca9e6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=45563979bd5f6bb1a91205ba3…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Fri May 15 13:34:12 2009 +0200
wined3d: Update the bump constants after a shader change.
Since we're using local constants now, we have to update the constants after a
shader change.
---
dlls/wined3d/arb_program_shader.c | 50 +++++++++++++++++++++---------------
1 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 1ff7fd4..4e35983 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -186,6 +186,32 @@ static void shader_arb_load_np2fixup_constants(
/* not implemented */
}
+static inline void shader_arb_ps_local_constants(IWineD3DDeviceImpl* deviceImpl)
+{
+ IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
+ IWineD3DBaseShaderImpl* pshader = (IWineD3DBaseShaderImpl*) stateBlock->pixelShader;
+ IWineD3DPixelShaderImpl *psi = (IWineD3DPixelShaderImpl *) pshader;
+ const WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
+ unsigned char i;
+
+ for(i = 0; i < psi->numbumpenvmatconsts; i++)
+ {
+ /* The state manager takes care that this function is always called if the bump env matrix changes */
+ const float *data = (const float *)&stateBlock->textureState[(int) psi->bumpenvmatconst[i].texunit][WINED3DTSS_BUMPENVMAT00];
+ GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, psi->bumpenvmatconst[i].const_num, data));
+
+ if (psi->luminanceconst[i].const_num != WINED3D_CONST_NUM_UNUSED)
+ {
+ /* WINED3DTSS_BUMPENVLSCALE and WINED3DTSS_BUMPENVLOFFSET are next to each other.
+ * point gl to the scale, and load 4 floats. x = scale, y = offset, z and w are junk, we
+ * don't care about them. The pointers are valid for sure because the stateblock is bigger.
+ * (they're WINED3DTSS_TEXTURETRANSFORMFLAGS and WINED3DTSS_ADDRESSW, so most likely 0 or NaN
+ */
+ const float *scale = (const float *)&stateBlock->textureState[(int) psi->luminanceconst[i].texunit][WINED3DTSS_BUMPENVLSCALE];
+ GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, psi->luminanceconst[i].const_num, scale));
+ }
+ }
+}
/**
* Loads the app-supplied constants into the currently set ARB_[vertex/fragment]_programs.
*
@@ -201,7 +227,6 @@ static void shader_arb_load_constants(
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device;
IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
const WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
- unsigned char i;
if (useVertexShader) {
IWineD3DBaseShaderImpl* vshader = (IWineD3DBaseShaderImpl*) stateBlock->vertexShader;
@@ -218,9 +243,7 @@ static void shader_arb_load_constants(
}
if (usePixelShader) {
-
IWineD3DBaseShaderImpl* pshader = (IWineD3DBaseShaderImpl*) stateBlock->pixelShader;
- IWineD3DPixelShaderImpl *psi = (IWineD3DPixelShaderImpl *) pshader;
/* Load DirectX 9 float constants for pixel shader */
deviceImpl->highest_dirty_ps_const = shader_arb_load_constantsF(
@@ -228,24 +251,7 @@ static void shader_arb_load_constants(
deviceImpl->highest_dirty_ps_const,
stateBlock->pixelShaderConstantF,
deviceImpl->activeContext->pshader_const_dirty);
-
- for(i = 0; i < psi->numbumpenvmatconsts; i++) {
- /* The state manager takes care that this function is always called if the bump env matrix changes
- */
- const float *data = (const float *)&stateBlock->textureState[(int) psi->bumpenvmatconst[i].texunit][WINED3DTSS_BUMPENVMAT00];
- GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, psi->bumpenvmatconst[i].const_num, data));
-
- if (psi->luminanceconst[i].const_num != WINED3D_CONST_NUM_UNUSED)
- {
- /* WINED3DTSS_BUMPENVLSCALE and WINED3DTSS_BUMPENVLOFFSET are next to each other.
- * point gl to the scale, and load 4 floats. x = scale, y = offset, z and w are junk, we
- * don't care about them. The pointers are valid for sure because the stateblock is bigger.
- * (they're WINED3DTSS_TEXTURETRANSFORMFLAGS and WINED3DTSS_ADDRESSW, so most likely 0 or NaN
- */
- const float *scale = (const float *)&stateBlock->textureState[(int) psi->luminanceconst[i].texunit][WINED3DTSS_BUMPENVLSCALE];
- GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, psi->luminanceconst[i].const_num, scale));
- }
- }
+ shader_arb_ps_local_constants(deviceImpl);
}
}
@@ -1687,6 +1693,8 @@ static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);");
}
TRACE("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n", This, priv->current_fprogram_id);
+
+ shader_arb_ps_local_constants(This);
} 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: 3372846aa64bdda484d5b5496db40aa1773eb65e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3372846aa64bdda484d5b5496…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Tue May 12 20:22:23 2009 +0200
wined3d: Use local constants for bump parameters.
This simplifies the loading code a bit. The constants were never
designed to be at the same location in all shaders, so there's no
point in using program.env. This way we don't collide with the d3d
shader constants and its easier to work together with NP2 fixups and
other shaders.
---
dlls/wined3d/arb_program_shader.c | 192 +++++++++++++------------------------
1 files changed, 68 insertions(+), 124 deletions(-)
Diff: http://source.winehq.org/git/wine.git/?a=commitdiff;h=3372846aa64bdda484d5b…