Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
vkd3d
Manage
Activity
Members
Labels
Plan
Wiki
Bugzilla
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wine
vkd3d
Commits
9d944ad9
Commit
9d944ad9
authored
7 years ago
by
Józef Kucia
Browse files
Options
Downloads
Patches
Plain Diff
libs/vkd3d-shader: Store info about SPIR-V built-ins in table.
parent
e5a4ad33
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libs/vkd3d-shader/spirv.c
+75
-85
75 additions, 85 deletions
libs/vkd3d-shader/spirv.c
with
75 additions
and
85 deletions
libs/vkd3d-shader/spirv.c
+
75
−
85
View file @
9d944ad9
...
...
@@ -1875,70 +1875,84 @@ static void vkd3d_dxbc_compiler_emit_store_dst(struct vkd3d_dxbc_compiler *compi
vkd3d_dxbc_compiler_emit_store_reg
(
compiler
,
&
dst
->
reg
,
dst
->
write_mask
,
val_id
);
}
static
enum
vkd3d_component_type
vkd3d_component_type_for_register
(
enum
vkd3d_shader_register_type
reg_type
,
/* The Vulkan spec says:
*
* "The variable decorated with GlobalInvocationId must be declared as a
* three-component vector of 32-bit integers."
*
* "The variable decorated with LocalInvocationId must be declared as a
* three-component vector of 32-bit integers."
*
* "The variable decorated with FragCoord must be declared as a
* four-component vector of 32-bit floating-point values."
*
* "Any variable decorated with Position must be declared as a four-component
* vector of 32-bit floating-point values."
*
* "The variable decorated with VertexIndex must be declared as a scalar
* 32-bit integer."
*/
static
const
struct
vkd3d_spirv_builtin
{
enum
vkd3d_shader_input_sysval_semantic
sysval
;
enum
vkd3d_shader_register_type
reg_type
;
enum
vkd3d_component_type
component_type
;
unsigned
int
component_count
;
SpvBuiltIn
spirv_builtin
;
}
vkd3d_spirv_builtins
[]
=
{
{
VKD3D_SIV_NONE
,
VKD3DSPR_THREADID
,
VKD3D_TYPE_INT
,
3
,
SpvBuiltInGlobalInvocationId
},
{
VKD3D_SIV_NONE
,
VKD3DSPR_LOCALTHREADID
,
VKD3D_TYPE_INT
,
3
,
SpvBuiltInLocalInvocationId
},
{
VKD3D_SIV_NONE
,
VKD3DSPR_LOCALTHREADINDEX
,
VKD3D_TYPE_INT
,
1
,
SpvBuiltInLocalInvocationIndex
},
{
VKD3D_SIV_POSITION
,
~
0u
,
VKD3D_TYPE_FLOAT
,
4
,
SpvBuiltInPosition
},
{
VKD3D_SIV_VERTEX_ID
,
~
0u
,
VKD3D_TYPE_INT
,
1
,
SpvBuiltInVertexIndex
},
};
static
const
struct
vkd3d_spirv_builtin
*
vkd3d_get_spirv_builtin
(
enum
vkd3d_shader_register_type
reg_type
,
enum
vkd3d_shader_input_sysval_semantic
sysval
)
{
if
(
reg_type
==
VKD3DSPR_THREADID
||
reg_type
==
VKD3DSPR_LOCALTHREADID
||
reg_type
==
VKD3DSPR_LOCALTHREADINDEX
)
return
VKD3D_TYPE_INT
;
unsigned
int
i
;
switch
(
sysval
)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
vkd3d_spirv_builtins
);
++
i
)
{
case
VKD3D_SIV_NONE
:
case
VKD3D_SIV_POSITION
:
return
VKD3D_TYPE_FLOAT
;
case
VKD3D_SIV_VERTEX_ID
:
return
VKD3D_TYPE_INT
;
default:
FIXME
(
"Unhandled builtin (register type %#x, semantic %#x).
\n
"
,
reg_type
,
sysval
);
return
VKD3D_TYPE_FLOAT
;
const
struct
vkd3d_spirv_builtin
*
current
=
&
vkd3d_spirv_builtins
[
i
];
if
(
current
->
sysval
==
VKD3D_SIV_NONE
&&
current
->
reg_type
==
reg_type
)
return
current
;
if
(
current
->
reg_type
==
~
0u
&&
current
->
sysval
==
sysval
)
return
current
;
}
if
(
sysval
!=
VKD3D_SIV_NONE
||
(
reg_type
!=
VKD3DSPR_INPUT
&&
reg_type
!=
VKD3DSPR_OUTPUT
&&
reg_type
!=
VKD3DSPR_COLOROUT
))
FIXME
(
"Unhandled builtin (register type %#x, semantic %#x).
\n
"
,
reg_type
,
sysval
);
return
NULL
;
}
static
enum
vkd3d_component_type
vkd3d_component_type_for_register
(
enum
vkd3d_shader_register_type
reg_type
,
enum
vkd3d_shader_input_sysval_semantic
sysval
)
{
const
struct
vkd3d_spirv_builtin
*
builtin
;
if
((
builtin
=
vkd3d_get_spirv_builtin
(
reg_type
,
sysval
)))
return
builtin
->
component_type
;
return
VKD3D_TYPE_FLOAT
;
}
static
unsigned
int
vkd3d_component_count_for_register
(
enum
vkd3d_shader_register_type
reg_type
,
enum
vkd3d_shader_input_sysval_semantic
sysval
)
{
/* The Vulkan spec says:
*
* "The variable decorated with GlobalInvocationId must be declared as a
* three-component vector of 32-bit integers."
*
* "The variable decorated with LocalInvocationId must be declared as a
* three-component vector of 32-bit integers."
*/
if
(
reg_type
==
VKD3DSPR_THREADID
||
reg_type
==
VKD3DSPR_LOCALTHREADID
)
return
3
;
if
(
reg_type
==
VKD3DSPR_LOCALTHREADINDEX
)
return
1
;
switch
(
sysval
)
{
case
VKD3D_SIV_NONE
:
return
0
;
case
VKD3D_SIV_POSITION
:
/* The Vulkan spec says:
*
* "The variable decorated with FragCoord must be declared as a
* four-component vector of 32-bit floating-point values."
*
* "Any variable decorated with Position must be declared as a
* four-component vector of 32-bit floating-point values."
*/
return
4
;
case
VKD3D_SIV_VERTEX_ID
:
/* The Vulkan spec says:
*
* "The variable decorated with VertexIndex must be declared as a
* scalar 32-bit integer."
*/
return
1
;
default:
FIXME
(
"Unhandled builtin (register type %#x, semantic %#x).
\n
"
,
reg_type
,
sysval
);
return
0
;
}
const
struct
vkd3d_spirv_builtin
*
builtin
;
if
((
builtin
=
vkd3d_get_spirv_builtin
(
reg_type
,
sysval
)))
return
builtin
->
component_count
;
return
0
;
}
static
void
vkd3d_dxbc_compiler_decorate_builtin
(
struct
vkd3d_dxbc_compiler
*
compiler
,
...
...
@@ -1946,39 +1960,15 @@ static void vkd3d_dxbc_compiler_decorate_builtin(struct vkd3d_dxbc_compiler *com
enum
vkd3d_shader_input_sysval_semantic
sysval
)
{
struct
vkd3d_spirv_builder
*
builder
=
&
compiler
->
spirv_builder
;
const
struct
vkd3d_spirv_builtin
*
builtin_info
;
SpvBuiltIn
builtin
;
switch
(
sysval
)
{
case
VKD3D_SIV_POSITION
:
if
(
compiler
->
shader_type
==
VKD3D_SHADER_TYPE_PIXEL
)
builtin
=
SpvBuiltInFragCoord
;
else
builtin
=
SpvBuiltInPosition
;
break
;
case
VKD3D_SIV_VERTEX_ID
:
builtin
=
SpvBuiltInVertexIndex
;
break
;
default:
if
(
reg_type
==
VKD3DSPR_THREADID
)
{
builtin
=
SpvBuiltInGlobalInvocationId
;
}
else
if
(
reg_type
==
VKD3DSPR_LOCALTHREADID
)
{
builtin
=
SpvBuiltInLocalInvocationId
;
}
else
if
(
reg_type
==
VKD3DSPR_LOCALTHREADINDEX
)
{
builtin
=
SpvBuiltInLocalInvocationIndex
;
}
else
{
FIXME
(
"Unhandled builtin (register type %#x, semantic %#x).
\n
"
,
reg_type
,
sysval
);
return
;
}
break
;
}
if
(
!
(
builtin_info
=
vkd3d_get_spirv_builtin
(
reg_type
,
sysval
)))
return
;
builtin
=
builtin_info
->
spirv_builtin
;
if
(
compiler
->
shader_type
==
VKD3D_SHADER_TYPE_PIXEL
&&
builtin
==
SpvBuiltInPosition
)
builtin
=
SpvBuiltInFragCoord
;
vkd3d_spirv_build_op_decorate1
(
builder
,
target_id
,
SpvDecorationBuiltIn
,
builtin
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment