From 4728cf128671feb899961ff620504909ec5d3785 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 1 Mar 2022 13:21:32 +0100 Subject: [PATCH] include: Introduce a common macro for defining tags. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- include/private/vkd3d_common.h | 4 +++ libs/vkd3d-shader/hlsl_sm1.c | 2 +- libs/vkd3d-shader/vkd3d_shader_private.h | 35 +++++++++++------------- libs/vkd3d/vkd3d_private.h | 14 ++++------ programs/vkd3d-compiler/main.c | 5 +--- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index ac556850..ebf05216 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -42,6 +42,10 @@ #define MEMBER_SIZE(t, m) sizeof(((t *)0)->m) +#define VKD3D_MAKE_TAG(ch0, ch1, ch2, ch3) \ + ((uint32_t)(ch0) | ((uint32_t)(ch1) << 8) \ + | ((uint32_t)(ch2) << 16) | ((uint32_t)(ch3) << 24)) + static inline size_t align(size_t addr, size_t alignment) { return (addr + (alignment - 1)) & ~(alignment - 1); diff --git a/libs/vkd3d-shader/hlsl_sm1.c b/libs/vkd3d-shader/hlsl_sm1.c index 1868bb70..90ec6058 100644 --- a/libs/vkd3d-shader/hlsl_sm1.c +++ b/libs/vkd3d-shader/hlsl_sm1.c @@ -335,7 +335,7 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe sm1_sort_externs(ctx); size_offset = put_u32(buffer, 0); - ctab_offset = put_u32(buffer, MAKEFOURCC('C','T','A','B')); + ctab_offset = put_u32(buffer, VKD3D_MAKE_TAG('C','T','A','B')); ctab_start = put_u32(buffer, sizeof(D3DXSHADER_CONSTANTTABLE)); creator_offset = put_u32(buffer, 0); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 2deaa46c..60c86155 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1232,25 +1232,22 @@ static inline void *vkd3d_find_struct_(const struct vkd3d_struct *chain, #define VKD3D_DXBC_MAX_SOURCE_COUNT 6 #define VKD3D_DXBC_HEADER_SIZE (8 * sizeof(uint32_t)) -#define MAKE_TAG(ch0, ch1, ch2, ch3) \ - ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \ - ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 )) -#define TAG_AON9 MAKE_TAG('A', 'o', 'n', '9') -#define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C') -#define TAG_DXIL MAKE_TAG('D', 'X', 'I', 'L') -#define TAG_ISG1 MAKE_TAG('I', 'S', 'G', '1') -#define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N') -#define TAG_OSG1 MAKE_TAG('O', 'S', 'G', '1') -#define TAG_OSG5 MAKE_TAG('O', 'S', 'G', '5') -#define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N') -#define TAG_PCSG MAKE_TAG('P', 'C', 'S', 'G') -#define TAG_PSG1 MAKE_TAG('P', 'S', 'G', '1') -#define TAG_RD11 MAKE_TAG('R', 'D', '1', '1') -#define TAG_RDEF MAKE_TAG('R', 'D', 'E', 'F') -#define TAG_RTS0 MAKE_TAG('R', 'T', 'S', '0') -#define TAG_SHDR MAKE_TAG('S', 'H', 'D', 'R') -#define TAG_SHEX MAKE_TAG('S', 'H', 'E', 'X') -#define TAG_TEXT MAKE_TAG('T', 'E', 'X', 'T') +#define TAG_AON9 VKD3D_MAKE_TAG('A', 'o', 'n', '9') +#define TAG_DXBC VKD3D_MAKE_TAG('D', 'X', 'B', 'C') +#define TAG_DXIL VKD3D_MAKE_TAG('D', 'X', 'I', 'L') +#define TAG_ISG1 VKD3D_MAKE_TAG('I', 'S', 'G', '1') +#define TAG_ISGN VKD3D_MAKE_TAG('I', 'S', 'G', 'N') +#define TAG_OSG1 VKD3D_MAKE_TAG('O', 'S', 'G', '1') +#define TAG_OSG5 VKD3D_MAKE_TAG('O', 'S', 'G', '5') +#define TAG_OSGN VKD3D_MAKE_TAG('O', 'S', 'G', 'N') +#define TAG_PCSG VKD3D_MAKE_TAG('P', 'C', 'S', 'G') +#define TAG_PSG1 VKD3D_MAKE_TAG('P', 'S', 'G', '1') +#define TAG_RD11 VKD3D_MAKE_TAG('R', 'D', '1', '1') +#define TAG_RDEF VKD3D_MAKE_TAG('R', 'D', 'E', 'F') +#define TAG_RTS0 VKD3D_MAKE_TAG('R', 'T', 'S', '0') +#define TAG_SHDR VKD3D_MAKE_TAG('S', 'H', 'D', 'R') +#define TAG_SHEX VKD3D_MAKE_TAG('S', 'H', 'E', 'X') +#define TAG_TEXT VKD3D_MAKE_TAG('T', 'E', 'X', 'T') struct dxbc_writer_section { diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index ca7a3f22..ac0d5ce1 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -44,17 +44,15 @@ #define VK_CALL(f) (vk_procs->f) -#define MAKE_MAGIC(a,b,c,f) (((uint32_t)a) | (((uint32_t)b) << 8) | (((uint32_t)c) << 16) | f) - #define VKD3D_DESCRIPTOR_MAGIC_HAS_VIEW 0x01000000u #define VKD3D_DESCRIPTOR_MAGIC_FREE 0x00000000u -#define VKD3D_DESCRIPTOR_MAGIC_CBV MAKE_MAGIC('C', 'B', 'V', 0) -#define VKD3D_DESCRIPTOR_MAGIC_SRV MAKE_MAGIC('S', 'R', 'V', VKD3D_DESCRIPTOR_MAGIC_HAS_VIEW) -#define VKD3D_DESCRIPTOR_MAGIC_UAV MAKE_MAGIC('U', 'A', 'V', VKD3D_DESCRIPTOR_MAGIC_HAS_VIEW) -#define VKD3D_DESCRIPTOR_MAGIC_SAMPLER MAKE_MAGIC('S', 'M', 'P', VKD3D_DESCRIPTOR_MAGIC_HAS_VIEW) -#define VKD3D_DESCRIPTOR_MAGIC_DSV MAKE_MAGIC('D', 'S', 'V', 0) -#define VKD3D_DESCRIPTOR_MAGIC_RTV MAKE_MAGIC('R', 'T', 'V', 0) +#define VKD3D_DESCRIPTOR_MAGIC_CBV VKD3D_MAKE_TAG('C', 'B', 'V', 0) +#define VKD3D_DESCRIPTOR_MAGIC_SRV VKD3D_MAKE_TAG('S', 'R', 'V', 1) +#define VKD3D_DESCRIPTOR_MAGIC_UAV VKD3D_MAKE_TAG('U', 'A', 'V', 1) +#define VKD3D_DESCRIPTOR_MAGIC_SAMPLER VKD3D_MAKE_TAG('S', 'M', 'P', 1) +#define VKD3D_DESCRIPTOR_MAGIC_DSV VKD3D_MAKE_TAG('D', 'S', 'V', 0) +#define VKD3D_DESCRIPTOR_MAGIC_RTV VKD3D_MAKE_TAG('R', 'T', 'V', 0) #define VKD3D_MAX_COMPATIBLE_FORMAT_COUNT 6u #define VKD3D_MAX_QUEUE_FAMILY_COUNT 3u diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index 2f330f62..ab475617 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -50,10 +50,7 @@ enum OPTION_TEXT_FORMATTING, }; -#define MAKE_TAG(ch0, ch1, ch2, ch3) \ - ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \ - ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 )) -#define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C') +#define TAG_DXBC VKD3D_MAKE_TAG('D', 'X', 'B', 'C') static const struct source_type_info {