vkd3d: Fix race condition while dumping DXBC shaders.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-10-08 15:40:20 +02:00 committed by Alexandre Julliard
parent c296cbe30b
commit 07d115b1d4

View File

@ -1203,11 +1203,14 @@ struct d3d12_pipeline_state *unsafe_impl_from_ID3D12PipelineState(ID3D12Pipeline
static void dump_shader(const char *path, const char *prefix, const void *data, size_t size) static void dump_shader(const char *path, const char *prefix, const void *data, size_t size)
{ {
static unsigned int shader_id = 0; static int shader_id = 0;
char filename[1024]; char filename[1024];
unsigned int id;
FILE *f; FILE *f;
snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%s-%u.dxbc", path, prefix, shader_id); id = InterlockedIncrement(&shader_id) - 1;
snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%s-%u.dxbc", path, prefix, id);
if (!(f = fopen(filename, "wb"))) if (!(f = fopen(filename, "wb")))
{ {
ERR("Failed to open %s for dumping shader.\n", filename); ERR("Failed to open %s for dumping shader.\n", filename);
@ -1218,8 +1221,6 @@ static void dump_shader(const char *path, const char *prefix, const void *data,
ERR("Failed to write shader to %s.\n", filename); ERR("Failed to write shader to %s.\n", filename);
if (fclose(f)) if (fclose(f))
ERR("Failed to close stream %s.\n", filename); ERR("Failed to close stream %s.\n", filename);
++shader_id;
} }
static void dump_shader_stage(VkShaderStageFlagBits stage, const void *data, size_t size) static void dump_shader_stage(VkShaderStageFlagBits stage, const void *data, size_t size)