Commit 85fa778f authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3dcompiler: Rip out the HLSL compiler.

The compiler is completely non-functional as-is, and lives in libvkd3d-shader now. When a vkd3d release is made d3dcompiler will access it via the libvkd3d-shader public API. Accordingly there's no reason to keep it around in wine's d3dcompiler. Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarMatteo Bruni <mbruni@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 0861b544
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -14,12 +14,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -654,181 +654,6 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena
return hr;
}
struct target_info {
const char *name;
enum shader_type type;
DWORD sm_major;
DWORD sm_minor;
DWORD level_major;
DWORD level_minor;
BOOL sw;
BOOL support;
};
/* Must be kept sorted for binary search */
static const struct target_info targets_info[] = {
{ "cs_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
{ "cs_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
{ "cs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
{ "ds_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
{ "fx_2_0", ST_UNKNOWN, 2, 0, 0, 0, FALSE, FALSE },
{ "fx_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
{ "fx_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
{ "fx_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
{ "gs_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
{ "gs_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
{ "gs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
{ "hs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
{ "ps.1.0", ST_PIXEL, 1, 0, 0, 0, FALSE, TRUE },
{ "ps.1.1", ST_PIXEL, 1, 1, 0, 0, FALSE, FALSE },
{ "ps.1.2", ST_PIXEL, 1, 2, 0, 0, FALSE, FALSE },
{ "ps.1.3", ST_PIXEL, 1, 3, 0, 0, FALSE, FALSE },
{ "ps.1.4", ST_PIXEL, 1, 4, 0, 0, FALSE, FALSE },
{ "ps.2.0", ST_PIXEL, 2, 0, 0, 0, FALSE, TRUE },
{ "ps.2.a", ST_PIXEL, 2, 1, 0, 0, FALSE, FALSE },
{ "ps.2.b", ST_PIXEL, 2, 2, 0, 0, FALSE, FALSE },
{ "ps.2.sw", ST_PIXEL, 2, 0, 0, 0, TRUE, FALSE },
{ "ps.3.0", ST_PIXEL, 3, 0, 0, 0, FALSE, TRUE },
{ "ps_1_0", ST_PIXEL, 1, 0, 0, 0, FALSE, TRUE },
{ "ps_1_1", ST_PIXEL, 1, 1, 0, 0, FALSE, FALSE },
{ "ps_1_2", ST_PIXEL, 1, 2, 0, 0, FALSE, FALSE },
{ "ps_1_3", ST_PIXEL, 1, 3, 0, 0, FALSE, FALSE },
{ "ps_1_4", ST_PIXEL, 1, 4, 0, 0, FALSE, FALSE },
{ "ps_2_0", ST_PIXEL, 2, 0, 0, 0, FALSE, TRUE },
{ "ps_2_a", ST_PIXEL, 2, 1, 0, 0, FALSE, FALSE },
{ "ps_2_b", ST_PIXEL, 2, 2, 0, 0, FALSE, FALSE },
{ "ps_2_sw", ST_PIXEL, 2, 0, 0, 0, TRUE, FALSE },
{ "ps_3_0", ST_PIXEL, 3, 0, 0, 0, FALSE, TRUE },
{ "ps_3_sw", ST_PIXEL, 3, 0, 0, 0, TRUE, FALSE },
{ "ps_4_0", ST_PIXEL, 4, 0, 0, 0, FALSE, TRUE },
{ "ps_4_0_level_9_0", ST_PIXEL, 4, 0, 9, 0, FALSE, FALSE },
{ "ps_4_0_level_9_1", ST_PIXEL, 4, 0, 9, 1, FALSE, FALSE },
{ "ps_4_0_level_9_3", ST_PIXEL, 4, 0, 9, 3, FALSE, FALSE },
{ "ps_4_1", ST_PIXEL, 4, 1, 0, 0, FALSE, TRUE },
{ "ps_5_0", ST_PIXEL, 5, 0, 0, 0, FALSE, TRUE },
{ "tx_1_0", ST_UNKNOWN, 1, 0, 0, 0, FALSE, FALSE },
{ "vs.1.0", ST_VERTEX, 1, 0, 0, 0, FALSE, TRUE },
{ "vs.1.1", ST_VERTEX, 1, 1, 0, 0, FALSE, TRUE },
{ "vs.2.0", ST_VERTEX, 2, 0, 0, 0, FALSE, TRUE },
{ "vs.2.a", ST_VERTEX, 2, 1, 0, 0, FALSE, FALSE },
{ "vs.2.sw", ST_VERTEX, 2, 0, 0, 0, TRUE, FALSE },
{ "vs.3.0", ST_VERTEX, 3, 0, 0, 0, FALSE, TRUE },
{ "vs.3.sw", ST_VERTEX, 3, 0, 0, 0, TRUE, FALSE },
{ "vs_1_0", ST_VERTEX, 1, 0, 0, 0, FALSE, TRUE },
{ "vs_1_1", ST_VERTEX, 1, 1, 0, 0, FALSE, TRUE },
{ "vs_2_0", ST_VERTEX, 2, 0, 0, 0, FALSE, TRUE },
{ "vs_2_a", ST_VERTEX, 2, 1, 0, 0, FALSE, FALSE },
{ "vs_2_sw", ST_VERTEX, 2, 0, 0, 0, TRUE, FALSE },
{ "vs_3_0", ST_VERTEX, 3, 0, 0, 0, FALSE, TRUE },
{ "vs_3_sw", ST_VERTEX, 3, 0, 0, 0, TRUE, FALSE },
{ "vs_4_0", ST_VERTEX, 4, 0, 0, 0, FALSE, TRUE },
{ "vs_4_0_level_9_0", ST_VERTEX, 4, 0, 9, 0, FALSE, FALSE },
{ "vs_4_0_level_9_1", ST_VERTEX, 4, 0, 9, 1, FALSE, FALSE },
{ "vs_4_0_level_9_3", ST_VERTEX, 4, 0, 9, 3, FALSE, FALSE },
{ "vs_4_1", ST_VERTEX, 4, 1, 0, 0, FALSE, TRUE },
{ "vs_5_0", ST_VERTEX, 5, 0, 0, 0, FALSE, TRUE },
};
static const struct target_info * get_target_info(const char *target)
{
LONG min = 0;
LONG max = ARRAY_SIZE(targets_info) - 1;
LONG cur;
int res;
while (min <= max)
{
cur = (min + max) / 2;
res = strcmp(target, targets_info[cur].name);
if (res < 0)
max = cur - 1;
else if (res > 0)
min = cur + 1;
else
return &targets_info[cur];
}
return NULL;
}
static HRESULT compile_shader(const char *preproc_shader, const char *target, const char *entrypoint,
ID3DBlob **shader, ID3DBlob **error_messages)
{
DWORD size, major, minor;
char *messages = NULL;
HRESULT hr;
ID3DBlob *buffer;
char *pos;
enum shader_type shader_type;
const struct target_info *info;
TRACE("Preprocessed shader source: %s\n", debugstr_a(preproc_shader));
TRACE("Checking compilation target %s\n", debugstr_a(target));
info = get_target_info(target);
if (!info)
{
FIXME("Unknown compilation target %s\n", debugstr_a(target));
return D3DERR_INVALIDCALL;
}
else
{
if (!info->support)
{
FIXME("Compilation target %s not yet supported\n", debugstr_a(target));
return D3DERR_INVALIDCALL;
}
else
{
shader_type = info->type;
major = info->sm_major;
minor = info->sm_minor;
}
}
hr = parse_hlsl_shader(preproc_shader, shader_type, major, minor, entrypoint, shader, &messages);
if (messages)
{
TRACE("Compiler messages:\n");
TRACE("%s\n", debugstr_a(messages));
TRACE("Shader source:\n");
TRACE("%s\n", debugstr_a(preproc_shader));
if (error_messages)
{
const char *preproc_messages = *error_messages ? ID3D10Blob_GetBufferPointer(*error_messages) : NULL;
HRESULT blob_hr;
size = strlen(messages) + (preproc_messages ? strlen(preproc_messages) : 0) + 1;
if (FAILED(blob_hr = D3DCreateBlob(size, &buffer)))
{
HeapFree(GetProcessHeap(), 0, messages);
if (shader && *shader)
{
ID3D10Blob_Release(*shader);
*shader = NULL;
}
return blob_hr;
}
pos = ID3D10Blob_GetBufferPointer(buffer);
if (preproc_messages)
{
memcpy(pos, preproc_messages, strlen(preproc_messages) + 1);
pos += strlen(preproc_messages);
}
memcpy(pos, messages, strlen(messages) + 1);
if (*error_messages) ID3D10Blob_Release(*error_messages);
*error_messages = buffer;
}
HeapFree(GetProcessHeap(), 0, messages);
}
return hr;
}
static HRESULT WINAPI d3dcompiler_include_from_file_open(ID3DInclude *iface, D3D_INCLUDE_TYPE include_type,
const char *filename, const void *parent_data, const void **data, UINT *bytes)
{
......@@ -936,7 +761,10 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
hr = preprocess_shader(data, data_size, filename, defines, include, error_messages);
if (SUCCEEDED(hr))
hr = compile_shader(wpp_output, target, entrypoint, shader, error_messages);
{
FIXME("HLSL shader compilation is not yet implemented.\n");
hr = E_NOTIMPL;
}
HeapFree(GetProcessHeap(), 0, wpp_output);
LeaveCriticalSection(&wpp_mutex);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1436,10 +1436,13 @@ static void test_fail(void)
{
compiled = errors = NULL;
hr = ppD3DCompile(tests[i], strlen(tests[i]), NULL, NULL, NULL, "test", targets[j], 0, 0, &compiled, &errors);
ok(hr == E_FAIL, "Test %u, target %s, got unexpected hr %#x.\n", i, targets[j], hr);
ok(!!errors, "Test %u, target %s, expected non-NULL error blob.\n", i, targets[j]);
todo_wine ok(hr == E_FAIL, "Test %u, target %s, got unexpected hr %#x.\n", i, targets[j], hr);
if (hr == E_FAIL)
{
ok(!!errors, "Test %u, target %s, expected non-NULL error blob.\n", i, targets[j]);
ID3D10Blob_Release(errors);
}
ok(!compiled, "Test %u, target %s, expected no compiled shader blob.\n", i, targets[j]);
ID3D10Blob_Release(errors);
}
}
}
......
......@@ -16,12 +16,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
......@@ -17,12 +17,10 @@ C_SRCS = \
LEX_SRCS = \
asmshader.l \
hlsl.l \
ppl.l
BISON_SRCS = \
asmshader.y \
hlsl.y \
ppy.y
RC_SRCS = version.rc
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