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
edb78187
Commit
edb78187
authored
Nov 09, 2007
by
Stefan Dösinger
Committed by
Alexandre Julliard
Nov 14, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Hardcode local constants into the shader if possible.
parent
b673b984
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
8 deletions
+47
-8
baseshader.c
dlls/wined3d/baseshader.c
+10
-6
glsl_shader.c
dlls/wined3d/glsl_shader.c
+33
-2
pixelshader.c
dlls/wined3d/pixelshader.c
+1
-0
vertexshader.c
dlls/wined3d/vertexshader.c
+1
-0
wined3d_private.h
dlls/wined3d/wined3d_private.h
+2
-0
No files found.
dlls/wined3d/baseshader.c
View file @
edb78187
...
...
@@ -447,12 +447,16 @@ HRESULT shader_get_registers_used(
else
if
(
WINED3DSPR_MISCTYPE
==
regtype
&&
reg
==
0
&&
pshader
)
reg_maps
->
vpos
=
1
;
else
if
(
WINED3DSPR_CONST
==
regtype
&&
!
pshader
&&
param
&
WINED3DSHADER_ADDRMODE_RELATIVE
)
{
if
(
reg
<=
((
IWineD3DVertexShaderImpl
*
)
This
)
->
min_rel_offset
)
{
((
IWineD3DVertexShaderImpl
*
)
This
)
->
min_rel_offset
=
reg
;
}
else
if
(
reg
>=
((
IWineD3DVertexShaderImpl
*
)
This
)
->
max_rel_offset
)
{
((
IWineD3DVertexShaderImpl
*
)
This
)
->
max_rel_offset
=
reg
;
else
if
(
WINED3DSPR_CONST
==
regtype
)
{
if
(
param
&
WINED3DSHADER_ADDRMODE_RELATIVE
)
{
if
(
!
pshader
)
{
if
(
reg
<=
((
IWineD3DVertexShaderImpl
*
)
This
)
->
min_rel_offset
)
{
((
IWineD3DVertexShaderImpl
*
)
This
)
->
min_rel_offset
=
reg
;
}
else
if
(
reg
>=
((
IWineD3DVertexShaderImpl
*
)
This
)
->
max_rel_offset
)
{
((
IWineD3DVertexShaderImpl
*
)
This
)
->
max_rel_offset
=
reg
;
}
}
reg_maps
->
usesrelconstF
=
TRUE
;
}
}
}
...
...
dlls/wined3d/glsl_shader.c
View file @
edb78187
...
...
@@ -199,6 +199,11 @@ static void shader_glsl_load_constantsF(IWineD3DBaseShaderImpl* This, WineD3D_GL
}
checkGLcall
(
"glUniform4fvARB()"
);
if
(
!
This
->
baseShader
.
load_local_constsF
)
{
TRACE
(
"No need to load local float constants for this shader
\n
"
);
return
;
}
/* Load immediate constants */
if
(
TRACE_ON
(
d3d_shader
))
{
LIST_FOR_EACH_ENTRY
(
lconst
,
&
This
->
baseShader
.
constantsF
,
local_constant
,
entry
)
{
...
...
@@ -464,6 +469,7 @@ void shader_generate_glsl_declarations(
IWineD3DDeviceImpl
*
device
=
(
IWineD3DDeviceImpl
*
)
This
->
baseShader
.
device
;
int
i
;
unsigned
int
extra_constants_needed
=
0
;
local_constant
*
lconst
;
/* There are some minor differences between pixel and vertex shaders */
char
pshader
=
shader_is_pshader_version
(
This
->
baseShader
.
hex_version
);
...
...
@@ -640,6 +646,15 @@ void shader_generate_glsl_declarations(
shader_addline
(
buffer
,
"vec4 tmp0;
\n
"
);
shader_addline
(
buffer
,
"vec4 tmp1;
\n
"
);
/* Hardcodeable local constants */
if
(
!
This
->
baseShader
.
load_local_constsF
)
{
LIST_FOR_EACH_ENTRY
(
lconst
,
&
This
->
baseShader
.
constantsF
,
local_constant
,
entry
)
{
float
*
value
=
(
float
*
)
lconst
->
value
;
shader_addline
(
buffer
,
"const vec4 LC%u = vec4(%f, %f, %f, %f);
\n
"
,
lconst
->
idx
,
value
[
0
],
value
[
1
],
value
[
2
],
value
[
3
]);
}
}
/* Start the main program */
shader_addline
(
buffer
,
"void main() {
\n
"
);
if
(
pshader
&&
reg_maps
->
vpos
)
{
...
...
@@ -734,6 +749,17 @@ static void shader_glsl_gen_modifier (
}
}
static
BOOL
constant_is_local
(
IWineD3DBaseShaderImpl
*
This
,
DWORD
reg
)
{
local_constant
*
lconst
;
if
(
This
->
baseShader
.
load_local_constsF
)
return
FALSE
;
LIST_FOR_EACH_ENTRY
(
lconst
,
&
This
->
baseShader
.
constantsF
,
local_constant
,
entry
)
{
if
(
lconst
->
idx
==
reg
)
return
TRUE
;
}
return
FALSE
;
}
/** Writes the GLSL variable name that corresponds to the register that the
* DX opcode parameter is trying to access */
static
void
shader_glsl_get_register_name
(
...
...
@@ -819,8 +845,13 @@ static void shader_glsl_get_register_name(
}
}
}
else
sprintf
(
tmpStr
,
"%s[%u]"
,
prefix
,
reg
);
}
else
{
if
(
constant_is_local
(
This
,
reg
))
{
sprintf
(
tmpStr
,
"LC%u"
,
reg
);
}
else
{
sprintf
(
tmpStr
,
"%s[%u]"
,
prefix
,
reg
);
}
}
break
;
}
...
...
dlls/wined3d/pixelshader.c
View file @
edb78187
...
...
@@ -586,6 +586,7 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i
}
}
}
This
->
baseShader
.
load_local_constsF
=
FALSE
;
This
->
baseShader
.
shader_mode
=
deviceImpl
->
ps_selected_mode
;
...
...
dlls/wined3d/vertexshader.c
View file @
edb78187
...
...
@@ -587,6 +587,7 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader
This
->
rel_offset
=
0
;
}
}
This
->
baseShader
.
load_local_constsF
=
This
->
baseShader
.
reg_maps
.
usesrelconstF
&&
!
list_empty
(
&
This
->
baseShader
.
constantsF
);
/* copy the function ... because it will certainly be released by application */
if
(
NULL
!=
pFunction
)
{
...
...
dlls/wined3d/wined3d_private.h
View file @
edb78187
...
...
@@ -1669,6 +1669,7 @@ typedef struct shader_reg_maps {
DWORD
samplers
[
max
(
MAX_FRAGMENT_SAMPLERS
,
MAX_VERTEX_SAMPLERS
)];
char
bumpmat
,
luminanceparams
;
char
usesnrm
,
vpos
,
usesdsy
;
char
usesrelconstF
;
/* Whether or not loops are used in this shader, and nesting depth */
unsigned
loop_depth
;
...
...
@@ -1898,6 +1899,7 @@ typedef struct IWineD3DBaseShaderClass
GLuint
prgId
;
BOOL
is_compiled
;
UINT
cur_loop_depth
,
cur_loop_regno
;
BOOL
load_local_constsF
;
/* Type of shader backend */
int
shader_mode
;
...
...
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