Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
298bd3c5
Commit
298bd3c5
authored
Jun 09, 2009
by
Stefan Dösinger
Committed by
Alexandre Julliard
Jun 10, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Store the bumpmap ARB constants in ARB structures.
parent
e83fa982
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
90 deletions
+96
-90
arb_program_shader.c
dlls/wined3d/arb_program_shader.c
+84
-63
glsl_shader.c
dlls/wined3d/glsl_shader.c
+12
-19
wined3d_private.h
dlls/wined3d/wined3d_private.h
+0
-8
No files found.
dlls/wined3d/arb_program_shader.c
View file @
298bd3c5
...
@@ -74,9 +74,11 @@ static unsigned int reserved_vs_const(IWineD3DBaseShader *shader, const WineD3D_
...
@@ -74,9 +74,11 @@ static unsigned int reserved_vs_const(IWineD3DBaseShader *shader, const WineD3D_
#define ARB_SHADER_PRIVCONST_POS ARB_SHADER_PRIVCONST_BASE + 0
#define ARB_SHADER_PRIVCONST_POS ARB_SHADER_PRIVCONST_BASE + 0
/* ARB_program_shader private data */
/* ARB_program_shader private data */
struct
shader_arb_priv
{
struct
shader_arb_priv
{
GLuint
current_vprogram_id
;
GLuint
current_vprogram_id
;
GLuint
current_fprogram_id
;
GLuint
current_fprogram_id
;
const
struct
arb_ps_compiled_shader
*
compiled_fprog
;
GLuint
depth_blt_vprogram_id
;
GLuint
depth_blt_vprogram_id
;
GLuint
depth_blt_fprogram_id
[
tex_type_count
];
GLuint
depth_blt_fprogram_id
[
tex_type_count
];
BOOL
use_arbfp_fixed_func
;
BOOL
use_arbfp_fixed_func
;
...
@@ -89,6 +91,27 @@ struct if_frame {
...
@@ -89,6 +91,27 @@ struct if_frame {
BOOL
muting
;
BOOL
muting
;
};
};
struct
arb_ps_compile_args
{
struct
ps_compile_args
super
;
DWORD
bools
;
/* WORD is enough, use DWORD for alignment */
};
struct
stb_const_desc
{
unsigned
char
texunit
;
UINT
const_num
;
};
struct
arb_ps_compiled_shader
{
struct
arb_ps_compile_args
args
;
GLuint
prgId
;
struct
stb_const_desc
bumpenvmatconst
[
MAX_TEXTURES
];
unsigned
char
numbumpenvmatconsts
;
struct
stb_const_desc
luminanceconst
[
MAX_TEXTURES
];
};
struct
shader_arb_ctx_priv
{
struct
shader_arb_ctx_priv
{
char
addr_reg
[
20
];
char
addr_reg
[
20
];
enum
{
enum
{
...
@@ -102,20 +125,11 @@ struct shader_arb_ctx_priv {
...
@@ -102,20 +125,11 @@ struct shader_arb_ctx_priv {
const
struct
arb_vs_compile_args
*
cur_vs_args
;
const
struct
arb_vs_compile_args
*
cur_vs_args
;
const
struct
arb_ps_compile_args
*
cur_ps_args
;
const
struct
arb_ps_compile_args
*
cur_ps_args
;
const
struct
arb_ps_compiled_shader
*
compiled_fprog
;
struct
list
if_frames
;
struct
list
if_frames
;
BOOL
muted
;
BOOL
muted
;
};
};
struct
arb_ps_compile_args
{
struct
ps_compile_args
super
;
DWORD
bools
;
/* WORD is enough, use DWORD for alignment */
};
struct
arb_ps_compiled_shader
{
struct
arb_ps_compile_args
args
;
GLuint
prgId
;
};
struct
arb_pshader_private
{
struct
arb_pshader_private
{
struct
arb_ps_compiled_shader
*
gl_shaders
;
struct
arb_ps_compiled_shader
*
gl_shaders
;
UINT
num_gl_shaders
,
shader_array_size
;
UINT
num_gl_shaders
,
shader_array_size
;
...
@@ -256,26 +270,28 @@ static void shader_arb_load_np2fixup_constants(
...
@@ -256,26 +270,28 @@ static void shader_arb_load_np2fixup_constants(
static
inline
void
shader_arb_ps_local_constants
(
IWineD3DDeviceImpl
*
deviceImpl
)
static
inline
void
shader_arb_ps_local_constants
(
IWineD3DDeviceImpl
*
deviceImpl
)
{
{
IWineD3DStateBlockImpl
*
stateBlock
=
deviceImpl
->
stateBlock
;
IWineD3DStateBlockImpl
*
stateBlock
=
deviceImpl
->
stateBlock
;
IWineD3DBaseShaderImpl
*
pshader
=
(
IWineD3DBaseShaderImpl
*
)
stateBlock
->
pixelShader
;
IWineD3DPixelShaderImpl
*
psi
=
(
IWineD3DPixelShaderImpl
*
)
pshader
;
const
WineD3D_GL_Info
*
gl_info
=
&
deviceImpl
->
adapter
->
gl_info
;
const
WineD3D_GL_Info
*
gl_info
=
&
deviceImpl
->
adapter
->
gl_info
;
unsigned
char
i
;
unsigned
char
i
;
struct
shader_arb_priv
*
priv
=
deviceImpl
->
shader_priv
;
const
struct
arb_ps_compiled_shader
*
gl_shader
=
priv
->
compiled_fprog
;
for
(
i
=
0
;
i
<
psi
->
numbumpenvmatconsts
;
i
++
)
for
(
i
=
0
;
i
<
gl_shader
->
numbumpenvmatconsts
;
i
++
)
{
{
int
texunit
=
gl_shader
->
bumpenvmatconst
[
i
].
texunit
;
/* The state manager takes care that this function is always called if the bump env matrix changes */
/* 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
];
const
float
*
data
=
(
const
float
*
)
&
stateBlock
->
textureState
[
texunit
][
WINED3DTSS_BUMPENVMAT00
];
GL_EXTCALL
(
glProgramLocalParameter4fvARB
(
GL_FRAGMENT_PROGRAM_ARB
,
psi
->
bumpenvmatconst
[
i
].
const_num
,
data
));
GL_EXTCALL
(
glProgramLocalParameter4fvARB
(
GL_FRAGMENT_PROGRAM_ARB
,
gl_shader
->
bumpenvmatconst
[
i
].
const_num
,
data
));
if
(
psi
->
luminanceconst
[
i
].
const_num
!=
WINED3D_CONST_NUM_UNUSED
)
if
(
gl_shader
->
luminanceconst
[
i
].
const_num
!=
WINED3D_CONST_NUM_UNUSED
)
{
{
/* WINED3DTSS_BUMPENVLSCALE and WINED3DTSS_BUMPENVLOFFSET are next to each other.
/* 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
* 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.
* 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
* (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
];
const
float
*
scale
=
(
const
float
*
)
&
stateBlock
->
textureState
[
texunit
][
WINED3DTSS_BUMPENVLSCALE
];
GL_EXTCALL
(
glProgramLocalParameter4fvARB
(
GL_FRAGMENT_PROGRAM_ARB
,
psi
->
luminanceconst
[
i
].
const_num
,
scale
));
GL_EXTCALL
(
glProgramLocalParameter4fvARB
(
GL_FRAGMENT_PROGRAM_ARB
,
gl_shader
->
luminanceconst
[
i
].
const_num
,
scale
));
}
}
}
}
}
}
...
@@ -365,11 +381,11 @@ static DWORD *local_const_mapping(IWineD3DBaseShaderImpl *This)
...
@@ -365,11 +381,11 @@ static DWORD *local_const_mapping(IWineD3DBaseShaderImpl *This)
}
}
/* Generate the variable & register declarations for the ARB_vertex_program output target */
/* Generate the variable & register declarations for the ARB_vertex_program output target */
static
void
shader_generate_arb_declarations
(
IWineD3DBaseShader
*
iface
,
const
shader_reg_maps
*
reg_maps
,
static
DWORD
shader_generate_arb_declarations
(
IWineD3DBaseShader
*
iface
,
const
shader_reg_maps
*
reg_maps
,
SHADER_BUFFER
*
buffer
,
const
WineD3D_GL_Info
*
gl_info
,
DWORD
*
lconst_map
)
SHADER_BUFFER
*
buffer
,
const
WineD3D_GL_Info
*
gl_info
,
DWORD
*
lconst_map
)
{
{
IWineD3DBaseShaderImpl
*
This
=
(
IWineD3DBaseShaderImpl
*
)
iface
;
IWineD3DBaseShaderImpl
*
This
=
(
IWineD3DBaseShaderImpl
*
)
iface
;
DWORD
i
,
cur
,
next_local
=
0
;
DWORD
i
,
next_local
=
0
;
char
pshader
=
shader_is_pshader_version
(
reg_maps
->
shader_version
.
type
);
char
pshader
=
shader_is_pshader_version
(
reg_maps
->
shader_version
.
type
);
unsigned
max_constantsF
;
unsigned
max_constantsF
;
const
local_constant
*
lconst
;
const
local_constant
*
lconst
;
...
@@ -444,37 +460,7 @@ static void shader_generate_arb_declarations(IWineD3DBaseShader *iface, const sh
...
@@ -444,37 +460,7 @@ static void shader_generate_arb_declarations(IWineD3DBaseShader *iface, const sh
}
}
}
}
for
(
i
=
0
;
i
<
(
sizeof
(
reg_maps
->
bumpmat
)
/
sizeof
(
reg_maps
->
bumpmat
[
0
]));
i
++
)
{
return
next_local
;
IWineD3DPixelShaderImpl
*
ps
=
(
IWineD3DPixelShaderImpl
*
)
This
;
if
(
!
reg_maps
->
bumpmat
[
i
])
continue
;
cur
=
ps
->
numbumpenvmatconsts
;
ps
->
bumpenvmatconst
[
cur
].
const_num
=
-
1
;
ps
->
bumpenvmatconst
[
cur
].
texunit
=
i
;
ps
->
luminanceconst
[
cur
].
const_num
=
-
1
;
ps
->
luminanceconst
[
cur
].
texunit
=
i
;
/* We can fit the constants into the constant limit for sure because texbem, texbeml, bem and beml are only supported
* in 1.x shaders, and GL_ARB_fragment_program has a constant limit of 24 constants. So in the worst case we're loading
* 8 shader constants, 8 bump matrices and 8 luminance parameters and are perfectly fine. (No NP2 fixup on bumpmapped
* textures due to conditional NP2 restrictions)
*
* Use local constants to load the bump env parameters, not program.env. This avoids collisions with d3d constants of
* shaders in newer shader models. Since the bump env parameters have to share their space with NP2 fixup constants,
* their location is shader dependent anyway and they cannot be loaded globally.
*/
ps
->
bumpenvmatconst
[
cur
].
const_num
=
next_local
++
;
shader_addline
(
buffer
,
"PARAM bumpenvmat%d = program.local[%d];
\n
"
,
i
,
ps
->
bumpenvmatconst
[
cur
].
const_num
);
ps
->
numbumpenvmatconsts
=
cur
+
1
;
if
(
!
reg_maps
->
luminanceparams
[
i
])
continue
;
((
IWineD3DPixelShaderImpl
*
)
This
)
->
luminanceconst
[
cur
].
const_num
=
next_local
++
;
shader_addline
(
buffer
,
"PARAM luminance%d = program.local[%d];
\n
"
,
i
,
ps
->
luminanceconst
[
cur
].
const_num
);
}
}
}
static
const
char
*
const
shift_tab
[]
=
{
static
const
char
*
const
shift_tab
[]
=
{
...
@@ -2093,7 +2079,7 @@ static void arbfp_add_sRGB_correction(SHADER_BUFFER *buffer, const char *fragcol
...
@@ -2093,7 +2079,7 @@ static void arbfp_add_sRGB_correction(SHADER_BUFFER *buffer, const char *fragcol
/* GL locking is done by the caller */
/* GL locking is done by the caller */
static
GLuint
shader_arb_generate_pshader
(
IWineD3DPixelShaderImpl
*
This
,
static
GLuint
shader_arb_generate_pshader
(
IWineD3DPixelShaderImpl
*
This
,
SHADER_BUFFER
*
buffer
,
const
struct
arb_ps_compile_args
*
args
)
SHADER_BUFFER
*
buffer
,
const
struct
arb_ps_compile_args
*
args
,
struct
arb_ps_compiled_shader
*
compiled
)
{
{
const
shader_reg_maps
*
reg_maps
=
&
This
->
baseShader
.
reg_maps
;
const
shader_reg_maps
*
reg_maps
=
&
This
->
baseShader
.
reg_maps
;
CONST
DWORD
*
function
=
This
->
baseShader
.
function
;
CONST
DWORD
*
function
=
This
->
baseShader
.
function
;
...
@@ -2101,7 +2087,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This,
...
@@ -2101,7 +2087,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This,
const
local_constant
*
lconst
;
const
local_constant
*
lconst
;
GLuint
retval
;
GLuint
retval
;
char
fragcolor
[
16
];
char
fragcolor
[
16
];
DWORD
*
lconst_map
=
local_const_mapping
((
IWineD3DBaseShaderImpl
*
)
This
);
DWORD
*
lconst_map
=
local_const_mapping
((
IWineD3DBaseShaderImpl
*
)
This
)
,
next_local
,
cur
;
struct
shader_arb_ctx_priv
priv_ctx
;
struct
shader_arb_ctx_priv
priv_ctx
;
BOOL
dcl_tmp
=
args
->
super
.
srgb_correction
,
dcl_td
=
FALSE
;
BOOL
dcl_tmp
=
args
->
super
.
srgb_correction
,
dcl_td
=
FALSE
;
BOOL
want_nv_prog
=
FALSE
;
BOOL
want_nv_prog
=
FALSE
;
...
@@ -2148,6 +2134,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This,
...
@@ -2148,6 +2134,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This,
/* Create the hw ARB shader */
/* Create the hw ARB shader */
memset
(
&
priv_ctx
,
0
,
sizeof
(
priv_ctx
));
memset
(
&
priv_ctx
,
0
,
sizeof
(
priv_ctx
));
priv_ctx
.
cur_ps_args
=
args
;
priv_ctx
.
cur_ps_args
=
args
;
priv_ctx
.
compiled_fprog
=
compiled
;
list_init
(
&
priv_ctx
.
if_frames
);
list_init
(
&
priv_ctx
.
if_frames
);
/* Avoid enabling NV_fragment_program* if we do not need it.
/* Avoid enabling NV_fragment_program* if we do not need it.
...
@@ -2238,7 +2225,37 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This,
...
@@ -2238,7 +2225,37 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This,
}
}
/* Base Declarations */
/* Base Declarations */
shader_generate_arb_declarations
(
(
IWineD3DBaseShader
*
)
This
,
reg_maps
,
buffer
,
&
GLINFO_LOCATION
,
lconst_map
);
next_local
=
shader_generate_arb_declarations
(
(
IWineD3DBaseShader
*
)
This
,
reg_maps
,
buffer
,
&
GLINFO_LOCATION
,
lconst_map
);
for
(
i
=
0
;
i
<
(
sizeof
(
reg_maps
->
bumpmat
)
/
sizeof
(
reg_maps
->
bumpmat
[
0
]));
i
++
)
{
if
(
!
reg_maps
->
bumpmat
[
i
])
continue
;
cur
=
compiled
->
numbumpenvmatconsts
;
compiled
->
bumpenvmatconst
[
cur
].
const_num
=
-
1
;
compiled
->
bumpenvmatconst
[
cur
].
texunit
=
i
;
compiled
->
luminanceconst
[
cur
].
const_num
=
-
1
;
compiled
->
luminanceconst
[
cur
].
texunit
=
i
;
/* We can fit the constants into the constant limit for sure because texbem, texbeml, bem and beml are only supported
* in 1.x shaders, and GL_ARB_fragment_program has a constant limit of 24 constants. So in the worst case we're loading
* 8 shader constants, 8 bump matrices and 8 luminance parameters and are perfectly fine. (No NP2 fixup on bumpmapped
* textures due to conditional NP2 restrictions)
*
* Use local constants to load the bump env parameters, not program.env. This avoids collisions with d3d constants of
* shaders in newer shader models. Since the bump env parameters have to share their space with NP2 fixup constants,
* their location is shader dependent anyway and they cannot be loaded globally.
*/
compiled
->
bumpenvmatconst
[
cur
].
const_num
=
next_local
++
;
shader_addline
(
buffer
,
"PARAM bumpenvmat%d = program.local[%d];
\n
"
,
i
,
compiled
->
bumpenvmatconst
[
cur
].
const_num
);
compiled
->
numbumpenvmatconsts
=
cur
+
1
;
if
(
!
reg_maps
->
luminanceparams
[
i
])
continue
;
compiled
->
luminanceconst
[
cur
].
const_num
=
next_local
++
;
shader_addline
(
buffer
,
"PARAM luminance%d = program.local[%d];
\n
"
,
i
,
compiled
->
luminanceconst
[
cur
].
const_num
);
}
/* Base Shader Body */
/* Base Shader Body */
shader_generate_main
((
IWineD3DBaseShader
*
)
This
,
buffer
,
reg_maps
,
function
,
&
priv_ctx
);
shader_generate_main
((
IWineD3DBaseShader
*
)
This
,
buffer
,
reg_maps
,
function
,
&
priv_ctx
);
...
@@ -2436,7 +2453,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This,
...
@@ -2436,7 +2453,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This,
}
}
/* GL locking is done by the caller */
/* GL locking is done by the caller */
static
GLuint
find_arb_pshader
(
IWineD3DPixelShaderImpl
*
shader
,
const
struct
arb_ps_compile_args
*
args
)
static
struct
arb_ps_compiled_shader
*
find_arb_pshader
(
IWineD3DPixelShaderImpl
*
shader
,
const
struct
arb_ps_compile_args
*
args
)
{
{
UINT
i
;
UINT
i
;
DWORD
new_size
;
DWORD
new_size
;
...
@@ -2456,7 +2473,7 @@ static GLuint find_arb_pshader(IWineD3DPixelShaderImpl *shader, const struct arb
...
@@ -2456,7 +2473,7 @@ static GLuint find_arb_pshader(IWineD3DPixelShaderImpl *shader, const struct arb
*/
*/
for
(
i
=
0
;
i
<
shader_data
->
num_gl_shaders
;
i
++
)
{
for
(
i
=
0
;
i
<
shader_data
->
num_gl_shaders
;
i
++
)
{
if
(
memcmp
(
&
shader_data
->
gl_shaders
[
i
].
args
,
args
,
sizeof
(
*
args
))
==
0
)
{
if
(
memcmp
(
&
shader_data
->
gl_shaders
[
i
].
args
,
args
,
sizeof
(
*
args
))
==
0
)
{
return
shader_data
->
gl_shaders
[
i
].
prgId
;
return
&
shader_data
->
gl_shaders
[
i
]
;
}
}
}
}
...
@@ -2465,10 +2482,10 @@ static GLuint find_arb_pshader(IWineD3DPixelShaderImpl *shader, const struct arb
...
@@ -2465,10 +2482,10 @@ static GLuint find_arb_pshader(IWineD3DPixelShaderImpl *shader, const struct arb
if
(
shader_data
->
num_gl_shaders
)
if
(
shader_data
->
num_gl_shaders
)
{
{
new_size
=
shader_data
->
shader_array_size
+
max
(
1
,
shader_data
->
shader_array_size
/
2
);
new_size
=
shader_data
->
shader_array_size
+
max
(
1
,
shader_data
->
shader_array_size
/
2
);
new_array
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
shader_data
->
gl_shaders
,
new_array
=
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
shader_data
->
gl_shaders
,
new_size
*
sizeof
(
*
shader_data
->
gl_shaders
));
new_size
*
sizeof
(
*
shader_data
->
gl_shaders
));
}
else
{
}
else
{
new_array
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
shader_data
->
gl_shaders
));
new_array
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
shader_data
->
gl_shaders
));
new_size
=
1
;
new_size
=
1
;
}
}
...
@@ -2486,11 +2503,12 @@ static GLuint find_arb_pshader(IWineD3DPixelShaderImpl *shader, const struct arb
...
@@ -2486,11 +2503,12 @@ static GLuint find_arb_pshader(IWineD3DPixelShaderImpl *shader, const struct arb
((
IWineD3DDeviceImpl
*
)
shader
->
baseShader
.
device
)
->
stateBlock
->
textures
);
((
IWineD3DDeviceImpl
*
)
shader
->
baseShader
.
device
)
->
stateBlock
->
textures
);
shader_buffer_init
(
&
buffer
);
shader_buffer_init
(
&
buffer
);
ret
=
shader_arb_generate_pshader
(
shader
,
&
buffer
,
args
);
ret
=
shader_arb_generate_pshader
(
shader
,
&
buffer
,
args
,
&
shader_data
->
gl_shaders
[
shader_data
->
num_gl_shaders
]);
shader_buffer_free
(
&
buffer
);
shader_buffer_free
(
&
buffer
);
shader_data
->
gl_shaders
[
shader_data
->
num_gl_shaders
++
].
prgId
=
ret
;
shader_data
->
gl_shaders
[
shader_data
->
num_gl_shaders
].
prgId
=
ret
;
return
ret
;
return
&
shader_data
->
gl_shaders
[
shader_data
->
num_gl_shaders
++
]
;
}
}
static
inline
BOOL
vs_args_equal
(
const
struct
arb_vs_compile_args
*
stored
,
const
struct
arb_vs_compile_args
*
new
,
static
inline
BOOL
vs_args_equal
(
const
struct
arb_vs_compile_args
*
stored
,
const
struct
arb_vs_compile_args
*
new
,
...
@@ -2618,10 +2636,13 @@ static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
...
@@ -2618,10 +2636,13 @@ static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
if
(
usePS
)
{
if
(
usePS
)
{
struct
arb_ps_compile_args
compile_args
;
struct
arb_ps_compile_args
compile_args
;
struct
arb_ps_compiled_shader
*
compiled
;
TRACE
(
"Using pixel shader
\n
"
);
TRACE
(
"Using pixel shader
\n
"
);
find_arb_ps_compile_args
((
IWineD3DPixelShaderImpl
*
)
This
->
stateBlock
->
pixelShader
,
This
->
stateBlock
,
&
compile_args
);
find_arb_ps_compile_args
((
IWineD3DPixelShaderImpl
*
)
This
->
stateBlock
->
pixelShader
,
This
->
stateBlock
,
&
compile_args
);
priv
->
current_fprogram_i
d
=
find_arb_pshader
((
IWineD3DPixelShaderImpl
*
)
This
->
stateBlock
->
pixelShader
,
compile
d
=
find_arb_pshader
((
IWineD3DPixelShaderImpl
*
)
This
->
stateBlock
->
pixelShader
,
&
compile_args
);
&
compile_args
);
priv
->
current_fprogram_id
=
compiled
->
prgId
;
priv
->
compiled_fprog
=
compiled
;
/* Bind the fragment program */
/* Bind the fragment program */
GL_EXTCALL
(
glBindProgramARB
(
GL_FRAGMENT_PROGRAM_ARB
,
priv
->
current_fprogram_id
));
GL_EXTCALL
(
glBindProgramARB
(
GL_FRAGMENT_PROGRAM_ARB
,
priv
->
current_fprogram_id
));
...
...
dlls/wined3d/glsl_shader.c
View file @
298bd3c5
...
@@ -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
(
p
s
->
baseShader
.
reg_maps
.
luminanceparams
[
stage
]
)
{
if
(
p
rog
->
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
));
}
}
...
...
dlls/wined3d/wined3d_private.h
View file @
298bd3c5
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment