Path: blob/master/libs/vkd3d/include/private/vkd3d_shader_utils.h
4393 views
/*1* Copyright 2023 Conor McCarthy for CodeWeavers2*3* This library is free software; you can redistribute it and/or4* modify it under the terms of the GNU Lesser General Public5* License as published by the Free Software Foundation; either6* version 2.1 of the License, or (at your option) any later version.7*8* This library is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11* Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public14* License along with this library; if not, write to the Free Software15* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA16*/1718#ifndef __VKD3D_SHADER_UTILS_H19#define __VKD3D_SHADER_UTILS_H2021#include "vkd3d_shader.h"2223static inline enum vkd3d_result vkd3d_shader_parse_dxbc_source_type(const struct vkd3d_shader_code *dxbc,24enum vkd3d_shader_source_type *type, char **messages)25{26struct vkd3d_shader_dxbc_desc desc;27enum vkd3d_result ret;28unsigned int i;2930*type = VKD3D_SHADER_SOURCE_NONE;3132if ((ret = vkd3d_shader_parse_dxbc(dxbc, 0, &desc, messages)) < 0)33return ret;3435for (i = 0; i < desc.section_count; ++i)36{37uint32_t tag = desc.sections[i].tag;38if (tag == TAG_SHDR || tag == TAG_SHEX)39{40*type = VKD3D_SHADER_SOURCE_DXBC_TPF;41}42else if (tag == TAG_DXIL)43{44*type = VKD3D_SHADER_SOURCE_DXBC_DXIL;45/* Default to DXIL if both are present. */46break;47}48}4950vkd3d_shader_free_dxbc(&desc);5152if (*type == VKD3D_SHADER_SOURCE_NONE)53return VKD3D_ERROR_INVALID_SHADER;5455return VKD3D_OK;56}5758#endif /* __VKD3D_SHADER_UTILS_H */596061