Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/vkd3d/include/private/vkd3d_shader_utils.h
4393 views
1
/*
2
* Copyright 2023 Conor McCarthy for CodeWeavers
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17
*/
18
19
#ifndef __VKD3D_SHADER_UTILS_H
20
#define __VKD3D_SHADER_UTILS_H
21
22
#include "vkd3d_shader.h"
23
24
static inline enum vkd3d_result vkd3d_shader_parse_dxbc_source_type(const struct vkd3d_shader_code *dxbc,
25
enum vkd3d_shader_source_type *type, char **messages)
26
{
27
struct vkd3d_shader_dxbc_desc desc;
28
enum vkd3d_result ret;
29
unsigned int i;
30
31
*type = VKD3D_SHADER_SOURCE_NONE;
32
33
if ((ret = vkd3d_shader_parse_dxbc(dxbc, 0, &desc, messages)) < 0)
34
return ret;
35
36
for (i = 0; i < desc.section_count; ++i)
37
{
38
uint32_t tag = desc.sections[i].tag;
39
if (tag == TAG_SHDR || tag == TAG_SHEX)
40
{
41
*type = VKD3D_SHADER_SOURCE_DXBC_TPF;
42
}
43
else if (tag == TAG_DXIL)
44
{
45
*type = VKD3D_SHADER_SOURCE_DXBC_DXIL;
46
/* Default to DXIL if both are present. */
47
break;
48
}
49
}
50
51
vkd3d_shader_free_dxbc(&desc);
52
53
if (*type == VKD3D_SHADER_SOURCE_NONE)
54
return VKD3D_ERROR_INVALID_SHADER;
55
56
return VKD3D_OK;
57
}
58
59
#endif /* __VKD3D_SHADER_UTILS_H */
60
61