Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
2a9af6ae
Commit
2a9af6ae
authored
Aug 08, 2022
by
Paul Gofman
Committed by
Alexandre Julliard
Aug 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3d11: Validate layout description in d3d_input_layout_create().
parent
a91cc089
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
16 deletions
+39
-16
inputlayout.c
dlls/d3d11/inputlayout.c
+39
-16
d3d11.c
dlls/d3d11/tests/d3d11.c
+0
-0
No files found.
dlls/d3d11/inputlayout.c
View file @
2a9af6ae
...
@@ -22,20 +22,27 @@
...
@@ -22,20 +22,27 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
d3d11
);
WINE_DEFAULT_DEBUG_CHANNEL
(
d3d11
);
static
struct
wined3d_shader_signature_element
*
shader_find_signature_element
(
const
struct
wined3d_shader_signature
*
s
,
static
BOOL
is_vs_sysval_semantic
(
const
struct
wined3d_shader_signature_element
*
e
)
const
char
*
semantic_name
,
unsigned
int
semantic_idx
,
unsigned
int
stream_idx
)
{
{
struct
wined3d_shader_signature_element
*
e
=
s
->
elements
;
return
!
stricmp
(
e
->
semantic_name
,
"sv_instanceid"
)
||
!
stricmp
(
e
->
semantic_name
,
"sv_vertexid"
);
}
static
unsigned
int
find_input_element
(
const
D3D11_INPUT_ELEMENT_DESC
*
element_descs
,
unsigned
int
element_count
,
struct
wined3d_shader_signature_element
*
ise
)
{
const
D3D11_INPUT_ELEMENT_DESC
*
f
;
unsigned
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
s
->
element_count
;
++
i
)
if
(
ise
->
stream_idx
)
return
element_count
;
for
(
i
=
0
;
i
<
element_count
;
++
i
)
{
{
if
(
!
stricmp
(
e
[
i
].
semantic_name
,
semantic_name
)
&&
e
[
i
].
semantic_idx
==
semantic_idx
f
=
&
element_descs
[
i
];
&&
e
[
i
].
stream_idx
==
stream_id
x
)
if
(
!
stricmp
(
ise
->
semantic_name
,
f
->
SemanticName
)
&&
ise
->
semantic_idx
==
f
->
SemanticInde
x
)
return
&
e
[
i
]
;
return
i
;
}
}
return
element_count
;
return
NULL
;
}
}
static
enum
wined3d_input_classification
wined3d_input_classification_from_d3d11
(
D3D11_INPUT_CLASSIFICATION
slot_class
)
static
enum
wined3d_input_classification
wined3d_input_classification_from_d3d11
(
D3D11_INPUT_CLASSIFICATION
slot_class
)
...
@@ -47,8 +54,10 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME
...
@@ -47,8 +54,10 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME
UINT
element_count
,
const
void
*
shader_byte_code
,
SIZE_T
shader_byte_code_length
,
UINT
element_count
,
const
void
*
shader_byte_code
,
SIZE_T
shader_byte_code_length
,
struct
wined3d_vertex_element
**
wined3d_elements
)
struct
wined3d_vertex_element
**
wined3d_elements
)
{
{
struct
wined3d_shader_signature_element
*
ise
;
struct
wined3d_shader_signature
is
;
struct
wined3d_shader_signature
is
;
unsigned
int
i
;
const
D3D11_INPUT_ELEMENT_DESC
*
f
;
unsigned
int
i
,
index
;
HRESULT
hr
;
HRESULT
hr
;
if
(
FAILED
(
hr
=
wined3d_extract_shader_input_signature_from_dxbc
(
&
is
,
shader_byte_code
,
shader_byte_code_length
)))
if
(
FAILED
(
hr
=
wined3d_extract_shader_input_signature_from_dxbc
(
&
is
,
shader_byte_code
,
shader_byte_code_length
)))
...
@@ -67,8 +76,8 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME
...
@@ -67,8 +76,8 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME
for
(
i
=
0
;
i
<
element_count
;
++
i
)
for
(
i
=
0
;
i
<
element_count
;
++
i
)
{
{
struct
wined3d_vertex_element
*
e
=
&
(
*
wined3d_elements
)[
i
];
struct
wined3d_vertex_element
*
e
=
&
(
*
wined3d_elements
)[
i
];
const
D3D11_INPUT_ELEMENT_DESC
*
f
=
&
element_descs
[
i
];
struct
wined3d_shader_signature_element
*
element
;
f
=
&
element_descs
[
i
]
;
e
->
format
=
wined3dformat_from_dxgi_format
(
f
->
Format
);
e
->
format
=
wined3dformat_from_dxgi_format
(
f
->
Format
);
e
->
input_slot
=
f
->
InputSlot
;
e
->
input_slot
=
f
->
InputSlot
;
...
@@ -79,11 +88,23 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME
...
@@ -79,11 +88,23 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME
e
->
method
=
WINED3D_DECL_METHOD_DEFAULT
;
e
->
method
=
WINED3D_DECL_METHOD_DEFAULT
;
e
->
usage
=
0
;
e
->
usage
=
0
;
e
->
usage_idx
=
0
;
e
->
usage_idx
=
0
;
}
ise
=
is
.
elements
;
if
((
element
=
shader_find_signature_element
(
&
is
,
f
->
SemanticName
,
f
->
SemanticIndex
,
0
)))
for
(
i
=
0
;
i
<
is
.
element_count
;
++
i
)
e
->
output_slot
=
element
->
register_idx
;
{
else
if
((
index
=
find_input_element
(
element_descs
,
element_count
,
&
ise
[
i
]))
<
element_count
)
WARN
(
"Unused input element %u.
\n
"
,
i
);
{
(
*
wined3d_elements
)[
index
].
output_slot
=
ise
[
i
].
register_idx
;
}
else
if
(
!
is_vs_sysval_semantic
(
&
ise
[
i
]))
{
WARN
(
"Input element %s%u not found in shader signature.
\n
"
,
ise
[
i
].
semantic_name
,
ise
[
i
].
semantic_idx
);
free
(
*
wined3d_elements
);
free
(
is
.
elements
);
return
E_INVALIDARG
;
}
}
}
free
(
is
.
elements
);
free
(
is
.
elements
);
...
@@ -367,6 +388,8 @@ HRESULT d3d_input_layout_create(struct d3d_device *device,
...
@@ -367,6 +388,8 @@ HRESULT d3d_input_layout_create(struct d3d_device *device,
struct
d3d_input_layout
*
object
;
struct
d3d_input_layout
*
object
;
HRESULT
hr
;
HRESULT
hr
;
if
(
!
element_descs
)
return
E_INVALIDARG
;
if
(
!
(
object
=
calloc
(
1
,
sizeof
(
*
object
))))
if
(
!
(
object
=
calloc
(
1
,
sizeof
(
*
object
))))
return
E_OUTOFMEMORY
;
return
E_OUTOFMEMORY
;
...
...
dlls/d3d11/tests/d3d11.c
View file @
2a9af6ae
This diff is collapsed.
Click to expand it.
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