Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- This fixes arithmetic-int.shader_test on 32-bit Linux for me.
libs/vkd3d-shader/hlsl.l | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index 267c8c30..2c398bc8 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -31,6 +31,38 @@ static void update_location(struct hlsl_ctx *ctx, YYLTYPE *loc);
#define YY_USER_ACTION update_location(yyget_extra(yyscanner), yyget_lloc(yyscanner));
+static int char_to_int(char c) +{ + if ('0' <= c && c <= '9') + return c - '0'; + if ('A' <= c && c <= 'F') + return c - 'A' + 10; + if ('a' <= c && c <= 'f') + return c - 'a' + 10; + return -1; +} + +static uint32_t parse_integer(const char *s) +{ + uint32_t base = 10, ret = 0; + int digit; + + if (*s == '0') + { + base = 8; + ++s; + if (*s == 'x' || *s == 'X') + { + base = 16; + ++s; + } + } + + while ((digit = char_to_int(*s++)) >= 0) + ret = ret * base + (uint32_t)digit; + return ret; +} + %}
%option bison-bridge @@ -197,15 +229,15 @@ row_major {return KW_ROW_MAJOR; } return C_FLOAT; } 0x[0-9a-fA-F]+ { - sscanf(yytext, "0x%x", &yylval->intval); + yylval->intval = parse_integer(yytext); return C_INTEGER; } 0[0-7]+ { - sscanf(yytext, "0%o", &yylval->intval); + yylval->intval = parse_integer(yytext); return C_INTEGER; } [0-9]+ { - yylval->intval = (atoi(yytext)); + yylval->intval = parse_integer(yytext); return C_INTEGER; }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- include/private/vkd3d_memory.h | 26 +++----------------------- libs/vkd3d-common/memory.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/include/private/vkd3d_memory.h b/include/private/vkd3d_memory.h index 8a2edb10..fbfee9f5 100644 --- a/include/private/vkd3d_memory.h +++ b/include/private/vkd3d_memory.h @@ -26,29 +26,9 @@
#include "vkd3d_debug.h"
-static inline void *vkd3d_malloc(size_t size) -{ - void *ptr; - if (!(ptr = malloc(size))) - ERR("Out of memory.\n"); - return ptr; -} - -static inline void *vkd3d_realloc(void *ptr, size_t size) -{ - if (!(ptr = realloc(ptr, size))) - ERR("Out of memory, size %zu.\n", size); - return ptr; -} - -static inline void *vkd3d_calloc(size_t count, size_t size) -{ - void *ptr; - assert(count <= ~(size_t)0 / size); - if (!(ptr = calloc(count, size))) - ERR("Out of memory.\n"); - return ptr; -} +void *vkd3d_malloc(size_t size); +void *vkd3d_realloc(void *ptr, size_t size); +void *vkd3d_calloc(size_t count, size_t size);
static inline void vkd3d_free(void *ptr) { diff --git a/libs/vkd3d-common/memory.c b/libs/vkd3d-common/memory.c index 2bf8947e..f46f180c 100644 --- a/libs/vkd3d-common/memory.c +++ b/libs/vkd3d-common/memory.c @@ -19,6 +19,30 @@
#include "vkd3d_memory.h"
+void *vkd3d_malloc(size_t size) +{ + void *ptr; + if (!(ptr = malloc(size))) + ERR("Out of memory.\n"); + return ptr; +} + +void *vkd3d_realloc(void *ptr, size_t size) +{ + if (!(ptr = realloc(ptr, size))) + ERR("Out of memory, size %zu.\n", size); + return ptr; +} + +void *vkd3d_calloc(size_t count, size_t size) +{ + void *ptr; + assert(count <= ~(size_t)0 / size); + if (!(ptr = calloc(count, size))) + ERR("Out of memory.\n"); + return ptr; +} + bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size) { size_t new_capacity, max_capacity;
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 10/05/22 20:21, Matteo Bruni ha scritto:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
include/private/vkd3d_memory.h | 26 +++----------------------- libs/vkd3d-common/memory.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/include/private/vkd3d_memory.h b/include/private/vkd3d_memory.h index 8a2edb10..fbfee9f5 100644 --- a/include/private/vkd3d_memory.h +++ b/include/private/vkd3d_memory.h @@ -26,29 +26,9 @@
#include "vkd3d_debug.h"
-static inline void *vkd3d_malloc(size_t size) -{
- void *ptr;
- if (!(ptr = malloc(size)))
ERR("Out of memory.\n");
- return ptr;
-}
-static inline void *vkd3d_realloc(void *ptr, size_t size) -{
- if (!(ptr = realloc(ptr, size)))
ERR("Out of memory, size %zu.\n", size);
- return ptr;
-}
-static inline void *vkd3d_calloc(size_t count, size_t size) -{
- void *ptr;
- assert(count <= ~(size_t)0 / size);
- if (!(ptr = calloc(count, size)))
ERR("Out of memory.\n");
- return ptr;
-} +void *vkd3d_malloc(size_t size); +void *vkd3d_realloc(void *ptr, size_t size); +void *vkd3d_calloc(size_t count, size_t size);
static inline void vkd3d_free(void *ptr) { diff --git a/libs/vkd3d-common/memory.c b/libs/vkd3d-common/memory.c index 2bf8947e..f46f180c 100644 --- a/libs/vkd3d-common/memory.c +++ b/libs/vkd3d-common/memory.c @@ -19,6 +19,30 @@
#include "vkd3d_memory.h"
+void *vkd3d_malloc(size_t size) +{
- void *ptr;
- if (!(ptr = malloc(size)))
ERR("Out of memory.\n");
- return ptr;
+}
+void *vkd3d_realloc(void *ptr, size_t size) +{
- if (!(ptr = realloc(ptr, size)))
ERR("Out of memory, size %zu.\n", size);
- return ptr;
+}
+void *vkd3d_calloc(size_t count, size_t size) +{
- void *ptr;
- assert(count <= ~(size_t)0 / size);
- if (!(ptr = calloc(count, size)))
ERR("Out of memory.\n");
- return ptr;
+}
- bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size) { size_t new_capacity, max_capacity;
On Tue, 10 May 2022 at 20:21, Matteo Bruni mbruni@codeweavers.com wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
include/private/vkd3d_memory.h | 26 +++----------------------- libs/vkd3d-common/memory.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-)
Why do we want this?
Hi,
Il 12/05/22 15:56, Henri Verbeet ha scritto:
On Tue, 10 May 2022 at 20:21, Matteo Bruni mbruni@codeweavers.com wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
include/private/vkd3d_memory.h | 26 +++----------------------- libs/vkd3d-common/memory.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-)
Why do we want this?
My interpretation is that we want it to enable 6/6, moving all the FIXME() and friends in the .c's instead of .h's (where it is not well defined which channel should be used).
Giovanni.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/spirv.c | 55 +++++++++++++++++++++++ libs/vkd3d-shader/vkd3d_shader_private.h | 57 ------------------------ 2 files changed, 55 insertions(+), 57 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index d746a35a..89b16305 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -168,6 +168,61 @@ static void vkd3d_spirv_validate(const struct vkd3d_shader_code *spirv,
#endif /* HAVE_SPIRV_TOOLS */
+static enum vkd3d_shader_component_type vkd3d_component_type_from_data_type(enum vkd3d_data_type data_type) +{ + switch (data_type) + { + case VKD3D_DATA_FLOAT: + case VKD3D_DATA_UNORM: + case VKD3D_DATA_SNORM: + return VKD3D_SHADER_COMPONENT_FLOAT; + case VKD3D_DATA_UINT: + return VKD3D_SHADER_COMPONENT_UINT; + case VKD3D_DATA_INT: + return VKD3D_SHADER_COMPONENT_INT; + case VKD3D_DATA_DOUBLE: + return VKD3D_SHADER_COMPONENT_DOUBLE; + default: + FIXME("Unhandled data type %#x.\n", data_type); + /* fall-through */ + case VKD3D_DATA_MIXED: + return VKD3D_SHADER_COMPONENT_UINT; + } +} + +static enum vkd3d_data_type vkd3d_data_type_from_component_type(enum vkd3d_shader_component_type component_type) +{ + switch (component_type) + { + case VKD3D_SHADER_COMPONENT_FLOAT: + return VKD3D_DATA_FLOAT; + case VKD3D_SHADER_COMPONENT_UINT: + return VKD3D_DATA_UINT; + case VKD3D_SHADER_COMPONENT_INT: + return VKD3D_DATA_INT; + case VKD3D_SHADER_COMPONENT_DOUBLE: + return VKD3D_DATA_DOUBLE; + default: + FIXME("Unhandled component type %#x.\n", component_type); + return VKD3D_DATA_FLOAT; + } +} + +static unsigned int vkd3d_write_mask_get_component_idx(DWORD write_mask) +{ + unsigned int i; + + assert(write_mask); + for (i = 0; i < VKD3D_VEC4_SIZE; ++i) + { + if (write_mask & (VKD3DSP_WRITEMASK_0 << i)) + return i; + } + + FIXME("Invalid write mask %#x.\n", write_mask); + return 0; +} + static enum vkd3d_shader_input_sysval_semantic vkd3d_siv_from_sysval_indexed(enum vkd3d_shader_sysval_semantic sysval, unsigned int index) { diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 29e178cc..5d3c3e49 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1102,63 +1102,6 @@ int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info, int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
-static inline enum vkd3d_shader_component_type vkd3d_component_type_from_data_type( - enum vkd3d_data_type data_type) -{ - switch (data_type) - { - case VKD3D_DATA_FLOAT: - case VKD3D_DATA_UNORM: - case VKD3D_DATA_SNORM: - return VKD3D_SHADER_COMPONENT_FLOAT; - case VKD3D_DATA_UINT: - return VKD3D_SHADER_COMPONENT_UINT; - case VKD3D_DATA_INT: - return VKD3D_SHADER_COMPONENT_INT; - case VKD3D_DATA_DOUBLE: - return VKD3D_SHADER_COMPONENT_DOUBLE; - default: - FIXME("Unhandled data type %#x.\n", data_type); - /* fall-through */ - case VKD3D_DATA_MIXED: - return VKD3D_SHADER_COMPONENT_UINT; - } -} - -static inline enum vkd3d_data_type vkd3d_data_type_from_component_type( - enum vkd3d_shader_component_type component_type) -{ - switch (component_type) - { - case VKD3D_SHADER_COMPONENT_FLOAT: - return VKD3D_DATA_FLOAT; - case VKD3D_SHADER_COMPONENT_UINT: - return VKD3D_DATA_UINT; - case VKD3D_SHADER_COMPONENT_INT: - return VKD3D_DATA_INT; - case VKD3D_SHADER_COMPONENT_DOUBLE: - return VKD3D_DATA_DOUBLE; - default: - FIXME("Unhandled component type %#x.\n", component_type); - return VKD3D_DATA_FLOAT; - } -} - -static inline unsigned int vkd3d_write_mask_get_component_idx(DWORD write_mask) -{ - unsigned int i; - - assert(write_mask); - for (i = 0; i < VKD3D_VEC4_SIZE; ++i) - { - if (write_mask & (VKD3DSP_WRITEMASK_0 << i)) - return i; - } - - FIXME("Invalid write mask %#x.\n", write_mask); - return 0; -} - static inline unsigned int vkd3d_write_mask_component_count(DWORD write_mask) { unsigned int count = vkd3d_popcount(write_mask & VKD3DSP_WRITEMASK_ALL);
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 10/05/22 20:21, Matteo Bruni ha scritto:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
libs/vkd3d-shader/spirv.c | 55 +++++++++++++++++++++++ libs/vkd3d-shader/vkd3d_shader_private.h | 57 ------------------------ 2 files changed, 55 insertions(+), 57 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index d746a35a..89b16305 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -168,6 +168,61 @@ static void vkd3d_spirv_validate(const struct vkd3d_shader_code *spirv,
#endif /* HAVE_SPIRV_TOOLS */
+static enum vkd3d_shader_component_type vkd3d_component_type_from_data_type(enum vkd3d_data_type data_type) +{
- switch (data_type)
- {
case VKD3D_DATA_FLOAT:
case VKD3D_DATA_UNORM:
case VKD3D_DATA_SNORM:
return VKD3D_SHADER_COMPONENT_FLOAT;
case VKD3D_DATA_UINT:
return VKD3D_SHADER_COMPONENT_UINT;
case VKD3D_DATA_INT:
return VKD3D_SHADER_COMPONENT_INT;
case VKD3D_DATA_DOUBLE:
return VKD3D_SHADER_COMPONENT_DOUBLE;
default:
FIXME("Unhandled data type %#x.\n", data_type);
/* fall-through */
case VKD3D_DATA_MIXED:
return VKD3D_SHADER_COMPONENT_UINT;
- }
+}
+static enum vkd3d_data_type vkd3d_data_type_from_component_type(enum vkd3d_shader_component_type component_type) +{
- switch (component_type)
- {
case VKD3D_SHADER_COMPONENT_FLOAT:
return VKD3D_DATA_FLOAT;
case VKD3D_SHADER_COMPONENT_UINT:
return VKD3D_DATA_UINT;
case VKD3D_SHADER_COMPONENT_INT:
return VKD3D_DATA_INT;
case VKD3D_SHADER_COMPONENT_DOUBLE:
return VKD3D_DATA_DOUBLE;
default:
FIXME("Unhandled component type %#x.\n", component_type);
return VKD3D_DATA_FLOAT;
- }
+}
+static unsigned int vkd3d_write_mask_get_component_idx(DWORD write_mask) +{
- unsigned int i;
- assert(write_mask);
- for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
- {
if (write_mask & (VKD3DSP_WRITEMASK_0 << i))
return i;
- }
- FIXME("Invalid write mask %#x.\n", write_mask);
- return 0;
+}
- static enum vkd3d_shader_input_sysval_semantic vkd3d_siv_from_sysval_indexed(enum vkd3d_shader_sysval_semantic sysval, unsigned int index) {
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 29e178cc..5d3c3e49 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1102,63 +1102,6 @@ int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info, int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
-static inline enum vkd3d_shader_component_type vkd3d_component_type_from_data_type(
enum vkd3d_data_type data_type)
-{
- switch (data_type)
- {
case VKD3D_DATA_FLOAT:
case VKD3D_DATA_UNORM:
case VKD3D_DATA_SNORM:
return VKD3D_SHADER_COMPONENT_FLOAT;
case VKD3D_DATA_UINT:
return VKD3D_SHADER_COMPONENT_UINT;
case VKD3D_DATA_INT:
return VKD3D_SHADER_COMPONENT_INT;
case VKD3D_DATA_DOUBLE:
return VKD3D_SHADER_COMPONENT_DOUBLE;
default:
FIXME("Unhandled data type %#x.\n", data_type);
/* fall-through */
case VKD3D_DATA_MIXED:
return VKD3D_SHADER_COMPONENT_UINT;
- }
-}
-static inline enum vkd3d_data_type vkd3d_data_type_from_component_type(
enum vkd3d_shader_component_type component_type)
-{
- switch (component_type)
- {
case VKD3D_SHADER_COMPONENT_FLOAT:
return VKD3D_DATA_FLOAT;
case VKD3D_SHADER_COMPONENT_UINT:
return VKD3D_DATA_UINT;
case VKD3D_SHADER_COMPONENT_INT:
return VKD3D_DATA_INT;
case VKD3D_SHADER_COMPONENT_DOUBLE:
return VKD3D_DATA_DOUBLE;
default:
FIXME("Unhandled component type %#x.\n", component_type);
return VKD3D_DATA_FLOAT;
- }
-}
-static inline unsigned int vkd3d_write_mask_get_component_idx(DWORD write_mask) -{
- unsigned int i;
- assert(write_mask);
- for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
- {
if (write_mask & (VKD3DSP_WRITEMASK_0 << i))
return i;
- }
- FIXME("Invalid write mask %#x.\n", write_mask);
- return 0;
-}
- static inline unsigned int vkd3d_write_mask_component_count(DWORD write_mask) { unsigned int count = vkd3d_popcount(write_mask & VKD3DSP_WRITEMASK_ALL);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d/utils.c | 6 ++++++ libs/vkd3d/vkd3d_private.h | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index 5f67c8b9..824e9e44 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -740,6 +740,12 @@ const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags) return vkd3d_dbg_sprintf("%s", &buffer[3]); }
+void debug_ignored_node_mask(unsigned int mask) +{ + if (mask && mask != 1) + FIXME("Ignoring node mask 0x%08x.\n", mask); +} + HRESULT hresult_from_errno(int rc) { switch (rc) diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 4e03145d..ad644682 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -1627,11 +1627,7 @@ const char *debug_vk_memory_heap_flags(VkMemoryHeapFlags flags); const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags); const char *debug_vk_queue_flags(VkQueueFlags flags);
-static inline void debug_ignored_node_mask(unsigned int mask) -{ - if (mask && mask != 1) - FIXME("Ignoring node mask 0x%08x.\n", mask); -} +void debug_ignored_node_mask(unsigned int mask);
HRESULT vkd3d_load_vk_global_procs(struct vkd3d_vk_global_procs *procs, PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr);
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 10/05/22 20:21, Matteo Bruni ha scritto:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
libs/vkd3d/utils.c | 6 ++++++ libs/vkd3d/vkd3d_private.h | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index 5f67c8b9..824e9e44 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -740,6 +740,12 @@ const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags) return vkd3d_dbg_sprintf("%s", &buffer[3]); }
+void debug_ignored_node_mask(unsigned int mask) +{
- if (mask && mask != 1)
FIXME("Ignoring node mask 0x%08x.\n", mask);
+}
- HRESULT hresult_from_errno(int rc) { switch (rc)
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 4e03145d..ad644682 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -1627,11 +1627,7 @@ const char *debug_vk_memory_heap_flags(VkMemoryHeapFlags flags); const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags); const char *debug_vk_queue_flags(VkQueueFlags flags);
-static inline void debug_ignored_node_mask(unsigned int mask) -{
- if (mask && mask != 1)
FIXME("Ignoring node mask 0x%08x.\n", mask);
-} +void debug_ignored_node_mask(unsigned int mask);
HRESULT vkd3d_load_vk_global_procs(struct vkd3d_vk_global_procs *procs, PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d/utils.c | 32 ++++++++++++++++++++++++++++++++ libs/vkd3d/vkd3d_private.h | 34 +++------------------------------- 2 files changed, 35 insertions(+), 31 deletions(-)
diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index 824e9e44..8169b14b 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -893,6 +893,38 @@ bool vkd3d_get_program_name(char program_name[PATH_MAX])
#endif /* HAVE_DECL_PROGRAM_INVOCATION_NAME */
+void vkd3d_private_data_destroy(struct vkd3d_private_data *data) +{ + if (data->is_object) + IUnknown_Release(data->u.object); + list_remove(&data->entry); + vkd3d_free(data); +} + +HRESULT vkd3d_private_store_init(struct vkd3d_private_store *store) +{ + int rc; + + list_init(&store->content); + + if ((rc = vkd3d_mutex_init(&store->mutex))) + ERR("Failed to initialize mutex, error %d.\n", rc); + + return hresult_from_errno(rc); +} + +void vkd3d_private_store_destroy(struct vkd3d_private_store *store) +{ + struct vkd3d_private_data *data, *cursor; + + LIST_FOR_EACH_ENTRY_SAFE(data, cursor, &store->content, struct vkd3d_private_data, entry) + { + vkd3d_private_data_destroy(data); + } + + vkd3d_mutex_destroy(&store->mutex); +} + static struct vkd3d_private_data *vkd3d_private_store_get_private_data( const struct vkd3d_private_store *store, const GUID *tag) { diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index ad644682..c1dfccb8 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -462,37 +462,9 @@ struct vkd3d_private_data } u; };
-static inline void vkd3d_private_data_destroy(struct vkd3d_private_data *data) -{ - if (data->is_object) - IUnknown_Release(data->u.object); - list_remove(&data->entry); - vkd3d_free(data); -} - -static inline HRESULT vkd3d_private_store_init(struct vkd3d_private_store *store) -{ - int rc; - - list_init(&store->content); - - if ((rc = vkd3d_mutex_init(&store->mutex))) - ERR("Failed to initialize mutex, error %d.\n", rc); - - return hresult_from_errno(rc); -} - -static inline void vkd3d_private_store_destroy(struct vkd3d_private_store *store) -{ - struct vkd3d_private_data *data, *cursor; - - LIST_FOR_EACH_ENTRY_SAFE(data, cursor, &store->content, struct vkd3d_private_data, entry) - { - vkd3d_private_data_destroy(data); - } - - vkd3d_mutex_destroy(&store->mutex); -} +void vkd3d_private_data_destroy(struct vkd3d_private_data *data); +HRESULT vkd3d_private_store_init(struct vkd3d_private_store *store); +void vkd3d_private_store_destroy(struct vkd3d_private_store *store);
HRESULT vkd3d_get_private_data(struct vkd3d_private_store *store, const GUID *tag, unsigned int *out_size, void *out); HRESULT vkd3d_set_private_data(struct vkd3d_private_store *store,
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 10/05/22 20:21, Matteo Bruni ha scritto:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
libs/vkd3d/utils.c | 32 ++++++++++++++++++++++++++++++++ libs/vkd3d/vkd3d_private.h | 34 +++------------------------------- 2 files changed, 35 insertions(+), 31 deletions(-)
diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index 824e9e44..8169b14b 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -893,6 +893,38 @@ bool vkd3d_get_program_name(char program_name[PATH_MAX])
#endif /* HAVE_DECL_PROGRAM_INVOCATION_NAME */
+void vkd3d_private_data_destroy(struct vkd3d_private_data *data) +{
- if (data->is_object)
IUnknown_Release(data->u.object);
- list_remove(&data->entry);
- vkd3d_free(data);
+}
+HRESULT vkd3d_private_store_init(struct vkd3d_private_store *store) +{
- int rc;
- list_init(&store->content);
- if ((rc = vkd3d_mutex_init(&store->mutex)))
ERR("Failed to initialize mutex, error %d.\n", rc);
- return hresult_from_errno(rc);
+}
+void vkd3d_private_store_destroy(struct vkd3d_private_store *store) +{
- struct vkd3d_private_data *data, *cursor;
- LIST_FOR_EACH_ENTRY_SAFE(data, cursor, &store->content, struct vkd3d_private_data, entry)
- {
vkd3d_private_data_destroy(data);
- }
- vkd3d_mutex_destroy(&store->mutex);
+}
- static struct vkd3d_private_data *vkd3d_private_store_get_private_data( const struct vkd3d_private_store *store, const GUID *tag) {
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index ad644682..c1dfccb8 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -462,37 +462,9 @@ struct vkd3d_private_data } u; };
-static inline void vkd3d_private_data_destroy(struct vkd3d_private_data *data) -{
- if (data->is_object)
IUnknown_Release(data->u.object);
- list_remove(&data->entry);
- vkd3d_free(data);
-}
-static inline HRESULT vkd3d_private_store_init(struct vkd3d_private_store *store) -{
- int rc;
- list_init(&store->content);
- if ((rc = vkd3d_mutex_init(&store->mutex)))
ERR("Failed to initialize mutex, error %d.\n", rc);
- return hresult_from_errno(rc);
-}
-static inline void vkd3d_private_store_destroy(struct vkd3d_private_store *store) -{
- struct vkd3d_private_data *data, *cursor;
- LIST_FOR_EACH_ENTRY_SAFE(data, cursor, &store->content, struct vkd3d_private_data, entry)
- {
vkd3d_private_data_destroy(data);
- }
- vkd3d_mutex_destroy(&store->mutex);
-} +void vkd3d_private_data_destroy(struct vkd3d_private_data *data); +HRESULT vkd3d_private_store_init(struct vkd3d_private_store *store); +void vkd3d_private_store_destroy(struct vkd3d_private_store *store);
HRESULT vkd3d_get_private_data(struct vkd3d_private_store *store, const GUID *tag, unsigned int *out_size, void *out); HRESULT vkd3d_set_private_data(struct vkd3d_private_store *store,
Mostly so that the debug primitives don't depend on a shared variable.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- This allows to keep using a separate debug env var for vkd3d-shader even when building vkd3d as static lib(s). That will eventually make it possible to drop the related change in the vkd3d copy imported into Wine.
include/private/vkd3d_debug.h | 32 +++++++++++++++++---------- libs/vkd3d-common/blob.c | 2 ++ libs/vkd3d-common/debug.c | 23 +++++++++---------- libs/vkd3d-common/error.c | 2 ++ libs/vkd3d-common/memory.c | 2 ++ libs/vkd3d-shader/d3dbc.c | 2 ++ libs/vkd3d-shader/dxbc.c | 2 ++ libs/vkd3d-shader/hlsl.c | 2 ++ libs/vkd3d-shader/hlsl.l | 2 ++ libs/vkd3d-shader/hlsl.y | 2 ++ libs/vkd3d-shader/hlsl_codegen.c | 2 ++ libs/vkd3d-shader/hlsl_constant_ops.c | 2 ++ libs/vkd3d-shader/hlsl_sm1.c | 2 ++ libs/vkd3d-shader/hlsl_sm4.c | 2 ++ libs/vkd3d-shader/preproc.l | 2 ++ libs/vkd3d-shader/preproc.y | 2 ++ libs/vkd3d-shader/spirv.c | 2 ++ libs/vkd3d-shader/trace.c | 2 ++ libs/vkd3d-shader/vkd3d_shader_main.c | 2 +- libs/vkd3d/command.c | 2 ++ libs/vkd3d/device.c | 2 ++ libs/vkd3d/resource.c | 2 ++ libs/vkd3d/state.c | 2 ++ libs/vkd3d/utils.c | 2 ++ 24 files changed, 73 insertions(+), 26 deletions(-)
diff --git a/include/private/vkd3d_debug.h b/include/private/vkd3d_debug.h index 8ab653ae..bc3bf5c9 100644 --- a/include/private/vkd3d_debug.h +++ b/include/private/vkd3d_debug.h @@ -44,9 +44,15 @@ enum vkd3d_dbg_level VKD3D_DBG_LEVEL_TRACE, };
-enum vkd3d_dbg_level vkd3d_dbg_get_level(void); +struct vkd3d_debug_channel +{ + const char name[64]; + enum vkd3d_dbg_level level; +}; + +enum vkd3d_dbg_level vkd3d_dbg_get_level(struct vkd3d_debug_channel *channel);
-void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4); +void vkd3d_dbg_printf(struct vkd3d_debug_channel *channel, enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5);
const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2); const char *vkd3d_dbg_vsprintf(const char *fmt, va_list args); @@ -54,13 +60,15 @@ const char *debugstr_a(const char *str); const char *debugstr_an(const char *str, size_t n); const char *debugstr_w(const WCHAR *wstr, size_t wchar_size);
-#define VKD3D_DBG_LOG(level) \ +#define VKD3D_DBG_LOG(channel, level) \ do { \ + struct vkd3d_debug_channel *vkd3d_dbg_channel = &channel; \ const enum vkd3d_dbg_level vkd3d_dbg_level = VKD3D_DBG_LEVEL_##level; \ VKD3D_DBG_PRINTF
-#define VKD3D_DBG_LOG_ONCE(first_time_level, level) \ +#define VKD3D_DBG_LOG_ONCE(channel, first_time_level, level) \ do { \ + struct vkd3d_debug_channel *vkd3d_dbg_channel = &channel; \ static bool vkd3d_dbg_next_time; \ const enum vkd3d_dbg_level vkd3d_dbg_level = vkd3d_dbg_next_time \ ? VKD3D_DBG_LEVEL_##level : VKD3D_DBG_LEVEL_##first_time_level; \ @@ -68,29 +76,29 @@ const char *debugstr_w(const WCHAR *wstr, size_t wchar_size); VKD3D_DBG_PRINTF
#define VKD3D_DBG_PRINTF(...) \ - vkd3d_dbg_printf(vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0) + vkd3d_dbg_printf(vkd3d_dbg_channel, vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0)
#ifndef TRACE -#define TRACE VKD3D_DBG_LOG(TRACE) +#define TRACE VKD3D_DBG_LOG(vkd3d_debug_channel, TRACE) #endif
#ifndef WARN -#define WARN VKD3D_DBG_LOG(WARN) +#define WARN VKD3D_DBG_LOG(vkd3d_debug_channel, WARN) #endif
#ifndef FIXME -#define FIXME VKD3D_DBG_LOG(FIXME) +#define FIXME VKD3D_DBG_LOG(vkd3d_debug_channel, FIXME) #endif
-#define ERR VKD3D_DBG_LOG(ERR) +#define ERR VKD3D_DBG_LOG(vkd3d_debug_channel, ERR)
#ifndef TRACE_ON -#define TRACE_ON() (vkd3d_dbg_get_level() == VKD3D_DBG_LEVEL_TRACE) +#define TRACE_ON() (vkd3d_dbg_get_level(&vkd3d_debug_channel) == VKD3D_DBG_LEVEL_TRACE) #endif
-#define FIXME_ONCE VKD3D_DBG_LOG_ONCE(FIXME, WARN) +#define FIXME_ONCE VKD3D_DBG_LOG_ONCE(vkd3d_debug_channel, FIXME, WARN)
-#define VKD3D_DEBUG_ENV_NAME(name) const char *vkd3d_dbg_env_name = name +#define VKD3D_DEBUG_ENV_NAME(name) static struct vkd3d_debug_channel vkd3d_debug_channel = {name, ~0u};
static inline const char *debugstr_guid(const GUID *guid) { diff --git a/libs/vkd3d-common/blob.c b/libs/vkd3d-common/blob.c index c46abb55..1cb817ce 100644 --- a/libs/vkd3d-common/blob.c +++ b/libs/vkd3d-common/blob.c @@ -23,6 +23,8 @@ #include "vkd3d_debug.h" #include "vkd3d_memory.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); + struct vkd3d_blob { ID3D10Blob ID3DBlob_iface; diff --git a/libs/vkd3d-common/debug.c b/libs/vkd3d-common/debug.c index 4868f3fb..0cbf2fbe 100644 --- a/libs/vkd3d-common/debug.c +++ b/libs/vkd3d-common/debug.c @@ -31,8 +31,6 @@ #define VKD3D_DEBUG_BUFFER_COUNT 64 #define VKD3D_DEBUG_BUFFER_SIZE 512
-extern const char *vkd3d_dbg_env_name; - static const char *debug_level_names[] = { /* VKD3D_DBG_LEVEL_NONE */ "none", @@ -42,37 +40,36 @@ static const char *debug_level_names[] = /* VKD3D_DBG_LEVEL_TRACE */ "trace", };
-enum vkd3d_dbg_level vkd3d_dbg_get_level(void) +enum vkd3d_dbg_level vkd3d_dbg_get_level(struct vkd3d_debug_channel *channel) { - static unsigned int level = ~0u; const char *vkd3d_debug; unsigned int i;
- if (level != ~0u) - return level; + if (channel->level != ~0u) + return channel->level;
- if (!(vkd3d_debug = getenv(vkd3d_dbg_env_name))) + if (!(vkd3d_debug = getenv(channel->name))) vkd3d_debug = "";
for (i = 0; i < ARRAY_SIZE(debug_level_names); ++i) { if (!strcmp(debug_level_names[i], vkd3d_debug)) { - level = i; - return level; + channel->level = i; + return channel->level; } }
/* Default debug level. */ - level = VKD3D_DBG_LEVEL_FIXME; - return level; + channel->level = VKD3D_DBG_LEVEL_FIXME; + return channel->level; }
-void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) +void vkd3d_dbg_printf(struct vkd3d_debug_channel *channel, enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) { va_list args;
- if (vkd3d_dbg_get_level() < level) + if (vkd3d_dbg_get_level(channel) < level) return;
assert(level < ARRAY_SIZE(debug_level_names)); diff --git a/libs/vkd3d-common/error.c b/libs/vkd3d-common/error.c index 81c1fd97..51928148 100644 --- a/libs/vkd3d-common/error.c +++ b/libs/vkd3d-common/error.c @@ -19,6 +19,8 @@ #include "vkd3d_common.h" #include "vkd3d_debug.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); + HRESULT hresult_from_vkd3d_result(int vkd3d_result) { switch (vkd3d_result) diff --git a/libs/vkd3d-common/memory.c b/libs/vkd3d-common/memory.c index f46f180c..3546e136 100644 --- a/libs/vkd3d-common/memory.c +++ b/libs/vkd3d-common/memory.c @@ -19,6 +19,8 @@
#include "vkd3d_memory.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); + void *vkd3d_malloc(size_t size) { void *ptr; diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index c5518752..e0e5c16e 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -24,6 +24,8 @@
#include "vkd3d_shader_private.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + #define VKD3D_SM1_VS 0xfffeu #define VKD3D_SM1_PS 0xffffu
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 17be2306..410ed371 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -21,6 +21,8 @@ #include "vkd3d_shader_private.h" #include "sm4.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + void dxbc_writer_init(struct dxbc_writer *dxbc) { memset(dxbc, 0, sizeof(*dxbc)); diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 7239b183..ffee93a6 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -22,6 +22,8 @@ #include "hlsl.h" #include <stdio.h>
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_log_level level, const char *fmt, ...) { diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index 2c398bc8..70a24c16 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -24,6 +24,8 @@ #include "hlsl.h" #include "hlsl.tab.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + #define YYSTYPE HLSL_YYSTYPE #define YYLTYPE HLSL_YYLTYPE
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 44e4964f..7d2f5014 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -108,6 +108,8 @@ int yylex(HLSL_YYSTYPE *yylval_param, HLSL_YYLTYPE *yylloc_param, void *yyscanne %code {
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + #define YYLLOC_DEFAULT(cur, rhs, n) (cur) = YYRHSLOC(rhs, !!n)
static void yyerror(YYLTYPE *loc, void *scanner, struct hlsl_ctx *ctx, const char *s) diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 78b22910..0794cebd 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -21,6 +21,8 @@ #include "hlsl.h" #include <stdio.h>
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + /* Split uniforms into two variables representing the constant and temp * registers, and copy the former to the latter, so that writes to uniforms * work. */ diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index d8787c21..647afc98 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -22,6 +22,8 @@
#include "hlsl.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct hlsl_ir_constant *src) { unsigned int k; diff --git a/libs/vkd3d-shader/hlsl_sm1.c b/libs/vkd3d-shader/hlsl_sm1.c index 0cdd3917..a6d14b32 100644 --- a/libs/vkd3d-shader/hlsl_sm1.c +++ b/libs/vkd3d-shader/hlsl_sm1.c @@ -21,6 +21,8 @@ #include "hlsl.h" #include <stdio.h>
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + bool hlsl_sm1_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic, bool output, D3DSHADER_PARAM_REGISTER_TYPE *type, unsigned int *reg) { diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index a5fc094b..ce35d603 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -23,6 +23,8 @@ #include "vkd3d_d3dcommon.h" #include "sm4.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_block *block);
static bool type_is_integer(const struct hlsl_type *type) diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index 7686e018..f4db270d 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -22,6 +22,8 @@
#include "preproc.tab.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + #undef ERROR /* defined in wingdi.h */
#define YYSTYPE PREPROC_YYSTYPE diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index 3f02ac03..79870503 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -46,6 +46,8 @@ int preproc_yylex(PREPROC_YYSTYPE *yylval_param, PREPROC_YYLTYPE *yylloc_param, %code {
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + #define YYLLOC_DEFAULT(cur, rhs, n) (cur) = YYRHSLOC(rhs, !!n)
#ifndef S_ISREG diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 89b16305..b62a3f20 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -34,6 +34,8 @@ # include "vulkan/GLSL.std.450.h" #endif /* HAVE_SPIRV_UNIFIED1_GLSL_STD_450_H */
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + #ifdef HAVE_SPIRV_TOOLS # include "spirv-tools/libspirv.h"
diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 6c30edc9..80803d78 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -27,6 +27,8 @@ #include <stdio.h> #include <math.h>
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); + static const char * const shader_opcode_names[] = { [VKD3DSIH_ABS ] = "abs", diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 62baf17f..398d430b 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -140,7 +140,7 @@ void vkd3d_shader_trace_text_(const char *text, size_t size, const char *functio q = end; else ++q; - vkd3d_dbg_printf(VKD3D_DBG_LEVEL_TRACE, function, "%.*s", (int)(q - p), p); + vkd3d_dbg_printf(&vkd3d_debug_channel, VKD3D_DBG_LEVEL_TRACE, function, "%.*s", (int)(q - p), p); } }
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 55e6be58..60928bfc 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -20,6 +20,8 @@
#include "vkd3d_private.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); + static void d3d12_fence_incref(struct d3d12_fence *fence); static void d3d12_fence_decref(struct d3d12_fence *fence); static HRESULT d3d12_fence_signal(struct d3d12_fence *fence, uint64_t value, VkFence vk_fence); diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 5f8108ec..cfc8ed89 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -19,6 +19,8 @@ #include "vkd3d_private.h" #include "vkd3d_version.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); + struct vkd3d_struct { enum vkd3d_structure_type type; diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 68c28cd1..596b8f9e 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -24,6 +24,8 @@
LONG64 object_global_serial_id;
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); + static inline bool is_cpu_accessible_heap(const D3D12_HEAP_PROPERTIES *properties) { if (properties->Type == D3D12_HEAP_TYPE_DEFAULT) diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 97e2856d..06260dab 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -21,6 +21,8 @@ #include "vkd3d_private.h" #include "vkd3d_shaders.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); + /* ID3D12RootSignature */ static inline struct d3d12_root_signature *impl_from_ID3D12RootSignature(ID3D12RootSignature *iface) { diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index 8169b14b..73037654 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -20,6 +20,8 @@
#include <errno.h>
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); + #define COLOR (VK_IMAGE_ASPECT_COLOR_BIT) #define DEPTH (VK_IMAGE_ASPECT_DEPTH_BIT) #define STENCIL (VK_IMAGE_ASPECT_STENCIL_BIT)
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 10/05/22 20:21, Matteo Bruni ha scritto:
Mostly so that the debug primitives don't depend on a shared variable.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
This allows to keep using a separate debug env var for vkd3d-shader even when building vkd3d as static lib(s). That will eventually make it possible to drop the related change in the vkd3d copy imported into Wine.
include/private/vkd3d_debug.h | 32 +++++++++++++++++---------- libs/vkd3d-common/blob.c | 2 ++ libs/vkd3d-common/debug.c | 23 +++++++++---------- libs/vkd3d-common/error.c | 2 ++ libs/vkd3d-common/memory.c | 2 ++ libs/vkd3d-shader/d3dbc.c | 2 ++ libs/vkd3d-shader/dxbc.c | 2 ++ libs/vkd3d-shader/hlsl.c | 2 ++ libs/vkd3d-shader/hlsl.l | 2 ++ libs/vkd3d-shader/hlsl.y | 2 ++ libs/vkd3d-shader/hlsl_codegen.c | 2 ++ libs/vkd3d-shader/hlsl_constant_ops.c | 2 ++ libs/vkd3d-shader/hlsl_sm1.c | 2 ++ libs/vkd3d-shader/hlsl_sm4.c | 2 ++ libs/vkd3d-shader/preproc.l | 2 ++ libs/vkd3d-shader/preproc.y | 2 ++ libs/vkd3d-shader/spirv.c | 2 ++ libs/vkd3d-shader/trace.c | 2 ++ libs/vkd3d-shader/vkd3d_shader_main.c | 2 +- libs/vkd3d/command.c | 2 ++ libs/vkd3d/device.c | 2 ++ libs/vkd3d/resource.c | 2 ++ libs/vkd3d/state.c | 2 ++ libs/vkd3d/utils.c | 2 ++ 24 files changed, 73 insertions(+), 26 deletions(-)
diff --git a/include/private/vkd3d_debug.h b/include/private/vkd3d_debug.h index 8ab653ae..bc3bf5c9 100644 --- a/include/private/vkd3d_debug.h +++ b/include/private/vkd3d_debug.h @@ -44,9 +44,15 @@ enum vkd3d_dbg_level VKD3D_DBG_LEVEL_TRACE, };
-enum vkd3d_dbg_level vkd3d_dbg_get_level(void); +struct vkd3d_debug_channel +{
- const char name[64];
- enum vkd3d_dbg_level level;
+};
+enum vkd3d_dbg_level vkd3d_dbg_get_level(struct vkd3d_debug_channel *channel);
-void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4); +void vkd3d_dbg_printf(struct vkd3d_debug_channel *channel, enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5);
const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2); const char *vkd3d_dbg_vsprintf(const char *fmt, va_list args); @@ -54,13 +60,15 @@ const char *debugstr_a(const char *str); const char *debugstr_an(const char *str, size_t n); const char *debugstr_w(const WCHAR *wstr, size_t wchar_size);
-#define VKD3D_DBG_LOG(level) \ +#define VKD3D_DBG_LOG(channel, level) \ do { \
struct vkd3d_debug_channel *vkd3d_dbg_channel = &channel; \ const enum vkd3d_dbg_level vkd3d_dbg_level = VKD3D_DBG_LEVEL_##level; \ VKD3D_DBG_PRINTF
-#define VKD3D_DBG_LOG_ONCE(first_time_level, level) \ +#define VKD3D_DBG_LOG_ONCE(channel, first_time_level, level) \ do { \
struct vkd3d_debug_channel *vkd3d_dbg_channel = &channel; \ static bool vkd3d_dbg_next_time; \ const enum vkd3d_dbg_level vkd3d_dbg_level = vkd3d_dbg_next_time \ ? VKD3D_DBG_LEVEL_##level : VKD3D_DBG_LEVEL_##first_time_level; \
@@ -68,29 +76,29 @@ const char *debugstr_w(const WCHAR *wstr, size_t wchar_size); VKD3D_DBG_PRINTF
#define VKD3D_DBG_PRINTF(...) \
vkd3d_dbg_printf(vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0)
vkd3d_dbg_printf(vkd3d_dbg_channel, vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0)
#ifndef TRACE
-#define TRACE VKD3D_DBG_LOG(TRACE) +#define TRACE VKD3D_DBG_LOG(vkd3d_debug_channel, TRACE) #endif
#ifndef WARN -#define WARN VKD3D_DBG_LOG(WARN) +#define WARN VKD3D_DBG_LOG(vkd3d_debug_channel, WARN) #endif
#ifndef FIXME -#define FIXME VKD3D_DBG_LOG(FIXME) +#define FIXME VKD3D_DBG_LOG(vkd3d_debug_channel, FIXME) #endif
-#define ERR VKD3D_DBG_LOG(ERR) +#define ERR VKD3D_DBG_LOG(vkd3d_debug_channel, ERR)
#ifndef TRACE_ON -#define TRACE_ON() (vkd3d_dbg_get_level() == VKD3D_DBG_LEVEL_TRACE) +#define TRACE_ON() (vkd3d_dbg_get_level(&vkd3d_debug_channel) == VKD3D_DBG_LEVEL_TRACE) #endif
-#define FIXME_ONCE VKD3D_DBG_LOG_ONCE(FIXME, WARN) +#define FIXME_ONCE VKD3D_DBG_LOG_ONCE(vkd3d_debug_channel, FIXME, WARN)
-#define VKD3D_DEBUG_ENV_NAME(name) const char *vkd3d_dbg_env_name = name +#define VKD3D_DEBUG_ENV_NAME(name) static struct vkd3d_debug_channel vkd3d_debug_channel = {name, ~0u};
static inline const char *debugstr_guid(const GUID *guid) { diff --git a/libs/vkd3d-common/blob.c b/libs/vkd3d-common/blob.c index c46abb55..1cb817ce 100644 --- a/libs/vkd3d-common/blob.c +++ b/libs/vkd3d-common/blob.c @@ -23,6 +23,8 @@ #include "vkd3d_debug.h" #include "vkd3d_memory.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
- struct vkd3d_blob { ID3D10Blob ID3DBlob_iface;
diff --git a/libs/vkd3d-common/debug.c b/libs/vkd3d-common/debug.c index 4868f3fb..0cbf2fbe 100644 --- a/libs/vkd3d-common/debug.c +++ b/libs/vkd3d-common/debug.c @@ -31,8 +31,6 @@ #define VKD3D_DEBUG_BUFFER_COUNT 64 #define VKD3D_DEBUG_BUFFER_SIZE 512
-extern const char *vkd3d_dbg_env_name;
- static const char *debug_level_names[] = { /* VKD3D_DBG_LEVEL_NONE */ "none",
@@ -42,37 +40,36 @@ static const char *debug_level_names[] = /* VKD3D_DBG_LEVEL_TRACE */ "trace", };
-enum vkd3d_dbg_level vkd3d_dbg_get_level(void) +enum vkd3d_dbg_level vkd3d_dbg_get_level(struct vkd3d_debug_channel *channel) {
static unsigned int level = ~0u; const char *vkd3d_debug; unsigned int i;
if (level != ~0u)
return level;
- if (channel->level != ~0u)
return channel->level;
- if (!(vkd3d_debug = getenv(vkd3d_dbg_env_name)))
if (!(vkd3d_debug = getenv(channel->name))) vkd3d_debug = "";
for (i = 0; i < ARRAY_SIZE(debug_level_names); ++i) { if (!strcmp(debug_level_names[i], vkd3d_debug)) {
level = i;
return level;
channel->level = i;
return channel->level; } } /* Default debug level. */
- level = VKD3D_DBG_LEVEL_FIXME;
- return level;
- channel->level = VKD3D_DBG_LEVEL_FIXME;
- return channel->level; }
-void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) +void vkd3d_dbg_printf(struct vkd3d_debug_channel *channel, enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) { va_list args;
- if (vkd3d_dbg_get_level() < level)
if (vkd3d_dbg_get_level(channel) < level) return;
assert(level < ARRAY_SIZE(debug_level_names));
diff --git a/libs/vkd3d-common/error.c b/libs/vkd3d-common/error.c index 81c1fd97..51928148 100644 --- a/libs/vkd3d-common/error.c +++ b/libs/vkd3d-common/error.c @@ -19,6 +19,8 @@ #include "vkd3d_common.h" #include "vkd3d_debug.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
- HRESULT hresult_from_vkd3d_result(int vkd3d_result) { switch (vkd3d_result)
diff --git a/libs/vkd3d-common/memory.c b/libs/vkd3d-common/memory.c index f46f180c..3546e136 100644 --- a/libs/vkd3d-common/memory.c +++ b/libs/vkd3d-common/memory.c @@ -19,6 +19,8 @@
#include "vkd3d_memory.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
- void *vkd3d_malloc(size_t size) { void *ptr;
diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index c5518752..e0e5c16e 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -24,6 +24,8 @@
#include "vkd3d_shader_private.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
- #define VKD3D_SM1_VS 0xfffeu #define VKD3D_SM1_PS 0xffffu
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 17be2306..410ed371 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -21,6 +21,8 @@ #include "vkd3d_shader_private.h" #include "sm4.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
- void dxbc_writer_init(struct dxbc_writer *dxbc) { memset(dxbc, 0, sizeof(*dxbc));
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 7239b183..ffee93a6 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -22,6 +22,8 @@ #include "hlsl.h" #include <stdio.h>
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
- void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_log_level level, const char *fmt, ...) {
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index 2c398bc8..70a24c16 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -24,6 +24,8 @@ #include "hlsl.h" #include "hlsl.tab.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
- #define YYSTYPE HLSL_YYSTYPE #define YYLTYPE HLSL_YYLTYPE
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 44e4964f..7d2f5014 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -108,6 +108,8 @@ int yylex(HLSL_YYSTYPE *yylval_param, HLSL_YYLTYPE *yylloc_param, void *yyscanne %code {
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
#define YYLLOC_DEFAULT(cur, rhs, n) (cur) = YYRHSLOC(rhs, !!n)
static void yyerror(YYLTYPE *loc, void *scanner, struct hlsl_ctx *ctx, const char *s)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 78b22910..0794cebd 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -21,6 +21,8 @@ #include "hlsl.h" #include <stdio.h>
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
- /* Split uniforms into two variables representing the constant and temp
- registers, and copy the former to the latter, so that writes to uniforms
- work. */
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index d8787c21..647afc98 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -22,6 +22,8 @@
#include "hlsl.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
- static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct hlsl_ir_constant *src) { unsigned int k;
diff --git a/libs/vkd3d-shader/hlsl_sm1.c b/libs/vkd3d-shader/hlsl_sm1.c index 0cdd3917..a6d14b32 100644 --- a/libs/vkd3d-shader/hlsl_sm1.c +++ b/libs/vkd3d-shader/hlsl_sm1.c @@ -21,6 +21,8 @@ #include "hlsl.h" #include <stdio.h>
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
- bool hlsl_sm1_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic, bool output, D3DSHADER_PARAM_REGISTER_TYPE *type, unsigned int *reg) {
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index a5fc094b..ce35d603 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -23,6 +23,8 @@ #include "vkd3d_d3dcommon.h" #include "sm4.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_block *block);
static bool type_is_integer(const struct hlsl_type *type)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index 7686e018..f4db270d 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -22,6 +22,8 @@
#include "preproc.tab.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
#undef ERROR /* defined in wingdi.h */
#define YYSTYPE PREPROC_YYSTYPE
diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index 3f02ac03..79870503 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -46,6 +46,8 @@ int preproc_yylex(PREPROC_YYSTYPE *yylval_param, PREPROC_YYLTYPE *yylloc_param, %code {
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
#define YYLLOC_DEFAULT(cur, rhs, n) (cur) = YYRHSLOC(rhs, !!n)
#ifndef S_ISREG
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 89b16305..b62a3f20 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -34,6 +34,8 @@ # include "vulkan/GLSL.std.450.h" #endif /* HAVE_SPIRV_UNIFIED1_GLSL_STD_450_H */
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
- #ifdef HAVE_SPIRV_TOOLS # include "spirv-tools/libspirv.h"
diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 6c30edc9..80803d78 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -27,6 +27,8 @@ #include <stdio.h> #include <math.h>
+VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
- static const char * const shader_opcode_names[] = { [VKD3DSIH_ABS ] = "abs",
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 62baf17f..398d430b 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -140,7 +140,7 @@ void vkd3d_shader_trace_text_(const char *text, size_t size, const char *functio q = end; else ++q;
vkd3d_dbg_printf(VKD3D_DBG_LEVEL_TRACE, function, "%.*s", (int)(q - p), p);
}vkd3d_dbg_printf(&vkd3d_debug_channel, VKD3D_DBG_LEVEL_TRACE, function, "%.*s", (int)(q - p), p); }
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 55e6be58..60928bfc 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -20,6 +20,8 @@
#include "vkd3d_private.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
- static void d3d12_fence_incref(struct d3d12_fence *fence); static void d3d12_fence_decref(struct d3d12_fence *fence); static HRESULT d3d12_fence_signal(struct d3d12_fence *fence, uint64_t value, VkFence vk_fence);
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 5f8108ec..cfc8ed89 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -19,6 +19,8 @@ #include "vkd3d_private.h" #include "vkd3d_version.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
- struct vkd3d_struct { enum vkd3d_structure_type type;
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 68c28cd1..596b8f9e 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -24,6 +24,8 @@
LONG64 object_global_serial_id;
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
- static inline bool is_cpu_accessible_heap(const D3D12_HEAP_PROPERTIES *properties) { if (properties->Type == D3D12_HEAP_TYPE_DEFAULT)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 97e2856d..06260dab 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -21,6 +21,8 @@ #include "vkd3d_private.h" #include "vkd3d_shaders.h"
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
- /* ID3D12RootSignature */ static inline struct d3d12_root_signature *impl_from_ID3D12RootSignature(ID3D12RootSignature *iface) {
diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index 8169b14b..73037654 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -20,6 +20,8 @@
#include <errno.h>
+VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
- #define COLOR (VK_IMAGE_ASPECT_COLOR_BIT) #define DEPTH (VK_IMAGE_ASPECT_DEPTH_BIT) #define STENCIL (VK_IMAGE_ASPECT_STENCIL_BIT)
On Tue, 10 May 2022 at 20:21, Matteo Bruni mbruni@codeweavers.com wrote:
Mostly so that the debug primitives don't depend on a shared variable.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
This allows to keep using a separate debug env var for vkd3d-shader even when building vkd3d as static lib(s). That will eventually make it possible to drop the related change in the vkd3d copy imported into Wine.
include/private/vkd3d_debug.h | 32 +++++++++++++++++---------- libs/vkd3d-common/blob.c | 2 ++ libs/vkd3d-common/debug.c | 23 +++++++++---------- libs/vkd3d-common/error.c | 2 ++ libs/vkd3d-common/memory.c | 2 ++ libs/vkd3d-shader/d3dbc.c | 2 ++ libs/vkd3d-shader/dxbc.c | 2 ++ libs/vkd3d-shader/hlsl.c | 2 ++ libs/vkd3d-shader/hlsl.l | 2 ++ libs/vkd3d-shader/hlsl.y | 2 ++ libs/vkd3d-shader/hlsl_codegen.c | 2 ++ libs/vkd3d-shader/hlsl_constant_ops.c | 2 ++ libs/vkd3d-shader/hlsl_sm1.c | 2 ++ libs/vkd3d-shader/hlsl_sm4.c | 2 ++ libs/vkd3d-shader/preproc.l | 2 ++ libs/vkd3d-shader/preproc.y | 2 ++ libs/vkd3d-shader/spirv.c | 2 ++ libs/vkd3d-shader/trace.c | 2 ++ libs/vkd3d-shader/vkd3d_shader_main.c | 2 +- libs/vkd3d/command.c | 2 ++ libs/vkd3d/device.c | 2 ++ libs/vkd3d/resource.c | 2 ++ libs/vkd3d/state.c | 2 ++ libs/vkd3d/utils.c | 2 ++ 24 files changed, 73 insertions(+), 26 deletions(-)
I can't say I like this solution. In particular, sprinkling VKD3D_DEBUG_ENV_NAME through the source seems undesirable. It should be possible to do this in a way that allows defining the environment variable only once per module. Separately, for the Wine integration, I think it would make more sense to integrate with Wine's debug facilities, so that e.g. WINEDEBUG=+d3d_shader and WINEDEBUG=+d3d12 simply do the right thing.
Hi,
Il 12/05/22 15:57, Henri Verbeet ha scritto:
I can't say I like this solution. In particular, sprinkling VKD3D_DEBUG_ENV_NAME through the source seems undesirable. It should be possible to do this in a way that allows defining the environment variable only once per module. Separately, for the Wine integration, I think it would make more sense to integrate with Wine's debug facilities, so that e.g. WINEDEBUG=+d3d_shader and WINEDEBUG=+d3d12 simply do the right thing.
As I see it, it's not very different from having a WINE_DEFAULT_DEBUG_CHANNEL in each file, just as we do with Wine. Actually, my suggestion would be to really transition to that model, which is more flexible (there can be more than one debug channel per file). And I would also like to have a single environment variable from which you can control all the flags.
Giovanni.
On Thu, May 12, 2022 at 4:12 PM Giovanni Mascellani gmascellani@codeweavers.com wrote:
Hi,
As I see it, it's not very different from having a WINE_DEFAULT_DEBUG_CHANNEL in each file, just as we do with Wine. Actually, my suggestion would be to really transition to that model, which is more flexible (there can be more than one debug channel per file).
Right. I saw my current patches as a step in that direction. I could certainly take care of that part too.
Il 12/05/22 15:57, Henri Verbeet ha scritto:
I can't say I like this solution. In particular, sprinkling VKD3D_DEBUG_ENV_NAME through the source seems undesirable. It should be possible to do this in a way that allows defining the environment variable only once per module.
The point of this series is to avoid global variables, which is the cause of the VKD3D_SHADER_DEBUG -> VKD3D_DEBUG change in the vkd3d version integrated into Wine, and which is something that I found confusing (i.e. to get vkd3d-shader debug output you have to use different env vars depending if you're using integrated vs separate vkd3d) besides of the intention of just reducing the diff with upstream vkd3d. Patches 2-5 are preparation for patch 6, moving all the code calling the debug trace functions out of header files.
Separately, for the Wine integration, I think it would make more sense to integrate with Wine's debug facilities, so that e.g. WINEDEBUG=+d3d_shader and WINEDEBUG=+d3d12 simply do the right thing.
That's an interesting idea, I'll start hacking on it.
On 5/12/22 08:57, Henri Verbeet wrote:
On Tue, 10 May 2022 at 20:21, Matteo Bruni mbruni@codeweavers.com wrote:
Mostly so that the debug primitives don't depend on a shared variable.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
This allows to keep using a separate debug env var for vkd3d-shader even when building vkd3d as static lib(s). That will eventually make it possible to drop the related change in the vkd3d copy imported into Wine.
include/private/vkd3d_debug.h | 32 +++++++++++++++++---------- libs/vkd3d-common/blob.c | 2 ++ libs/vkd3d-common/debug.c | 23 +++++++++---------- libs/vkd3d-common/error.c | 2 ++ libs/vkd3d-common/memory.c | 2 ++ libs/vkd3d-shader/d3dbc.c | 2 ++ libs/vkd3d-shader/dxbc.c | 2 ++ libs/vkd3d-shader/hlsl.c | 2 ++ libs/vkd3d-shader/hlsl.l | 2 ++ libs/vkd3d-shader/hlsl.y | 2 ++ libs/vkd3d-shader/hlsl_codegen.c | 2 ++ libs/vkd3d-shader/hlsl_constant_ops.c | 2 ++ libs/vkd3d-shader/hlsl_sm1.c | 2 ++ libs/vkd3d-shader/hlsl_sm4.c | 2 ++ libs/vkd3d-shader/preproc.l | 2 ++ libs/vkd3d-shader/preproc.y | 2 ++ libs/vkd3d-shader/spirv.c | 2 ++ libs/vkd3d-shader/trace.c | 2 ++ libs/vkd3d-shader/vkd3d_shader_main.c | 2 +- libs/vkd3d/command.c | 2 ++ libs/vkd3d/device.c | 2 ++ libs/vkd3d/resource.c | 2 ++ libs/vkd3d/state.c | 2 ++ libs/vkd3d/utils.c | 2 ++ 24 files changed, 73 insertions(+), 26 deletions(-)
I can't say I like this solution. In particular, sprinkling VKD3D_DEBUG_ENV_NAME through the source seems undesirable. It should be possible to do this in a way that allows defining the environment variable only once per module. Separately, for the Wine integration, I think it would make more sense to integrate with Wine's debug facilities, so that e.g. WINEDEBUG=+d3d_shader and WINEDEBUG=+d3d12 simply do the right thing.
I don't think that defining the environment variable looks right either, but on the other hand I'd like to see multiple channels per module be allowed, along the lines of Wine. E.g. it'd be nice to separate dxbc, spirv, hlsl, preproc. I think that necessitates defining *something* per file.
On Thu, 12 May 2022 at 18:34, Zebediah Figura zfigura@codeweavers.com wrote:
I don't think that defining the environment variable looks right either, but on the other hand I'd like to see multiple channels per module be allowed, along the lines of Wine. E.g. it'd be nice to separate dxbc, spirv, hlsl, preproc. I think that necessitates defining *something* per file.
Sure, I could see the case for separate debug channels. That seems somewhat orthogonal though. I.e., right now, if we wanted to add different channels, those would likely end up being in addition to the VKD3D_DEBUG_ENV_NAME lines introduced by this patch.
On Thu, May 12, 2022 at 6:45 PM Henri Verbeet hverbeet@gmail.com wrote:
On Thu, 12 May 2022 at 18:34, Zebediah Figura zfigura@codeweavers.com wrote:
I don't think that defining the environment variable looks right either, but on the other hand I'd like to see multiple channels per module be allowed, along the lines of Wine. E.g. it'd be nice to separate dxbc, spirv, hlsl, preproc. I think that necessitates defining *something* per file.
Sure, I could see the case for separate debug channels. That seems somewhat orthogonal though. I.e., right now, if we wanted to add different channels, those would likely end up being in addition to the VKD3D_DEBUG_ENV_NAME lines introduced by this patch.
It's a bit verbose but it doesn't look too terrible to me (although I'm still modifying stuff and I might change my opinion). The alternative is to embrace the change in Wine's copy and just use VKD3D_DEBUG everywhere, with the understanding that we're making a break with the past (and probably hardcoding the environment variable name... more than it already was).
On 5/12/22 11:47, Matteo Bruni wrote:
On Thu, May 12, 2022 at 6:45 PM Henri Verbeet hverbeet@gmail.com wrote:
On Thu, 12 May 2022 at 18:34, Zebediah Figura zfigura@codeweavers.com wrote:
I don't think that defining the environment variable looks right either, but on the other hand I'd like to see multiple channels per module be allowed, along the lines of Wine. E.g. it'd be nice to separate dxbc, spirv, hlsl, preproc. I think that necessitates defining *something* per file.
Sure, I could see the case for separate debug channels. That seems somewhat orthogonal though. I.e., right now, if we wanted to add different channels, those would likely end up being in addition to the VKD3D_DEBUG_ENV_NAME lines introduced by this patch.
It's a bit verbose but it doesn't look too terrible to me (although I'm still modifying stuff and I might change my opinion). The alternative is to embrace the change in Wine's copy and just use VKD3D_DEBUG everywhere, with the understanding that we're making a break with the past (and probably hardcoding the environment variable name... more than it already was).
I'll admit, I'm not personally very opposed to that either. In the one place it's easier to type "VKD3D_DEBUG=+d3d12,+spirv" than "VKD3D_DEBUG=+d3d12 VKD3D_SHADER_DEBUG=+spirv". But I also haven't done much d3d12 debugging.
On 5/10/22 13:21, Matteo Bruni wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
This fixes arithmetic-int.shader_test on 32-bit Linux for me.
libs/vkd3d-shader/hlsl.l | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index 267c8c30..2c398bc8 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -31,6 +31,38 @@ static void update_location(struct hlsl_ctx *ctx, YYLTYPE *loc);
#define YY_USER_ACTION update_location(yyget_extra(yyscanner), yyget_lloc(yyscanner));
+static int char_to_int(char c) +{
- if ('0' <= c && c <= '9')
return c - '0';
- if ('A' <= c && c <= 'F')
return c - 'A' + 10;
- if ('a' <= c && c <= 'f')
return c - 'a' + 10;
- return -1;
+}
+static uint32_t parse_integer(const char *s) +{
- uint32_t base = 10, ret = 0;
- int digit;
- if (*s == '0')
- {
base = 8;
++s;
if (*s == 'x' || *s == 'X')
{
base = 16;
++s;
}
- }
- while ((digit = char_to_int(*s++)) >= 0)
ret = ret * base + (uint32_t)digit;
- return ret;
+}
This is an exact copy of preproc_parse_integer(); could we just link to that (and rename + move it) instead?
On Tue, May 10, 2022 at 8:27 PM Zebediah Figura zfigura@codeweavers.com wrote:
On 5/10/22 13:21, Matteo Bruni wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
This fixes arithmetic-int.shader_test on 32-bit Linux for me.
libs/vkd3d-shader/hlsl.l | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index 267c8c30..2c398bc8 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -31,6 +31,38 @@ static void update_location(struct hlsl_ctx *ctx, YYLTYPE *loc);
#define YY_USER_ACTION update_location(yyget_extra(yyscanner), yyget_lloc(yyscanner));
+static int char_to_int(char c) +{
- if ('0' <= c && c <= '9')
return c - '0';
- if ('A' <= c && c <= 'F')
return c - 'A' + 10;
- if ('a' <= c && c <= 'f')
return c - 'a' + 10;
- return -1;
+}
+static uint32_t parse_integer(const char *s) +{
- uint32_t base = 10, ret = 0;
- int digit;
- if (*s == '0')
- {
base = 8;
++s;
if (*s == 'x' || *s == 'X')
{
base = 16;
++s;
}
- }
- while ((digit = char_to_int(*s++)) >= 0)
ret = ret * base + (uint32_t)digit;
- return ret;
+}
This is an exact copy of preproc_parse_integer(); could we just link to that (and rename + move it) instead?
I'm not sure why I decided that I needed to copy the function over... Now I moved the implementation to vkd3d_shader_private.h (so I made it static inline), does that seem good or do you prefer it somewhere else? I could e.g. move it back to preproc.y, it somehow didn't feel great but I can surely get over it.
On 5/10/22 15:48, Matteo Bruni wrote:
On Tue, May 10, 2022 at 8:27 PM Zebediah Figura zfigura@codeweavers.com wrote:
On 5/10/22 13:21, Matteo Bruni wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
This fixes arithmetic-int.shader_test on 32-bit Linux for me.
libs/vkd3d-shader/hlsl.l | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index 267c8c30..2c398bc8 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -31,6 +31,38 @@ static void update_location(struct hlsl_ctx *ctx, YYLTYPE *loc);
#define YY_USER_ACTION update_location(yyget_extra(yyscanner), yyget_lloc(yyscanner));
+static int char_to_int(char c) +{
- if ('0' <= c && c <= '9')
return c - '0';
- if ('A' <= c && c <= 'F')
return c - 'A' + 10;
- if ('a' <= c && c <= 'f')
return c - 'a' + 10;
- return -1;
+}
+static uint32_t parse_integer(const char *s) +{
- uint32_t base = 10, ret = 0;
- int digit;
- if (*s == '0')
- {
base = 8;
++s;
if (*s == 'x' || *s == 'X')
{
base = 16;
++s;
}
- }
- while ((digit = char_to_int(*s++)) >= 0)
ret = ret * base + (uint32_t)digit;
- return ret;
+}
This is an exact copy of preproc_parse_integer(); could we just link to that (and rename + move it) instead?
I'm not sure why I decided that I needed to copy the function over... Now I moved the implementation to vkd3d_shader_private.h (so I made it static inline), does that seem good or do you prefer it somewhere else? I could e.g. move it back to preproc.y, it somehow didn't feel great but I can surely get over it.
I guess it's mostly up to Henri's preference, but my inclination is that the most reasonable place is vkd3d_shader_main.c or preproc.y.