Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
70968e69
Commit
70968e69
authored
Dec 02, 2008
by
Henri Verbeet
Committed by
Alexandre Julliard
Dec 03, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Use a bitmask to store which bool and int constants are set.
Note that constants_set was never actually NULL for shader_glsl_load_constantsB() and shader_glsl_load_constantsI().
parent
0ae60765
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
58 deletions
+52
-58
device.c
dlls/wined3d/device.c
+16
-12
glsl_shader.c
dlls/wined3d/glsl_shader.c
+24
-34
stateblock.c
dlls/wined3d/stateblock.c
+8
-8
wined3d_private.h
dlls/wined3d/wined3d_private.h
+4
-4
No files found.
dlls/wined3d/device.c
View file @
70968e69
...
...
@@ -457,12 +457,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
object
->
num_contained_ps_consts_f
=
GL_LIMITS
(
pshader_constantsF
);
for
(
i
=
0
;
i
<
MAX_CONST_B
;
++
i
)
{
object
->
contained_ps_consts_b
[
i
]
=
i
;
object
->
changed
.
pixelShaderConstantsB
[
i
]
=
TRUE
;
object
->
changed
.
pixelShaderConstantsB
|=
(
1
<<
i
)
;
}
object
->
num_contained_ps_consts_b
=
MAX_CONST_B
;
for
(
i
=
0
;
i
<
MAX_CONST_I
;
++
i
)
{
object
->
contained_ps_consts_i
[
i
]
=
i
;
object
->
changed
.
pixelShaderConstantsI
[
i
]
=
TRUE
;
object
->
changed
.
pixelShaderConstantsI
|=
(
1
<<
i
)
;
}
object
->
num_contained_ps_consts_i
=
MAX_CONST_I
;
...
...
@@ -514,13 +514,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
}
object
->
num_contained_vs_consts_f
=
GL_LIMITS
(
vshader_constantsF
);
for
(
i
=
0
;
i
<
MAX_CONST_B
;
++
i
)
{
object
->
changed
.
vertexShaderConstantsB
[
i
]
=
TRUE
;
object
->
contained_vs_consts_b
[
i
]
=
i
;
object
->
changed
.
vertexShaderConstantsB
|=
(
1
<<
i
);
}
object
->
num_contained_vs_consts_b
=
MAX_CONST_B
;
for
(
i
=
0
;
i
<
MAX_CONST_I
;
++
i
)
{
object
->
changed
.
vertexShaderConstantsI
[
i
]
=
TRUE
;
object
->
contained_vs_consts_i
[
i
]
=
i
;
object
->
changed
.
vertexShaderConstantsI
|=
(
1
<<
i
);
}
object
->
num_contained_vs_consts_i
=
MAX_CONST_I
;
for
(
i
=
0
;
i
<
NUM_SAVEDVERTEXSTATES_R
;
i
++
)
{
...
...
@@ -3538,7 +3538,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB(
TRACE
(
"Set BOOL constant %u to %s
\n
"
,
start
+
i
,
srcData
[
i
]
?
"true"
:
"false"
);
for
(
i
=
start
;
i
<
cnt
+
start
;
++
i
)
{
This
->
updateStateBlock
->
changed
.
vertexShaderConstantsB
[
i
]
=
TRUE
;
This
->
updateStateBlock
->
changed
.
vertexShaderConstantsB
|=
(
1
<<
i
)
;
}
IWineD3DDeviceImpl_MarkStateDirty
(
This
,
STATE_VERTEXSHADERCONSTANT
);
...
...
@@ -3586,7 +3586,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantI(
srcData
[
i
*
4
],
srcData
[
i
*
4
+
1
],
srcData
[
i
*
4
+
2
],
srcData
[
i
*
4
+
3
]);
for
(
i
=
start
;
i
<
cnt
+
start
;
++
i
)
{
This
->
updateStateBlock
->
changed
.
vertexShaderConstantsI
[
i
]
=
TRUE
;
This
->
updateStateBlock
->
changed
.
vertexShaderConstantsI
|=
(
1
<<
i
)
;
}
IWineD3DDeviceImpl_MarkStateDirty
(
This
,
STATE_VERTEXSHADERCONSTANT
);
...
...
@@ -3971,7 +3971,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantB(
TRACE
(
"Set BOOL constant %u to %s
\n
"
,
start
+
i
,
srcData
[
i
]
?
"true"
:
"false"
);
for
(
i
=
start
;
i
<
cnt
+
start
;
++
i
)
{
This
->
updateStateBlock
->
changed
.
pixelShaderConstantsB
[
i
]
=
TRUE
;
This
->
updateStateBlock
->
changed
.
pixelShaderConstantsB
|=
(
1
<<
i
)
;
}
IWineD3DDeviceImpl_MarkStateDirty
(
This
,
STATE_PIXELSHADERCONSTANT
);
...
...
@@ -4019,7 +4019,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantI(
srcData
[
i
*
4
],
srcData
[
i
*
4
+
1
],
srcData
[
i
*
4
+
2
],
srcData
[
i
*
4
+
3
]);
for
(
i
=
start
;
i
<
cnt
+
start
;
++
i
)
{
This
->
updateStateBlock
->
changed
.
pixelShaderConstantsI
[
i
]
=
TRUE
;
This
->
updateStateBlock
->
changed
.
pixelShaderConstantsI
|=
(
1
<<
i
)
;
}
IWineD3DDeviceImpl_MarkStateDirty
(
This
,
STATE_PIXELSHADERCONSTANT
);
...
...
@@ -4903,25 +4903,29 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
}
}
for
(
i
=
0
;
i
<
MAX_CONST_I
;
i
++
)
{
if
(
object
->
changed
.
vertexShaderConstantsI
[
i
])
{
if
(
object
->
changed
.
vertexShaderConstantsI
&
(
1
<<
i
))
{
object
->
contained_vs_consts_i
[
object
->
num_contained_vs_consts_i
]
=
i
;
object
->
num_contained_vs_consts_i
++
;
}
}
for
(
i
=
0
;
i
<
MAX_CONST_B
;
i
++
)
{
if
(
object
->
changed
.
vertexShaderConstantsB
[
i
])
{
if
(
object
->
changed
.
vertexShaderConstantsB
&
(
1
<<
i
))
{
object
->
contained_vs_consts_b
[
object
->
num_contained_vs_consts_b
]
=
i
;
object
->
num_contained_vs_consts_b
++
;
}
}
for
(
i
=
0
;
i
<
MAX_CONST_I
;
i
++
)
{
if
(
object
->
changed
.
pixelShaderConstantsI
[
i
])
{
if
(
object
->
changed
.
pixelShaderConstantsI
&
(
1
<<
i
))
{
object
->
contained_ps_consts_i
[
object
->
num_contained_ps_consts_i
]
=
i
;
object
->
num_contained_ps_consts_i
++
;
}
}
for
(
i
=
0
;
i
<
MAX_CONST_B
;
i
++
)
{
if
(
object
->
changed
.
pixelShaderConstantsB
[
i
])
{
if
(
object
->
changed
.
pixelShaderConstantsB
&
(
1
<<
i
))
{
object
->
contained_ps_consts_b
[
object
->
num_contained_ps_consts_b
]
=
i
;
object
->
num_contained_ps_consts_b
++
;
}
...
...
dlls/wined3d/glsl_shader.c
View file @
70968e69
...
...
@@ -291,19 +291,16 @@ static void shader_glsl_load_constantsF(IWineD3DBaseShaderImpl *This, const Wine
checkGLcall
(
"glUniform4fvARB()"
);
}
/**
* Loads integer constants (aka uniforms) into the currently set GLSL program.
* When @constants_set == NULL, it will load all the constants.
*/
/* Loads integer constants (aka uniforms) into the currently set GLSL program. */
static
void
shader_glsl_load_constantsI
(
IWineD3DBaseShaderImpl
*
This
,
const
WineD3D_GL_Info
*
gl_info
,
GLhandleARB
programId
,
const
GLhandleARB
locations
[
MAX_CONST_I
],
unsigned
int
max_constants
,
const
int
*
constants
,
const
BOOL
*
constants_set
)
const
GLhandleARB
locations
[
MAX_CONST_I
],
const
int
*
constants
,
WORD
constants_set
)
{
unsigned
int
i
;
struct
list
*
ptr
;
for
(
i
=
0
;
i
<
max_constants
;
++
i
)
{
if
(
NULL
==
constants_set
||
constants_set
[
i
])
{
for
(
i
=
0
;
constants_set
;
constants_set
>>=
1
,
++
i
)
{
if
(
!
(
constants_set
&
1
))
continue
;
TRACE_
(
d3d_constants
)(
"Loading constants %u: %i, %i, %i, %i
\n
"
,
i
,
constants
[
i
*
4
],
constants
[
i
*
4
+
1
],
constants
[
i
*
4
+
2
],
constants
[
i
*
4
+
3
]);
...
...
@@ -312,7 +309,6 @@ static void shader_glsl_load_constantsI(IWineD3DBaseShaderImpl *This, const Wine
GL_EXTCALL
(
glUniform4ivARB
(
locations
[
i
],
1
,
&
constants
[
i
*
4
]));
checkGLcall
(
"glUniform4ivARB"
);
}
}
/* Load immediate constants */
ptr
=
list_head
(
&
This
->
baseShader
.
constantsI
);
...
...
@@ -331,12 +327,9 @@ static void shader_glsl_load_constantsI(IWineD3DBaseShaderImpl *This, const Wine
}
}
/**
* Loads boolean constants (aka uniforms) into the currently set GLSL program.
* When @constants_set == NULL, it will load all the constants.
*/
/* Loads boolean constants (aka uniforms) into the currently set GLSL program. */
static
void
shader_glsl_load_constantsB
(
IWineD3DBaseShaderImpl
*
This
,
const
WineD3D_GL_Info
*
gl_info
,
GLhandleARB
programId
,
unsigned
int
max_constants
,
const
BOOL
*
constants
,
const
BOOL
*
constants_set
)
GLhandleARB
programId
,
const
BOOL
*
constants
,
WORD
constants_set
)
{
GLhandleARB
tmp_loc
;
unsigned
int
i
;
...
...
@@ -345,22 +338,25 @@ static void shader_glsl_load_constantsB(IWineD3DBaseShaderImpl *This, const Wine
const
char
*
prefix
=
is_pshader
?
"PB"
:
"VB"
;
struct
list
*
ptr
;
for
(
i
=
0
;
i
<
max_constants
;
++
i
)
{
if
(
NULL
==
constants_set
||
constants_set
[
i
])
{
/* TODO: Benchmark and see if it would be beneficial to store the
* locations of the constants to avoid looking up each time */
for
(
i
=
0
;
constants_set
;
constants_set
>>=
1
,
++
i
)
{
if
(
!
(
constants_set
&
1
))
continue
;
TRACE_
(
d3d_constants
)(
"Loading constants %u
: %i;
\n
"
,
i
,
constants
[
i
]);
TRACE_
(
d3d_constants
)(
"Loading constants %i
: %i;
\n
"
,
i
,
constants
[
i
]);
/* TODO: Benchmark and see if it would be beneficial to store the
* locations of the constants to avoid looking up each time */
snprintf
(
tmp_name
,
sizeof
(
tmp_name
),
"%s[%u
]"
,
prefix
,
i
);
snprintf
(
tmp_name
,
sizeof
(
tmp_name
),
"%s[%i
]"
,
prefix
,
i
);
tmp_loc
=
GL_EXTCALL
(
glGetUniformLocationARB
(
programId
,
tmp_name
));
if
(
tmp_loc
!=
-
1
)
{
if
(
tmp_loc
!=
-
1
)
{
/* We found this uniform name in the program - go ahead and send the data */
GL_EXTCALL
(
glUniform1ivARB
(
tmp_loc
,
1
,
&
constants
[
i
]));
checkGLcall
(
"glUniform1ivARB"
);
}
}
}
/* Load immediate constants */
ptr
=
list_head
(
&
This
->
baseShader
.
constantsB
);
...
...
@@ -420,15 +416,12 @@ static void shader_glsl_load_constants(
stateBlock
->
vertexShaderConstantF
,
constant_locations
,
constant_list
);
/* Load DirectX 9 integer constants/uniforms for vertex shader */
shader_glsl_load_constantsI
(
vshader
,
gl_info
,
programId
,
prog
->
vuniformI_locations
,
MAX_CONST_I
,
stateBlock
->
vertexShaderConstantI
,
stateBlock
->
changed
.
vertexShaderConstantsI
);
shader_glsl_load_constantsI
(
vshader
,
gl_info
,
prog
->
vuniformI_locations
,
stateBlock
->
vertexShaderConstantI
,
stateBlock
->
changed
.
vertexShaderConstantsI
);
/* Load DirectX 9 boolean constants/uniforms for vertex shader */
shader_glsl_load_constantsB
(
vshader
,
gl_info
,
programId
,
MAX_CONST_B
,
stateBlock
->
vertexShaderConstantB
,
stateBlock
->
changed
.
vertexShaderConstantsB
);
shader_glsl_load_constantsB
(
vshader
,
gl_info
,
programId
,
stateBlock
->
vertexShaderConstantB
,
stateBlock
->
changed
.
vertexShaderConstantsB
);
/* Upload the position fixup params */
GL_EXTCALL
(
glUniform4fvARB
(
prog
->
posFixup_location
,
1
,
&
deviceImpl
->
posFixup
[
0
]));
...
...
@@ -447,15 +440,12 @@ static void shader_glsl_load_constants(
stateBlock
->
pixelShaderConstantF
,
constant_locations
,
constant_list
);
/* Load DirectX 9 integer constants/uniforms for pixel shader */
shader_glsl_load_constantsI
(
pshader
,
gl_info
,
programId
,
prog
->
puniformI_locations
,
MAX_CONST_I
,
stateBlock
->
pixelShaderConstantI
,
stateBlock
->
changed
.
pixelShaderConstantsI
);
shader_glsl_load_constantsI
(
pshader
,
gl_info
,
prog
->
puniformI_locations
,
stateBlock
->
pixelShaderConstantI
,
stateBlock
->
changed
.
pixelShaderConstantsI
);
/* Load DirectX 9 boolean constants/uniforms for pixel shader */
shader_glsl_load_constantsB
(
pshader
,
gl_info
,
programId
,
MAX_CONST_B
,
stateBlock
->
pixelShaderConstantB
,
stateBlock
->
changed
.
pixelShaderConstantsB
);
shader_glsl_load_constantsB
(
pshader
,
gl_info
,
programId
,
stateBlock
->
pixelShaderConstantB
,
stateBlock
->
changed
.
pixelShaderConstantsB
);
/* 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.
...
...
dlls/wined3d/stateblock.c
View file @
70968e69
...
...
@@ -87,10 +87,10 @@ static void stateblock_savedstates_copy(IWineD3DStateBlock* iface, SAVEDSTATES *
memcpy
(
dest
->
textureState
,
source
->
textureState
,
bsize
*
MAX_TEXTURES
*
(
WINED3D_HIGHEST_TEXTURE_STATE
+
1
));
memcpy
(
dest
->
samplerState
,
source
->
samplerState
,
bsize
*
MAX_COMBINED_SAMPLERS
*
(
WINED3D_HIGHEST_SAMPLER_STATE
+
1
));
memcpy
(
dest
->
clipplane
,
source
->
clipplane
,
bsize
*
MAX_CLIPPLANES
);
memcpy
(
dest
->
pixelShaderConstantsB
,
source
->
pixelShaderConstantsB
,
bsize
*
MAX_CONST_B
)
;
memcpy
(
dest
->
pixelShaderConstantsI
,
source
->
pixelShaderConstantsI
,
bsize
*
MAX_CONST_I
)
;
memcpy
(
dest
->
vertexShaderConstantsB
,
source
->
vertexShaderConstantsB
,
bsize
*
MAX_CONST_B
)
;
memcpy
(
dest
->
vertexShaderConstantsI
,
source
->
vertexShaderConstantsI
,
bsize
*
MAX_CONST_I
)
;
dest
->
pixelShaderConstantsB
=
source
->
pixelShaderConstantsB
;
dest
->
pixelShaderConstantsI
=
source
->
pixelShaderConstantsI
;
dest
->
vertexShaderConstantsB
=
source
->
vertexShaderConstantsB
;
dest
->
vertexShaderConstantsI
=
source
->
vertexShaderConstantsI
;
/* Dynamically sized arrays */
memcpy
(
dest
->
pixelShaderConstantsF
,
source
->
pixelShaderConstantsF
,
bsize
*
GL_LIMITS
(
pshader_constantsF
));
...
...
@@ -125,10 +125,10 @@ void stateblock_savedstates_set(
memset
(
states
->
textureState
,
value
,
bsize
*
MAX_TEXTURES
*
(
WINED3D_HIGHEST_TEXTURE_STATE
+
1
));
memset
(
states
->
samplerState
,
value
,
bsize
*
MAX_COMBINED_SAMPLERS
*
(
WINED3D_HIGHEST_SAMPLER_STATE
+
1
));
memset
(
states
->
clipplane
,
value
,
bsize
*
MAX_CLIPPLANES
);
memset
(
states
->
pixelShaderConstantsB
,
value
,
bsize
*
MAX_CONST_B
)
;
memset
(
states
->
pixelShaderConstantsI
,
value
,
bsize
*
MAX_CONST_I
)
;
memset
(
states
->
vertexShaderConstantsB
,
value
,
bsize
*
MAX_CONST_B
)
;
memset
(
states
->
vertexShaderConstantsI
,
value
,
bsize
*
MAX_CONST_I
)
;
states
->
pixelShaderConstantsB
=
value
?
0xffff
:
0
;
states
->
pixelShaderConstantsI
=
value
?
0xffff
:
0
;
states
->
vertexShaderConstantsB
=
value
?
0xffff
:
0
;
states
->
vertexShaderConstantsI
=
value
?
0xffff
:
0
;
/* Dynamically sized arrays */
memset
(
states
->
pixelShaderConstantsF
,
value
,
bsize
*
GL_LIMITS
(
pshader_constantsF
));
...
...
dlls/wined3d/wined3d_private.h
View file @
70968e69
...
...
@@ -1662,12 +1662,12 @@ typedef struct SAVEDSTATES {
BOOL
clipplane
[
MAX_CLIPPLANES
];
BOOL
vertexDecl
;
BOOL
pixelShader
;
BOOL
pixelShaderConstantsB
[
MAX_CONST_B
]
;
BOOL
pixelShaderConstantsI
[
MAX_CONST_I
]
;
WORD
pixelShaderConstantsB
;
WORD
pixelShaderConstantsI
;
BOOL
*
pixelShaderConstantsF
;
BOOL
vertexShader
;
BOOL
vertexShaderConstantsB
[
MAX_CONST_B
]
;
BOOL
vertexShaderConstantsI
[
MAX_CONST_I
]
;
WORD
vertexShaderConstantsB
;
WORD
vertexShaderConstantsI
;
BOOL
*
vertexShaderConstantsF
;
BOOL
scissorRect
;
}
SAVEDSTATES
;
...
...
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