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
6d5f562d
Commit
6d5f562d
authored
Mar 18, 2008
by
Stefan Dösinger
Committed by
Alexandre Julliard
Mar 25, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Move the shader backend selection into a separate function.
parent
a66fb40d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
30 deletions
+39
-30
directx.c
dlls/wined3d/directx.c
+17
-30
glsl_shader.c
dlls/wined3d/glsl_shader.c
+22
-0
No files found.
dlls/wined3d/directx.c
View file @
6d5f562d
...
...
@@ -2638,6 +2638,22 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface,
return
WINED3D_OK
;
}
static
const
shader_backend_t
*
select_shader_backend
(
UINT
Adapter
,
WINED3DDEVTYPE
DeviceType
)
{
const
shader_backend_t
*
ret
;
int
vs_selected_mode
;
int
ps_selected_mode
;
select_shader_mode
(
&
GLINFO_LOCATION
,
DeviceType
,
&
ps_selected_mode
,
&
vs_selected_mode
);
if
(
vs_selected_mode
==
SHADER_GLSL
||
ps_selected_mode
==
SHADER_GLSL
)
{
ret
=
&
glsl_shader_backend
;
}
else
if
(
vs_selected_mode
==
SHADER_ARB
||
ps_selected_mode
==
SHADER_ARB
)
{
ret
=
&
arb_program_shader_backend
;
}
else
{
ret
=
&
none_shader_backend
;
}
return
ret
;
}
/* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
subset of a D3DCAPS9 structure. However, it has to come via a void *
as the d3d8 interface cannot import the d3d9 header */
...
...
@@ -3221,27 +3237,6 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
return
WINED3D_OK
;
}
static
unsigned
int
glsl_program_key_hash
(
void
*
key
)
{
glsl_program_key_t
*
k
=
(
glsl_program_key_t
*
)
key
;
unsigned
int
hash
=
k
->
vshader
|
k
->
pshader
<<
16
;
hash
+=
~
(
hash
<<
15
);
hash
^=
(
hash
>>
10
);
hash
+=
(
hash
<<
3
);
hash
^=
(
hash
>>
6
);
hash
+=
~
(
hash
<<
11
);
hash
^=
(
hash
>>
16
);
return
hash
;
}
static
BOOL
glsl_program_key_compare
(
void
*
keya
,
void
*
keyb
)
{
glsl_program_key_t
*
ka
=
(
glsl_program_key_t
*
)
keya
;
glsl_program_key_t
*
kb
=
(
glsl_program_key_t
*
)
keyb
;
return
ka
->
vshader
==
kb
->
vshader
&&
ka
->
pshader
==
kb
->
pshader
;
}
/* Note due to structure differences between dx8 and dx9 D3DPRESENT_PARAMETERS,
and fields being inserted in the middle, a new structure is used in place */
static
HRESULT
WINAPI
IWineD3DImpl_CreateDevice
(
IWineD3D
*
iface
,
UINT
Adapter
,
WINED3DDEVTYPE
DeviceType
,
HWND
hFocusWindow
,
...
...
@@ -3302,15 +3297,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
object
->
devType
=
DeviceType
;
select_shader_mode
(
&
GLINFO_LOCATION
,
DeviceType
,
&
object
->
ps_selected_mode
,
&
object
->
vs_selected_mode
);
if
(
object
->
ps_selected_mode
==
SHADER_GLSL
||
object
->
vs_selected_mode
==
SHADER_GLSL
)
{
object
->
shader_backend
=
&
glsl_shader_backend
;
object
->
glsl_program_lookup
=
hash_table_create
(
&
glsl_program_key_hash
,
&
glsl_program_key_compare
);
}
else
if
(
object
->
ps_selected_mode
==
SHADER_ARB
||
object
->
vs_selected_mode
==
SHADER_ARB
)
{
object
->
shader_backend
=
&
arb_program_shader_backend
;
}
else
{
object
->
shader_backend
=
&
none_shader_backend
;
}
if
(
FAILED
(
object
->
shader_backend
->
shader_alloc_private
((
IWineD3DDevice
*
)
object
)))
{
object
->
shader_backend
=
select_shader_backend
(
Adapter
,
DeviceType
);
if
(
FAILED
(
object
->
shader_backend
->
shader_alloc_private
((
IWineD3DDevice
*
)
object
)))
{
IWineD3D_Release
(
object
->
wineD3D
);
HeapFree
(
GetProcessHeap
(),
0
,
object
);
*
ppReturnedDeviceInterface
=
NULL
;
...
...
dlls/wined3d/glsl_shader.c
View file @
6d5f562d
...
...
@@ -3346,9 +3346,31 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
This
->
baseShader
.
is_compiled
=
FALSE
;
}
static
unsigned
int
glsl_program_key_hash
(
void
*
key
)
{
glsl_program_key_t
*
k
=
(
glsl_program_key_t
*
)
key
;
unsigned
int
hash
=
k
->
vshader
|
k
->
pshader
<<
16
;
hash
+=
~
(
hash
<<
15
);
hash
^=
(
hash
>>
10
);
hash
+=
(
hash
<<
3
);
hash
^=
(
hash
>>
6
);
hash
+=
~
(
hash
<<
11
);
hash
^=
(
hash
>>
16
);
return
hash
;
}
static
BOOL
glsl_program_key_compare
(
void
*
keya
,
void
*
keyb
)
{
glsl_program_key_t
*
ka
=
(
glsl_program_key_t
*
)
keya
;
glsl_program_key_t
*
kb
=
(
glsl_program_key_t
*
)
keyb
;
return
ka
->
vshader
==
kb
->
vshader
&&
ka
->
pshader
==
kb
->
pshader
;
}
static
HRESULT
shader_glsl_alloc
(
IWineD3DDevice
*
iface
)
{
IWineD3DDeviceImpl
*
This
=
(
IWineD3DDeviceImpl
*
)
iface
;
This
->
shader_priv
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
struct
shader_glsl_priv
));
This
->
glsl_program_lookup
=
hash_table_create
(
&
glsl_program_key_hash
,
&
glsl_program_key_compare
);
return
WINED3D_OK
;
}
...
...
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