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
cb973648
Commit
cb973648
authored
May 21, 2006
by
Ivan Gyurdiev
Committed by
Alexandre Julliard
May 22, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Clean up register use maps.
parent
d59eeb3e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
32 deletions
+39
-32
baseshader.c
dlls/wined3d/baseshader.c
+39
-26
wined3d_private.h
dlls/wined3d/wined3d_private.h
+0
-6
No files found.
dlls/wined3d/baseshader.c
View file @
cb973648
...
...
@@ -30,6 +30,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
#define GLNAME_REQUIRE_GLSL ((const char *)1)
typedef
struct
shader_reg_maps
{
DWORD
texcoord
;
DWORD
temporary
;
DWORD
address
;
}
shader_reg_maps
;
inline
static
BOOL
shader_is_version_token
(
DWORD
token
)
{
return
shader_is_pshader_version
(
token
)
||
shader_is_vshader_version
(
token
);
...
...
@@ -153,26 +159,22 @@ int shader_skip_unrecognized(
return
tokens_read
;
}
/* Note: For vertex shaders,
* texUsed = addrUsed, and
* D3DSPR_TEXTURE = D3DSPR_ADDR.
*
* Also note that this does not count the loop register
* as an address register. */
/* Note that this does not count the loop register
* as an address register. */
void
shader_get_registers_used
(
static
void
shader_get_registers_used
(
IWineD3DBaseShader
*
iface
,
shader_reg_maps
*
reg_maps
,
CONST
DWORD
*
pToken
)
{
IWineD3DBaseShaderImpl
*
This
=
(
IWineD3DBaseShaderImpl
*
)
iface
;
DWORD
*
tempsUsed
=
&
This
->
baseShader
.
temps_used
;
DWORD
*
texUsed
=
&
This
->
baseShader
.
textures_used
;
if
(
pToken
==
NULL
)
return
;
*
tempsUsed
=
0
;
*
texUsed
=
0
;
reg_maps
->
temporary
=
0
;
reg_maps
->
texcoord
=
0
;
reg_maps
->
address
=
0
;
while
(
D3DVS_END
()
!=
*
pToken
)
{
CONST
SHADER_OPCODE
*
curOpcode
;
...
...
@@ -233,10 +235,16 @@ void shader_get_registers_used(
regtype
=
(
param
&
D3DSP_REGTYPE_MASK
)
>>
D3DSP_REGTYPE_SHIFT
;
reg
=
param
&
D3DSP_REGNUM_MASK
;
if
(
D3DSPR_TEXTURE
==
regtype
)
*
texUsed
|=
(
1
<<
reg
);
if
(
D3DSPR_TEXTURE
==
regtype
)
{
/* vs: D3DSPR_ADDR */
if
(
shader_is_pshader_version
(
This
->
baseShader
.
hex_version
))
reg_maps
->
texcoord
|=
(
1
<<
reg
);
else
reg_maps
->
address
|=
(
1
<<
reg
);
}
if
(
D3DSPR_TEMP
==
regtype
)
*
tempsUsed
|=
(
1
<<
reg
);
reg_maps
->
temporary
|=
(
1
<<
reg
);
}
}
}
...
...
@@ -498,30 +506,33 @@ void shader_dump_param(
/** Generate the variable & register declarations for the ARB_vertex_program
output target */
void
generate_arb_declarations
(
IWineD3DBaseShader
*
iface
,
SHADER_BUFFER
*
buffer
)
{
void
generate_arb_declarations
(
IWineD3DBaseShader
*
iface
,
shader_reg_maps
*
reg_maps
,
SHADER_BUFFER
*
buffer
)
{
IWineD3DBaseShaderImpl
*
This
=
(
IWineD3DBaseShaderImpl
*
)
iface
;
DWORD
i
;
for
(
i
=
0
;
i
<
This
->
baseShader
.
limits
.
temporary
;
i
++
)
{
if
(
This
->
baseShader
.
temps_used
&
(
1
<<
i
))
if
(
reg_maps
->
temporary
&
(
1
<<
i
))
shader_addline
(
buffer
,
"TEMP R%lu;
\n
"
,
i
);
}
for
(
i
=
0
;
i
<
This
->
baseShader
.
limits
.
address
;
i
++
)
{
if
(
This
->
baseShader
.
textures_used
&
(
1
<<
i
))
if
(
reg_maps
->
address
&
(
1
<<
i
))
shader_addline
(
buffer
,
"ADDRESS A%ld;
\n
"
,
i
);
}
for
(
i
=
0
;
i
<
This
->
baseShader
.
limits
.
texture
;
i
++
)
{
if
(
This
->
baseShader
.
textures_use
d
&
(
1
<<
i
))
if
(
reg_maps
->
texcoor
d
&
(
1
<<
i
))
shader_addline
(
buffer
,
"TEMP T%lu;
\n
"
,
i
);
}
/* Texture coordinate registers must be pre-loaded */
for
(
i
=
0
;
i
<
This
->
baseShader
.
limits
.
texture
;
i
++
)
{
if
(
This
->
baseShader
.
textures_use
d
&
(
1
<<
i
))
shader_addline
(
buffer
,
"MOV T%lu, fragment.texcoord[%lu];
\n
"
,
i
,
i
);
if
(
reg_maps
->
texcoor
d
&
(
1
<<
i
))
shader_addline
(
buffer
,
"MOV T%lu, fragment.texcoord[%lu];
\n
"
,
i
,
i
);
}
/* Need to PARAM the environment parameters (constants) so we can use relative addressing */
...
...
@@ -532,7 +543,10 @@ void generate_arb_declarations(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer)
/** Generate the variable & register declarations for the GLSL
output target */
void
generate_glsl_declarations
(
IWineD3DBaseShader
*
iface
,
SHADER_BUFFER
*
buffer
)
{
void
generate_glsl_declarations
(
IWineD3DBaseShader
*
iface
,
shader_reg_maps
*
reg_maps
,
SHADER_BUFFER
*
buffer
)
{
FIXME
(
"GLSL not fully implemented yet.
\n
"
);
...
...
@@ -554,14 +568,13 @@ void generate_base_shader(
SHADER_HANDLER
hw_fct
=
NULL
;
DWORD
opcode_token
;
DWORD
i
;
shader_reg_maps
reg_maps
;
/* Initialize current parsing state */
This
->
baseShader
.
parse_state
.
current_row
=
0
;
/* First pass: figure out which temporary and texture registers are used */
shader_get_registers_used
(
iface
,
pToken
);
TRACE
(
"Texture/Address registers used: %#lx, Temp registers used %#lx
\n
"
,
This
->
baseShader
.
textures_used
,
This
->
baseShader
.
temps_used
);
shader_get_registers_used
(
iface
,
&
reg_maps
,
pToken
);
/* TODO: check register usage against GL/Directx limits, and fail if they're exceeded
nUseAddressRegister < = GL_MAX_PROGRAM_ADDRESS_REGISTERS_AR
...
...
@@ -570,10 +583,10 @@ void generate_base_shader(
/* Pre-declare registers */
if
(
USING_GLSL
)
{
generate_glsl_declarations
(
iface
,
buffer
);
generate_glsl_declarations
(
iface
,
&
reg_maps
,
buffer
);
shader_addline
(
buffer
,
"void main() {
\n
"
);
}
else
{
generate_arb_declarations
(
iface
,
buffer
);
generate_arb_declarations
(
iface
,
&
reg_maps
,
buffer
);
}
/* Second pass, process opcodes */
...
...
dlls/wined3d/wined3d_private.h
View file @
cb973648
...
...
@@ -1341,8 +1341,6 @@ typedef struct IWineD3DBaseShaderClass
{
DWORD
version
;
DWORD
hex_version
;
DWORD
temps_used
;
DWORD
textures_used
;
SHADER_LIMITS
limits
;
SHADER_PARSE_STATE
parse_state
;
CONST
SHADER_OPCODE
*
shader_ins
;
...
...
@@ -1360,10 +1358,6 @@ typedef struct IWineD3DBaseShaderImpl {
IWineD3DBaseShaderClass
baseShader
;
}
IWineD3DBaseShaderImpl
;
extern
void
shader_get_registers_used
(
IWineD3DBaseShader
*
iface
,
CONST
DWORD
*
pToken
);
extern
void
shader_program_dump_decl_usage
(
DWORD
dcl
,
DWORD
param
);
...
...
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