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
e7122e9a
Commit
e7122e9a
authored
Nov 27, 2006
by
H. Verbeet
Committed by
Alexandre Julliard
Nov 28, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Create a separate function for sampling a texture.
parent
8a7f4279
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
85 deletions
+85
-85
arb_program_shader.c
dlls/wined3d/arb_program_shader.c
+39
-33
glsl_shader.c
dlls/wined3d/glsl_shader.c
+46
-52
No files found.
dlls/wined3d/arb_program_shader.c
View file @
e7122e9a
...
...
@@ -423,6 +423,44 @@ static void vshader_program_add_param(SHADER_OPCODE_ARG *arg, const DWORD param,
}
}
static
void
shader_hw_sample
(
SHADER_OPCODE_ARG
*
arg
,
DWORD
sampler_idx
,
const
char
*
dst_str
,
const
char
*
coord_reg
)
{
IWineD3DPixelShaderImpl
*
This
=
(
IWineD3DPixelShaderImpl
*
)
arg
->
shader
;
IWineD3DDeviceImpl
*
deviceImpl
=
(
IWineD3DDeviceImpl
*
)
This
->
baseShader
.
device
;
SHADER_BUFFER
*
buffer
=
arg
->
buffer
;
DWORD
sampler_type
=
arg
->
reg_maps
->
samplers
[
sampler_idx
]
&
WINED3DSP_TEXTURETYPE_MASK
;
const
char
*
tex_type
;
switch
(
sampler_type
)
{
case
WINED3DSTT_1D
:
tex_type
=
"1D"
;
break
;
case
WINED3DSTT_2D
:
tex_type
=
"2D"
;
break
;
case
WINED3DSTT_VOLUME
:
tex_type
=
"3D"
;
break
;
case
WINED3DSTT_CUBE
:
tex_type
=
"CUBE"
;
break
;
default:
ERR
(
"Unexpected texture type %d
\n
"
,
sampler_type
);
tex_type
=
""
;
}
if
(
deviceImpl
->
stateBlock
->
textureState
[
sampler_idx
][
WINED3DTSS_TEXTURETRANSFORMFLAGS
]
&
WINED3DTTFF_PROJECTED
)
{
shader_addline
(
buffer
,
"TXP %s, %s, texture[%u], %s;
\n
"
,
dst_str
,
coord_reg
,
sampler_idx
,
tex_type
);
}
else
{
shader_addline
(
buffer
,
"TEX %s, %s, texture[%u], %s;
\n
"
,
dst_str
,
coord_reg
,
sampler_idx
,
tex_type
);
}
}
static
void
pshader_gen_input_modifier_line
(
SHADER_BUFFER
*
buffer
,
const
DWORD
instr
,
...
...
@@ -618,7 +656,6 @@ void pshader_hw_map2gl(SHADER_OPCODE_ARG* arg) {
void
pshader_hw_tex
(
SHADER_OPCODE_ARG
*
arg
)
{
IWineD3DPixelShaderImpl
*
This
=
(
IWineD3DPixelShaderImpl
*
)
arg
->
shader
;
IWineD3DDeviceImpl
*
deviceImpl
=
(
IWineD3DDeviceImpl
*
)
This
->
baseShader
.
device
;
DWORD
dst
=
arg
->
dst
;
DWORD
*
src
=
arg
->
src
;
...
...
@@ -627,10 +664,8 @@ void pshader_hw_tex(SHADER_OPCODE_ARG* arg) {
char
reg_dest
[
40
];
char
reg_coord
[
40
];
const
char
*
tex_type
;
DWORD
reg_dest_code
;
DWORD
reg_sampler_code
;
DWORD
sampler_type
;
/* All versions have a destination register */
reg_dest_code
=
dst
&
WINED3DSP_REGNUM_MASK
;
...
...
@@ -650,36 +685,7 @@ void pshader_hw_tex(SHADER_OPCODE_ARG* arg) {
else
reg_sampler_code
=
src
[
1
]
&
WINED3DSP_REGNUM_MASK
;
sampler_type
=
arg
->
reg_maps
->
samplers
[
reg_sampler_code
]
&
WINED3DSP_TEXTURETYPE_MASK
;
switch
(
sampler_type
)
{
case
WINED3DSTT_1D
:
tex_type
=
"1D"
;
break
;
case
WINED3DSTT_2D
:
tex_type
=
"2D"
;
break
;
case
WINED3DSTT_VOLUME
:
tex_type
=
"3D"
;
break
;
case
WINED3DSTT_CUBE
:
tex_type
=
"CUBE"
;
break
;
default:
ERR
(
"Unexpected texture type %d
\n
"
,
sampler_type
);
tex_type
=
"2D"
;
}
if
(
deviceImpl
->
stateBlock
->
textureState
[
reg_sampler_code
][
WINED3DTSS_TEXTURETRANSFORMFLAGS
]
&
WINED3DTTFF_PROJECTED
)
{
shader_addline
(
buffer
,
"TXP %s, %s, texture[%u], %s;
\n
"
,
reg_dest
,
reg_coord
,
reg_sampler_code
,
tex_type
);
}
else
{
shader_addline
(
buffer
,
"TEX %s, %s, texture[%u], %s;
\n
"
,
reg_dest
,
reg_coord
,
reg_sampler_code
,
tex_type
);
}
shader_hw_sample
(
arg
,
reg_sampler_code
,
reg_dest
,
reg_coord
);
}
void
pshader_hw_texcoord
(
SHADER_OPCODE_ARG
*
arg
)
{
...
...
dlls/wined3d/glsl_shader.c
View file @
e7122e9a
...
...
@@ -855,6 +855,47 @@ static inline const char* shader_get_comp_op(
}
}
static
void
shader_glsl_sample
(
SHADER_OPCODE_ARG
*
arg
,
DWORD
sampler_idx
,
const
char
*
dst_str
,
const
char
*
coord_reg
)
{
IWineD3DPixelShaderImpl
*
This
=
(
IWineD3DPixelShaderImpl
*
)
arg
->
shader
;
IWineD3DDeviceImpl
*
deviceImpl
=
(
IWineD3DDeviceImpl
*
)
This
->
baseShader
.
device
;
DWORD
sampler_type
=
arg
->
reg_maps
->
samplers
[
sampler_idx
]
&
WINED3DSP_TEXTURETYPE_MASK
;
const
char
sampler_prefix
=
shader_is_pshader_version
(
This
->
baseShader
.
hex_version
)
?
'P'
:
'V'
;
SHADER_BUFFER
*
buffer
=
arg
->
buffer
;
if
(
deviceImpl
->
stateBlock
->
textureState
[
sampler_idx
][
WINED3DTSS_TEXTURETRANSFORMFLAGS
]
&
WINED3DTTFF_PROJECTED
)
{
/* Note that there's no such thing as a projected cube texture. */
switch
(
sampler_type
)
{
case
WINED3DSTT_2D
:
shader_addline
(
buffer
,
"%s = texture2DProj(%cshader%u, %s);
\n
"
,
dst_str
,
sampler_prefix
,
sampler_idx
,
coord_reg
);
break
;
case
WINED3DSTT_VOLUME
:
shader_addline
(
buffer
,
"%s = texture3DProj(%cshader%u, %s);
\n
"
,
dst_str
,
sampler_prefix
,
sampler_idx
,
coord_reg
);
break
;
default:
shader_addline
(
buffer
,
"%s = unrecognized_stype(%cshader%u, %s);
\n
"
,
dst_str
,
sampler_prefix
,
sampler_idx
,
coord_reg
);
FIXME
(
"Unrecognized sampler type: %#x;
\n
"
,
sampler_type
);
break
;
}
}
else
{
switch
(
sampler_type
)
{
case
WINED3DSTT_2D
:
shader_addline
(
buffer
,
"%s = texture2D(%csampler%u, %s.xy);
\n
"
,
dst_str
,
sampler_prefix
,
sampler_idx
,
coord_reg
);
break
;
case
WINED3DSTT_CUBE
:
shader_addline
(
buffer
,
"%s = textureCube(%csampler%u, %s.xyz);
\n
"
,
dst_str
,
sampler_prefix
,
sampler_idx
,
coord_reg
);
break
;
case
WINED3DSTT_VOLUME
:
shader_addline
(
buffer
,
"%s = texture3D(%csampler%u, %s.xyz);
\n
"
,
dst_str
,
sampler_prefix
,
sampler_idx
,
coord_reg
);
break
;
default:
shader_addline
(
buffer
,
"%s = unrecognized_stype(%csampler%u, %s);
\n
"
,
dst_str
,
sampler_prefix
,
sampler_idx
,
coord_reg
);
FIXME
(
"Unrecognized sampler type: %#x;
\n
"
,
sampler_type
);
break
;
}
}
}
/*****************************************************************************
*
* Begin processing individual instruction opcodes
...
...
@@ -1356,20 +1397,12 @@ void shader_glsl_callnz(SHADER_OPCODE_ARG* arg) {
* Pixel Shader Specific Code begins here
********************************************/
void
pshader_glsl_tex
(
SHADER_OPCODE_ARG
*
arg
)
{
/* FIXME: Make this work for more than just 2D textures */
IWineD3DPixelShaderImpl
*
This
=
(
IWineD3DPixelShaderImpl
*
)
arg
->
shader
;
IWineD3DDeviceImpl
*
deviceImpl
=
(
IWineD3DDeviceImpl
*
)
This
->
baseShader
.
device
;
SHADER_BUFFER
*
buffer
=
arg
->
buffer
;
DWORD
hex_version
=
This
->
baseShader
.
hex_version
;
char
dst_str
[
100
],
dst_reg
[
50
],
dst_mask
[
6
];
char
coord_str
[
100
],
coord_reg
[
50
],
coord_mask
[
6
];
char
sampler_str
[
100
],
sampler_reg
[
50
],
sampler_mask
[
6
];
DWORD
reg_dest_code
=
arg
->
dst
&
WINED3DSP_REGNUM_MASK
;
DWORD
sampler_code
,
sampler_type
;
/* All versions have a destination register */
shader_glsl_add_param
(
arg
,
arg
->
dst
,
0
,
FALSE
,
dst_reg
,
dst_mask
,
dst_str
);
...
...
@@ -1381,53 +1414,14 @@ void pshader_glsl_tex(SHADER_OPCODE_ARG* arg) {
else
shader_glsl_add_param
(
arg
,
arg
->
src
[
0
],
arg
->
src_addr
[
0
],
TRUE
,
coord_reg
,
coord_mask
,
coord_str
);
/* 1.0-1.4: Use destination register as
coordinate
source.
* 2.0+: Use provided
coordinate source register
. */
/* 1.0-1.4: Use destination register as
sampler
source.
* 2.0+: Use provided
sampler source
. */
if
(
hex_version
<
WINED3DPS_VERSION
(
2
,
0
))
{
sprintf
(
sampler_str
,
"Psampler%u"
,
reg_dest_code
);
sampler_code
=
reg_dest_code
;
}
else
{
shader_glsl_add_param
(
arg
,
arg
->
src
[
1
],
arg
->
src_addr
[
1
],
TRUE
,
sampler_reg
,
sampler_mask
,
sampler_str
);
sampler_code
=
arg
->
src
[
1
]
&
WINED3DSP_REGNUM_MASK
;
}
sampler_type
=
arg
->
reg_maps
->
samplers
[
sampler_code
]
&
WINED3DSP_TEXTURETYPE_MASK
;
if
(
deviceImpl
->
stateBlock
->
textureState
[
sampler_code
][
WINED3DTSS_TEXTURETRANSFORMFLAGS
]
&
WINED3DTTFF_PROJECTED
)
{
switch
(
sampler_type
)
{
case
WINED3DSTT_2D
:
shader_addline
(
buffer
,
"%s = texture2DProj(%s, %s);
\n
"
,
dst_str
,
sampler_str
,
coord_reg
);
break
;
case
WINED3DSTT_CUBE
:
shader_addline
(
buffer
,
"%s = textureCubeProj(%s, %s);
\n
"
,
dst_str
,
sampler_str
,
coord_reg
);
break
;
case
WINED3DSTT_VOLUME
:
shader_addline
(
buffer
,
"%s = texture3DProj(%s, %s);
\n
"
,
dst_str
,
sampler_str
,
coord_reg
);
break
;
default:
shader_addline
(
buffer
,
"%s = unrecognized_stype(%s, %s.stp);
\n
"
,
dst_str
,
sampler_str
,
coord_reg
);
FIXME
(
"Unrecognized sampler type: %#x;
\n
"
,
sampler_type
);
break
;
}
shader_glsl_sample
(
arg
,
arg
->
dst
&
WINED3DSP_REGNUM_MASK
,
dst_str
,
coord_reg
);
}
else
{
switch
(
sampler_type
)
{
case
WINED3DSTT_2D
:
shader_addline
(
buffer
,
"%s = texture2D(%s, %s.st);
\n
"
,
dst_str
,
sampler_str
,
coord_reg
);
break
;
case
WINED3DSTT_CUBE
:
shader_addline
(
buffer
,
"%s = textureCube(%s, %s.stp);
\n
"
,
dst_str
,
sampler_str
,
coord_reg
);
break
;
case
WINED3DSTT_VOLUME
:
shader_addline
(
buffer
,
"%s = texture3D(%s, %s.stp);
\n
"
,
dst_str
,
sampler_str
,
coord_reg
);
break
;
default:
shader_addline
(
buffer
,
"%s = unrecognized_stype(%s, %s.stp);
\n
"
,
dst_str
,
sampler_str
,
coord_reg
);
FIXME
(
"Unrecognized sampler type: %#x;
\n
"
,
sampler_type
);
break
;
}
shader_glsl_sample
(
arg
,
arg
->
src
[
1
]
&
WINED3DSP_REGNUM_MASK
,
dst_str
,
coord_reg
);
}
}
void
pshader_glsl_texcoord
(
SHADER_OPCODE_ARG
*
arg
)
{
...
...
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