Commit 3c186a5e authored by Alexandre Julliard's avatar Alexandre Julliard

vkd3d: Import upstream release 1.9.

parent 3b5aef66
......@@ -764,7 +764,7 @@ static void test_get_blob_part2(void)
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
size = ID3D10Blob_GetBufferSize(blob);
todo_wine ok(size == 4735, "Got unexpected size %Iu.\n", size);
ok(size == 4735, "Got unexpected size %Iu.\n", size);
dword = ((DWORD*)ID3D10Blob_GetBufferPointer(blob));
ok(TAG_DXBC == *dword, "DXBC got %#lx, expected %#lx.\n", *dword, TAG_DXBC);
......
......@@ -616,8 +616,7 @@ static void test_sampling(void)
winetest_push_context("Test %u", i);
ID3D11DeviceContext_ClearRenderTargetView(test_context.immediate_context, test_context.rtv, red);
todo_wine_if (i < 3)
ps_code = compile_shader_flags(tests[i], "ps_4_0", D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY);
ps_code = compile_shader_flags(tests[i], "ps_4_0", D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY);
if (ps_code)
{
draw_quad(&test_context, ps_code);
......@@ -902,7 +901,6 @@ static void test_reflection(void)
refcount = reflection->lpVtbl->Release(reflection);
ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
todo_wine
code = compile_shader_flags(ps_source, "ps_4_0", D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY);
if (!code)
return;
......
......@@ -558,26 +558,30 @@ static void test_conditionals(void)
return;
device = test_context.device;
todo_wine
ps_code = compile_shader(ps_if_source, "ps_2_0", 0);
draw_quad(device, ps_code);
init_readback(device, &rb);
for (i = 0; i < 200; i += 40)
if (ps_code)
{
v = get_readback_vec4(&rb, i, 0);
todo_wine ok(compare_vec4(v, 0.9f, 0.8f, 0.7f, 0.6f, 0),
"Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
}
draw_quad(device, ps_code);
init_readback(device, &rb);
for (i = 240; i < 640; i += 40)
{
v = get_readback_vec4(&rb, i, 0);
todo_wine ok(compare_vec4(v, 0.1f, 0.2f, 0.3f, 0.4f, 0),
"Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
}
for (i = 0; i < 200; i += 40)
{
v = get_readback_vec4(&rb, i, 0);
todo_wine ok(compare_vec4(v, 0.9f, 0.8f, 0.7f, 0.6f, 0),
"Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
}
release_readback(&rb);
ID3D10Blob_Release(ps_code);
for (i = 240; i < 640; i += 40)
{
v = get_readback_vec4(&rb, i, 0);
todo_wine ok(compare_vec4(v, 0.1f, 0.2f, 0.3f, 0.4f, 0),
"Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
}
release_readback(&rb);
ID3D10Blob_Release(ps_code);
}
todo_wine ps_code = compile_shader(ps_ternary_source, "ps_2_0", 0);
if (ps_code)
......@@ -588,6 +592,7 @@ static void test_conditionals(void)
for (i = 0; i < 320; i += 40)
{
v = get_readback_vec4(&rb, i, 0);
todo_wine
ok(compare_vec4(v, 0.5f, 0.25f, 0.5f, 0.75f, 0),
"Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
}
......@@ -595,6 +600,7 @@ static void test_conditionals(void)
for (i = 360; i < 640; i += 40)
{
v = get_readback_vec4(&rb, i, 0);
todo_wine
ok(compare_vec4(v, 0.6f, 0.8f, 0.1f, 0.2f, 0),
"Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
}
......@@ -653,6 +659,7 @@ static void test_float_vectors(void)
ID3D10Blob_Release(ps_code);
}
todo_wine
ps_code = compile_shader(ps_uniform_indexing_source, "ps_2_0", 0);
if (ps_code)
{
......@@ -696,6 +703,7 @@ static void test_trig(void)
return;
device = test_context.device;
todo_wine
ps_code = compile_shader(ps_source, "ps_2_0", 0);
if (ps_code)
{
......@@ -1168,13 +1176,14 @@ static void test_samplers(void)
{
hr = IDirect3DDevice9_Clear(test_context.device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 0, 0), 1.0f, 0);
ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
todo_wine_if (i > 2)
ps_code = compile_shader(tests[i], "ps_2_0", 0);
if (ps_code)
{
draw_quad(test_context.device, ps_code);
v = get_color_vec4(test_context.device, 0, 0);
todo_wine ok(compare_vec4(&v, 1.0f, 0.0f, 1.0f, 0.0f, 0),
ok(compare_vec4(&v, 1.0f, 0.0f, 1.0f, 0.0f, 0),
"Test %u: Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", i, v.x, v.y, v.z, v.w);
ID3D10Blob_Release(ps_code);
......
Alexandre Julliard
Alistair Leslie-Hughes
Andrew Eikum
Andrey Gusev
Atharva Nimbalkar
......@@ -8,6 +9,8 @@ Chip Davis
Conor McCarthy
David Gow
Derek Lesho
Ethan Lee
Evan Tang
Fabian Maurer
Francisco Casas
Francois Gouget
......@@ -16,6 +19,7 @@ Hans-Kristian Arntzen
Henri Verbeet
Isabella Bosia
Jactry Zeng
Jan Sikorski
Joshua Ashton
Józef Kucia
Martin Storsjö
......
......@@ -14,20 +14,21 @@ SOURCES = \
libs/vkd3d-common/memory.c \
libs/vkd3d-common/utf8.c \
libs/vkd3d-shader/checksum.c \
libs/vkd3d-shader/d3d_asm.c \
libs/vkd3d-shader/d3dbc.c \
libs/vkd3d-shader/dxbc.c \
libs/vkd3d-shader/dxil.c \
libs/vkd3d-shader/glsl.c \
libs/vkd3d-shader/hlsl.c \
libs/vkd3d-shader/hlsl.l \
libs/vkd3d-shader/hlsl.y \
libs/vkd3d-shader/hlsl_codegen.c \
libs/vkd3d-shader/hlsl_constant_ops.c \
libs/vkd3d-shader/hlsl_sm1.c \
libs/vkd3d-shader/hlsl_sm4.c \
libs/vkd3d-shader/ir.c \
libs/vkd3d-shader/preproc.l \
libs/vkd3d-shader/preproc.y \
libs/vkd3d-shader/spirv.c \
libs/vkd3d-shader/trace.c \
libs/vkd3d-shader/tpf.c \
libs/vkd3d-shader/vkd3d_shader_main.c \
libs/vkd3d/command.c \
libs/vkd3d/device.c \
......
#define PACKAGE_NAME "vkd3d"
#define PACKAGE_STRING "vkd3d 1.7"
#define PACKAGE_VERSION "1.7"
#define PACKAGE_STRING "vkd3d 1.9"
#define PACKAGE_VERSION "1.9"
#define PATH_MAX 1024
#define SONAME_LIBVULKAN "vulkan-1.dll"
......@@ -20,6 +20,7 @@
#define __VKD3D_COMMON_H
#include "config.h"
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#include "vkd3d_types.h"
......@@ -28,6 +29,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef _MSC_VER
#include <intrin.h>
......@@ -171,6 +173,11 @@ static inline bool vkd3d_bound_range(size_t start, size_t count, size_t limit)
#endif
}
static inline bool vkd3d_object_range_overflow(size_t start, size_t count, size_t size)
{
return (~(size_t)0 - start) / size < count;
}
static inline uint16_t vkd3d_make_u16(uint8_t low, uint8_t high)
{
return low | ((uint16_t)high << 8);
......@@ -186,6 +193,21 @@ static inline int vkd3d_u32_compare(uint32_t x, uint32_t y)
return (x > y) - (x < y);
}
static inline bool bitmap_clear(uint32_t *map, unsigned int idx)
{
return map[idx >> 5] &= ~(1u << (idx & 0x1f));
}
static inline bool bitmap_set(uint32_t *map, unsigned int idx)
{
return map[idx >> 5] |= (1u << (idx & 0x1f));
}
static inline bool bitmap_is_set(const uint32_t *map, unsigned int idx)
{
return map[idx >> 5] & (1u << (idx & 0x1f));
}
static inline int ascii_isupper(int c)
{
return 'A' <= c && c <= 'Z';
......@@ -249,6 +271,7 @@ static inline LONG InterlockedDecrement(LONG volatile *x)
# else
# error "InterlockedDecrement() not implemented for this platform"
# endif
#endif /* _WIN32 */
static inline void vkd3d_parse_version(const char *version, int *major, int *minor)
......
......@@ -91,7 +91,7 @@ const char *debugstr_w(const WCHAR *wstr, size_t wchar_size);
#define FIXME_ONCE VKD3D_DBG_LOG_ONCE(FIXME, WARN)
#define VKD3D_DEBUG_ENV_NAME(name) const char *vkd3d_dbg_env_name = name
#define VKD3D_DEBUG_ENV_NAME(name) const char *const vkd3d_dbg_env_name = name
static inline const char *debugstr_guid(const GUID *guid)
{
......
/*
* Copyright 2023 Conor McCarthy for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __VKD3D_SHADER_UTILS_H
#define __VKD3D_SHADER_UTILS_H
#include "vkd3d_shader.h"
#define TAG_DXIL VKD3D_MAKE_TAG('D', 'X', 'I', 'L')
#define TAG_SHDR VKD3D_MAKE_TAG('S', 'H', 'D', 'R')
#define TAG_SHEX VKD3D_MAKE_TAG('S', 'H', 'E', 'X')
static inline enum vkd3d_result vkd3d_shader_parse_dxbc_source_type(const struct vkd3d_shader_code *dxbc,
enum vkd3d_shader_source_type *type, char **messages)
{
struct vkd3d_shader_dxbc_desc desc;
enum vkd3d_result ret;
unsigned int i;
*type = VKD3D_SHADER_SOURCE_NONE;
if ((ret = vkd3d_shader_parse_dxbc(dxbc, 0, &desc, messages)) < 0)
return ret;
for (i = 0; i < desc.section_count; ++i)
{
uint32_t tag = desc.sections[i].tag;
if (tag == TAG_SHDR || tag == TAG_SHEX)
{
*type = VKD3D_SHADER_SOURCE_DXBC_TPF;
#ifndef VKD3D_SHADER_UNSUPPORTED_DXIL
break;
#else
}
else if (tag == TAG_DXIL)
{
*type = VKD3D_SHADER_SOURCE_DXBC_DXIL;
/* Default to DXIL if both are present. */
break;
#endif
}
}
vkd3d_shader_free_dxbc(&desc);
if (*type == VKD3D_SHADER_SOURCE_NONE)
return VKD3D_ERROR_INVALID_SHADER;
return VKD3D_OK;
}
#endif /* __VKD3D_SHADER_UTILS_H */
......@@ -76,6 +76,8 @@ enum vkd3d_api_version
VKD3D_API_VERSION_1_5,
VKD3D_API_VERSION_1_6,
VKD3D_API_VERSION_1_7,
VKD3D_API_VERSION_1_8,
VKD3D_API_VERSION_1_9,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_API_VERSION),
};
......@@ -206,7 +208,42 @@ VKD3D_API VkPhysicalDevice vkd3d_get_vk_physical_device(ID3D12Device *device);
VKD3D_API struct vkd3d_instance *vkd3d_instance_from_device(ID3D12Device *device);
VKD3D_API uint32_t vkd3d_get_vk_queue_family_index(ID3D12CommandQueue *queue);
/**
* Acquire the Vulkan queue backing a command queue.
*
* While a queue is acquired by the client, it is locked so that
* neither the vkd3d library nor other threads can submit work to
* it. For that reason it should be released as soon as possible with
* vkd3d_release_vk_queue(). The lock is not reentrant, so the same
* queue must not be acquired more than once by the same thread.
*
* Work submitted through the Direct3D 12 API exposed by vkd3d is not
* always immediately submitted to the Vulkan queue; sometimes it is
* kept in another internal queue, which might not necessarily be
* empty at the time vkd3d_acquire_vk_queue() is called. For this
* reason, work submitted directly to the Vulkan queue might appear to
* the Vulkan driver as being submitted before other work submitted
* though the Direct3D 12 API. If this is not desired, it is
* recommended to synchronize work submission using an ID3D12Fence
* object, by submitting to the queue a signal operation after all the
* Direct3D 12 work is submitted and waiting for it before calling
* vkd3d_acquire_vk_queue().
*
* \since 1.0
*/
VKD3D_API VkQueue vkd3d_acquire_vk_queue(ID3D12CommandQueue *queue);
/**
* Release the Vulkan queue backing a command queue.
*
* This must be paired to an earlier corresponding
* vkd3d_acquire_vk_queue(). After this function is called, the Vulkan
* queue returned by vkd3d_acquire_vk_queue() must not be used any
* more.
*
* \since 1.0
*/
VKD3D_API void vkd3d_release_vk_queue(ID3D12CommandQueue *queue);
VKD3D_API HRESULT vkd3d_create_image_resource(ID3D12Device *device,
......
......@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#endif
......@@ -40,15 +41,15 @@
#define VKD3D_DEBUG_BUFFER_COUNT 64
#define VKD3D_DEBUG_BUFFER_SIZE 512
extern const char *vkd3d_dbg_env_name;
extern const char *const vkd3d_dbg_env_name;
static const char *debug_level_names[] =
static const char *const debug_level_names[] =
{
/* VKD3D_DBG_LEVEL_NONE */ "none",
/* VKD3D_DBG_LEVEL_ERR */ "err",
/* VKD3D_DBG_LEVEL_FIXME */ "fixme",
/* VKD3D_DBG_LEVEL_WARN */ "warn",
/* VKD3D_DBG_LEVEL_TRACE */ "trace",
[VKD3D_DBG_LEVEL_NONE ] = "none",
[VKD3D_DBG_LEVEL_ERR ] = "err",
[VKD3D_DBG_LEVEL_FIXME] = "fixme",
[VKD3D_DBG_LEVEL_WARN ] = "warn",
[VKD3D_DBG_LEVEL_TRACE] = "trace",
};
enum vkd3d_dbg_level vkd3d_dbg_get_level(void)
......@@ -105,7 +106,13 @@ void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const ch
assert(level < ARRAY_SIZE(debug_level_names));
#ifdef _WIN32
vkd3d_dbg_output("vkd3d:%04lx:%s:%s ", GetCurrentThreadId(), debug_level_names[level], function);
#elif HAVE_GETTID
vkd3d_dbg_output("vkd3d:%u:%s:%s ", gettid(), debug_level_names[level], function);
#else
vkd3d_dbg_output("vkd3d:%s:%s ", debug_level_names[level], function);
#endif
va_start(args, fmt);
vkd3d_dbg_voutput(fmt, args);
va_end(args);
......
......@@ -109,6 +109,7 @@ static const char * const shader_opcode_names[] =
[VKD3DSIH_DEQ ] = "deq",
[VKD3DSIH_DFMA ] = "dfma",
[VKD3DSIH_DGE ] = "dge",
[VKD3DSIH_DISCARD ] = "discard",
[VKD3DSIH_DIV ] = "div",
[VKD3DSIH_DLT ] = "dlt",
[VKD3DSIH_DMAX ] = "dmax",
......@@ -577,17 +578,17 @@ static void shader_dump_resource_type(struct vkd3d_d3d_asm_compiler *compiler, e
{
static const char *const resource_type_names[] =
{
/* VKD3D_SHADER_RESOURCE_NONE */ "none",
/* VKD3D_SHADER_RESOURCE_BUFFER */ "buffer",
/* VKD3D_SHADER_RESOURCE_TEXTURE_1D */ "texture1d",
/* VKD3D_SHADER_RESOURCE_TEXTURE_2D */ "texture2d",
/* VKD3D_SHADER_RESOURCE_TEXTURE_2DMS */ "texture2dms",
/* VKD3D_SHADER_RESOURCE_TEXTURE_3D */ "texture3d",
/* VKD3D_SHADER_RESOURCE_TEXTURE_CUBE */ "texturecube",
/* VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY */ "texture1darray",
/* VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY */ "texture2darray",
/* VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY */ "texture2dmsarray",
/* VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY */ "texturecubearray",
[VKD3D_SHADER_RESOURCE_NONE ] = "none",
[VKD3D_SHADER_RESOURCE_BUFFER ] = "buffer",
[VKD3D_SHADER_RESOURCE_TEXTURE_1D ] = "texture1d",
[VKD3D_SHADER_RESOURCE_TEXTURE_2D ] = "texture2d",
[VKD3D_SHADER_RESOURCE_TEXTURE_2DMS ] = "texture2dms",
[VKD3D_SHADER_RESOURCE_TEXTURE_3D ] = "texture3d",
[VKD3D_SHADER_RESOURCE_TEXTURE_CUBE ] = "texturecube",
[VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY ] = "texture1darray",
[VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY ] = "texture2darray",
[VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY] = "texture2dmsarray",
[VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY] = "texturecubearray",
};
if (type < ARRAY_SIZE(resource_type_names))
......@@ -600,19 +601,19 @@ static void shader_dump_data_type(struct vkd3d_d3d_asm_compiler *compiler, const
{
static const char *const data_type_names[] =
{
/* VKD3D_DATA_FLOAT */ "float",
/* VKD3D_DATA_INT */ "int",
/* VKD3D_DATA_RESOURCE */ "resource",
/* VKD3D_DATA_SAMPLER */ "sampler",
/* VKD3D_DATA_UAV */ "uav",
/* VKD3D_DATA_UINT */ "uint",
/* VKD3D_DATA_UNORM */ "unorm",
/* VKD3D_DATA_SNORM */ "snorm",
/* VKD3D_DATA_OPAQUE */ "opaque",
/* VKD3D_DATA_MIXED */ "mixed",
/* VKD3D_DATA_DOUBLE */ "double",
/* VKD3D_DATA_CONTINUED */ "<continued>",
/* VKD3D_DATA_UNUSED */ "<unused>",
[VKD3D_DATA_FLOAT ] = "float",
[VKD3D_DATA_INT ] = "int",
[VKD3D_DATA_RESOURCE ] = "resource",
[VKD3D_DATA_SAMPLER ] = "sampler",
[VKD3D_DATA_UAV ] = "uav",
[VKD3D_DATA_UINT ] = "uint",
[VKD3D_DATA_UNORM ] = "unorm",
[VKD3D_DATA_SNORM ] = "snorm",
[VKD3D_DATA_OPAQUE ] = "opaque",
[VKD3D_DATA_MIXED ] = "mixed",
[VKD3D_DATA_DOUBLE ] = "double",
[VKD3D_DATA_CONTINUED] = "<continued>",
[VKD3D_DATA_UNUSED ] = "<unused>",
};
const char *name;
int i;
......@@ -645,7 +646,7 @@ static void shader_dump_decl_usage(struct vkd3d_d3d_asm_compiler *compiler,
break;
case VKD3D_SHADER_RESOURCE_TEXTURE_3D:
shader_addline(buffer, "_3d");
shader_addline(buffer, "_volume");
break;
case VKD3D_SHADER_RESOURCE_TEXTURE_CUBE:
......@@ -660,8 +661,9 @@ static void shader_dump_decl_usage(struct vkd3d_d3d_asm_compiler *compiler,
else if (semantic->resource.reg.reg.type == VKD3DSPR_RESOURCE || semantic->resource.reg.reg.type == VKD3DSPR_UAV)
{
if (semantic->resource.reg.reg.type == VKD3DSPR_RESOURCE)
shader_addline(buffer, "_resource_");
shader_addline(buffer, "_resource");
shader_addline(buffer, "_");
shader_dump_resource_type(compiler, semantic->resource_type);
if (semantic->resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMS
|| semantic->resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY)
......@@ -712,7 +714,7 @@ static void shader_dump_decl_usage(struct vkd3d_d3d_asm_compiler *compiler,
break;
case VKD3D_DECL_USAGE_TEXCOORD:
shader_addline(buffer, "texture%u", semantic->usage_idx);
shader_addline(buffer, "texcoord%u", semantic->usage_idx);
break;
case VKD3D_DECL_USAGE_TANGENT:
......@@ -1505,9 +1507,9 @@ static void shader_dump_instruction_flags(struct vkd3d_d3d_asm_compiler *compile
{
case VKD3DSIH_BREAKP:
case VKD3DSIH_CONTINUEP:
case VKD3DSIH_DISCARD:
case VKD3DSIH_IF:
case VKD3DSIH_RETP:
case VKD3DSIH_TEXKILL:
switch (ins->flags)
{
case VKD3D_SHADER_CONDITIONAL_OP_NZ: shader_addline(buffer, "_nz"); break;
......@@ -1857,11 +1859,11 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
shader_addline(buffer, "\n");
}
enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out)
enum vkd3d_result vkd3d_dxbc_binary_to_text(const struct vkd3d_shader_instruction_array *instructions,
const struct vkd3d_shader_version *shader_version, const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *out)
{
enum vkd3d_shader_compile_option_formatting_flags formatting;
struct vkd3d_shader_version *shader_version;
struct vkd3d_d3d_asm_compiler compiler;
enum vkd3d_result result = VKD3D_OK;
struct vkd3d_string_buffer *buffer;
......@@ -1919,16 +1921,16 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
buffer = &compiler.buffer;
vkd3d_string_buffer_init(buffer);
compiler.shader_version = *shader_version;
shader_version = &compiler.shader_version;
*shader_version = parser->shader_version;
vkd3d_string_buffer_printf(buffer, "%s%s_%u_%u%s\n", compiler.colours.version,
shader_get_type_prefix(shader_version->type), shader_version->major,
shader_version->minor, compiler.colours.reset);
indent = 0;
for (i = 0; i < parser->instructions.count; ++i)
for (i = 0; i < instructions->count; ++i)
{
struct vkd3d_shader_instruction *ins = &parser->instructions.elements[i];
struct vkd3d_shader_instruction *ins = &instructions->elements[i];
switch (ins->handler_idx)
{
......@@ -1981,12 +1983,13 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
return result;
}
void vkd3d_shader_trace(struct vkd3d_shader_parser *parser)
void vkd3d_shader_trace(const struct vkd3d_shader_instruction_array *instructions,
const struct vkd3d_shader_version *shader_version)
{
const char *p, *q, *end;
struct vkd3d_shader_code code;
if (vkd3d_dxbc_binary_to_text(parser, NULL, &code) != VKD3D_OK)
if (vkd3d_dxbc_binary_to_text(instructions, shader_version, NULL, &code) != VKD3D_OK)
return;
end = (const char *)code.code + code.size;
......
......@@ -37,6 +37,7 @@ static void update_location(struct hlsl_ctx *ctx, YYLTYPE *loc);
%option bison-locations
%option extra-type="struct hlsl_ctx *"
%option never-interactive
%option nodefault
%option noinput
%option nounput
%option noyywrap
......@@ -95,6 +96,7 @@ matrix {return KW_MATRIX; }
namespace {return KW_NAMESPACE; }
nointerpolation {return KW_NOINTERPOLATION; }
out {return KW_OUT; }
packoffset {return KW_PACKOFFSET; }
pass {return KW_PASS; }
PixelShader {return KW_PIXELSHADER; }
precise {return KW_PRECISE; }
......@@ -102,6 +104,8 @@ RasterizerState {return KW_RASTERIZERSTATE; }
RenderTargetView {return KW_RENDERTARGETVIEW; }
return {return KW_RETURN; }
register {return KW_REGISTER; }
RWBuffer {return KW_RWBUFFER; }
RWStructuredBuffer {return KW_RWSTRUCTUREDBUFFER; }
RWTexture1D {return KW_RWTEXTURE1D; }
RWTexture2D {return KW_RWTEXTURE2D; }
RWTexture3D {return KW_RWTEXTURE3D; }
......@@ -265,6 +269,10 @@ row_major {return KW_ROW_MAJOR; }
return STRING;
}
<pp_line>{WS}+ {}
<pp_line>{ANY} {
FIXME("Malformed preprocessor line directive?\n");
BEGIN(INITIAL);
}
<pp_line>{NEWLINE} {
FIXME("Malformed preprocessor line directive?\n");
BEGIN(INITIAL);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -30,6 +30,13 @@
#define YY_DECL static int preproc_lexer_lex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)
static struct preproc_macro *preproc_get_top_macro(struct preproc_ctx *ctx)
{
if (!ctx->expansion_count)
return NULL;
return ctx->expansion_stack[ctx->expansion_count - 1].macro;
}
static void update_location(struct preproc_ctx *ctx);
#define YY_USER_ACTION update_location(yyget_extra(yyscanner));
......@@ -41,6 +48,7 @@ static void update_location(struct preproc_ctx *ctx);
%option bison-locations
%option extra-type="struct preproc_ctx *"
%option never-interactive
%option nodefault
%option noinput
%option nounput
%option noyy_top_state
......@@ -75,6 +83,7 @@ INT_SUFFIX [uUlL]{0,2}
<C_COMMENT>"*/" {yy_pop_state(yyscanner);}
<C_COMMENT,CXX_COMMENT><<EOF>> {yy_pop_state(yyscanner);}
<C_COMMENT,CXX_COMMENT>. {}
<C_COMMENT>\n {}
<ERROR>(\\{NEWLINE}|[^\n])* {return T_STRING;}
......@@ -123,7 +132,20 @@ INT_SUFFIX [uUlL]{0,2}
const char *p;
if (!ctx->last_was_newline)
return T_HASHSTRING;
{
struct preproc_macro *macro;
/* Stringification is only done for function-like macro bodies.
* Anywhere else, we need to parse it as two separate tokens.
* We could use a state for this, but yyless() is easier and cheap.
*/
if ((macro = preproc_get_top_macro(ctx)) && macro->arg_count)
return T_HASHSTRING;
yyless(1);
return T_TEXT;
}
for (p = yytext + 1; strchr(" \t", *p); ++p)
;
......@@ -176,9 +198,9 @@ INT_SUFFIX [uUlL]{0,2}
return T_NEWLINE;
}
<INITIAL>{WS}+ {}
<INITIAL,INCLUDE,LINE>{WS}+ {}
<INITIAL>[-()\[\]{},+!*/<>&|^?:] {return yytext[0];}
<INITIAL>. {return T_TEXT;}
<INITIAL,INCLUDE,LINE>. {return T_TEXT;}
%%
......@@ -217,13 +239,6 @@ static bool preproc_is_writing(struct preproc_ctx *ctx)
return file->if_stack[file->if_count - 1].current_true;
}
static struct preproc_macro *preproc_get_top_macro(struct preproc_ctx *ctx)
{
if (!ctx->expansion_count)
return NULL;
return ctx->expansion_stack[ctx->expansion_count - 1].macro;
}
/* Concatenation is not done for object-like macros, but is done for both
* function-like macro bodies and their arguments. */
static bool should_concat(struct preproc_ctx *ctx)
......@@ -332,6 +347,43 @@ static bool preproc_push_expansion(struct preproc_ctx *ctx,
return true;
}
static void preproc_stringify(struct preproc_ctx *ctx, struct vkd3d_string_buffer *buffer, const char *text)
{
const struct preproc_text *expansion;
const char *p = text + 1;
unsigned int i;
while (*p == ' ' || *p == '\t')
++p;
vkd3d_string_buffer_printf(buffer, "\"");
if ((expansion = find_arg_expansion(ctx, p)))
{
size_t len = expansion->text.content_size;
size_t start = 0;
while (len && strchr(" \t\r\n", expansion->text.buffer[len - 1]))
--len;
while (start < len && strchr(" \t\r\n", expansion->text.buffer[start]))
++start;
for (i = start; i < len; ++i)
{
char c = expansion->text.buffer[i];
if (c == '\\' || c == '"')
vkd3d_string_buffer_printf(buffer, "\\");
vkd3d_string_buffer_printf(buffer, "%c", c);
}
}
else
{
vkd3d_string_buffer_printf(buffer, "%s", p);
}
vkd3d_string_buffer_printf(buffer, "\"");
}
int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
{
struct preproc_ctx *ctx = yyget_extra(scanner);
......@@ -439,9 +491,6 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
switch (func_state->state)
{
case STATE_NONE:
{
struct preproc_macro *macro;
if (token == T_CONCAT && should_concat(ctx))
{
while (ctx->buffer.content_size
......@@ -450,37 +499,17 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
break;
}
/* Stringification, however, is only done for function-like
* macro bodies. */
if (token == T_HASHSTRING && (macro = preproc_get_top_macro(ctx)) && macro->arg_count)
if (token == T_HASHSTRING)
{
const struct preproc_text *expansion;
const char *p = text + 1;
unsigned int i;
struct vkd3d_string_buffer buffer;
if (ctx->current_directive)
return return_token(token, lval, text);
while (*p == ' ' || *p == '\t')
++p;
vkd3d_string_buffer_printf(&ctx->buffer, "\"");
if ((expansion = find_arg_expansion(ctx, p)))
{
for (i = 0; i < expansion->text.content_size; ++i)
{
char c = expansion->text.buffer[i];
if (c == '\\' || c == '"')
vkd3d_string_buffer_printf(&ctx->buffer, "\\");
vkd3d_string_buffer_printf(&ctx->buffer, "%c", c);
}
}
else
{
vkd3d_string_buffer_printf(&ctx->buffer, "%s", p);
}
vkd3d_string_buffer_printf(&ctx->buffer, "\"");
vkd3d_string_buffer_init(&buffer);
preproc_stringify(ctx, &buffer, text);
vkd3d_string_buffer_printf(&ctx->buffer, "%s", buffer.buffer);
vkd3d_string_buffer_cleanup(&buffer);
break;
}
......@@ -584,7 +613,6 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
else
vkd3d_string_buffer_printf(&ctx->buffer, "%s ", text);
break;
}
case STATE_IDENTIFIER:
if (token == '(')
......@@ -626,6 +654,41 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
switch (token)
{
/* Most text gets left alone (e.g. if it contains macros,
* the macros should be evaluated later).
* Arguments are a special case, and are replaced with
* their values immediately. */
case T_IDENTIFIER:
case T_IDENTIFIER_PAREN:
{
const struct preproc_text *expansion;
if ((expansion = find_arg_expansion(ctx, text)))
{
preproc_push_expansion(ctx, expansion, NULL);
continue;
}
if (current_arg)
preproc_text_add(current_arg, text);
break;
}
/* Stringification is another special case. Unsurprisingly,
* we need to stringify if this is an argument. More
* surprisingly, we need to stringify even if it's not. */
case T_HASHSTRING:
{
struct vkd3d_string_buffer buffer;
vkd3d_string_buffer_init(&buffer);
preproc_stringify(ctx, &buffer, text);
if (current_arg)
preproc_text_add(current_arg, buffer.buffer);
vkd3d_string_buffer_cleanup(&buffer);
break;
}
case T_NEWLINE:
if (current_arg)
preproc_text_add(current_arg, " ");
......@@ -684,6 +747,9 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
if (current_arg)
preproc_text_add(current_arg, text);
}
if (current_arg)
preproc_text_add(current_arg, " ");
break;
}
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -20,6 +20,7 @@
#include "vkd3d_private.h"
#include "vkd3d_shaders.h"
#include "vkd3d_shader_utils.h"
/* ID3D12RootSignature */
static inline struct d3d12_root_signature *impl_from_ID3D12RootSignature(ID3D12RootSignature *iface)
......@@ -374,8 +375,8 @@ static HRESULT d3d12_root_signature_info_count_descriptors(struct d3d12_root_sig
if (unbounded && range->OffsetInDescriptorsFromTableStart == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
{
WARN("An unbounded range with offset D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND occurs after "
"another unbounded range.\n");
WARN("A range with offset D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND occurs after "
"an unbounded range.\n");
return E_INVALIDARG;
}
......@@ -1958,7 +1959,7 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
const struct vkd3d_shader_compile_option options[] =
{
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_7},
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_9},
{VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV, typed_uav_compile_option(device)},
{VKD3D_SHADER_COMPILE_OPTION_WRITE_TESS_GEOM_POINT_SIZE, 0},
};
......@@ -1978,14 +1979,14 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
compile_info.next = shader_interface;
compile_info.source.code = code->pShaderBytecode;
compile_info.source.size = code->BytecodeLength;
compile_info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
compile_info.target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY;
compile_info.options = options;
compile_info.option_count = ARRAY_SIZE(options);
compile_info.log_level = VKD3D_SHADER_LOG_NONE;
compile_info.source_name = NULL;
if ((ret = vkd3d_shader_compile(&compile_info, &spirv, NULL)) < 0)
if ((ret = vkd3d_shader_parse_dxbc_source_type(&compile_info.source, &compile_info.source_type, NULL)) < 0
|| (ret = vkd3d_shader_compile(&compile_info, &spirv, NULL)) < 0)
{
WARN("Failed to compile shader, vkd3d result %d.\n", ret);
return hresult_from_vkd3d_result(ret);
......@@ -2008,10 +2009,11 @@ static int vkd3d_scan_dxbc(const struct d3d12_device *device, const D3D12_SHADER
struct vkd3d_shader_scan_descriptor_info *descriptor_info)
{
struct vkd3d_shader_compile_info compile_info;
enum vkd3d_result ret;
const struct vkd3d_shader_compile_option options[] =
{
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_7},
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_9},
{VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV, typed_uav_compile_option(device)},
};
......@@ -2019,13 +2021,15 @@ static int vkd3d_scan_dxbc(const struct d3d12_device *device, const D3D12_SHADER
compile_info.next = descriptor_info;
compile_info.source.code = code->pShaderBytecode;
compile_info.source.size = code->BytecodeLength;
compile_info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
compile_info.target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY;
compile_info.options = options;
compile_info.option_count = ARRAY_SIZE(options);
compile_info.log_level = VKD3D_SHADER_LOG_NONE;
compile_info.source_name = NULL;
if ((ret = vkd3d_shader_parse_dxbc_source_type(&compile_info.source, &compile_info.source_type, NULL)) < 0)
return ret;
return vkd3d_shader_scan(&compile_info, NULL);
}
......
......@@ -71,11 +71,11 @@ HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info,
if (!device)
{
ID3D12Device_Release(&object->ID3D12Device_iface);
ID3D12Device_Release(&object->ID3D12Device1_iface);
return S_FALSE;
}
return return_interface(&object->ID3D12Device_iface, &IID_ID3D12Device, iid, device);
return return_interface(&object->ID3D12Device1_iface, &IID_ID3D12Device, iid, device);
}
/* ID3D12RootSignatureDeserializer */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment