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: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0861b5447f
commit
85fa778f93
|
@ -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);
|
||||
|
|
|
@ -158,21 +158,6 @@ static inline BOOL d3dcompiler_free(void *ptr)
|
|||
return HeapFree(GetProcessHeap(), 0, ptr);
|
||||
}
|
||||
|
||||
static inline char *d3dcompiler_strdup(const char *string)
|
||||
{
|
||||
char *copy;
|
||||
SIZE_T len;
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
len = strlen(string);
|
||||
copy = d3dcompiler_alloc(len + 1);
|
||||
if (copy)
|
||||
memcpy(copy, string, len + 1);
|
||||
return copy;
|
||||
}
|
||||
|
||||
struct asm_parser;
|
||||
|
||||
/* This structure is only used in asmshader.y, but since the .l file accesses the semantic types
|
||||
|
@ -534,598 +519,6 @@ struct bwriter_shader *SlAssembleShader(const char *text, char **messages) DECLS
|
|||
HRESULT shader_write_bytecode(const struct bwriter_shader *shader, DWORD **result, DWORD *size) DECLSPEC_HIDDEN;
|
||||
void SlDeleteShader(struct bwriter_shader *shader) DECLSPEC_HIDDEN;
|
||||
|
||||
/* The general IR structure is inspired by Mesa GLSL hir, even though the code
|
||||
* ends up being quite different in practice. Anyway, here comes the relevant
|
||||
* licensing information.
|
||||
*
|
||||
* Copyright © 2010 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
enum hlsl_type_class
|
||||
{
|
||||
HLSL_CLASS_SCALAR,
|
||||
HLSL_CLASS_VECTOR,
|
||||
HLSL_CLASS_MATRIX,
|
||||
HLSL_CLASS_LAST_NUMERIC = HLSL_CLASS_MATRIX,
|
||||
HLSL_CLASS_STRUCT,
|
||||
HLSL_CLASS_ARRAY,
|
||||
HLSL_CLASS_OBJECT,
|
||||
};
|
||||
|
||||
enum hlsl_base_type
|
||||
{
|
||||
HLSL_TYPE_FLOAT,
|
||||
HLSL_TYPE_HALF,
|
||||
HLSL_TYPE_DOUBLE,
|
||||
HLSL_TYPE_INT,
|
||||
HLSL_TYPE_UINT,
|
||||
HLSL_TYPE_BOOL,
|
||||
HLSL_TYPE_LAST_SCALAR = HLSL_TYPE_BOOL,
|
||||
HLSL_TYPE_SAMPLER,
|
||||
HLSL_TYPE_TEXTURE,
|
||||
HLSL_TYPE_PIXELSHADER,
|
||||
HLSL_TYPE_VERTEXSHADER,
|
||||
HLSL_TYPE_STRING,
|
||||
HLSL_TYPE_VOID,
|
||||
};
|
||||
|
||||
enum hlsl_sampler_dim
|
||||
{
|
||||
HLSL_SAMPLER_DIM_GENERIC,
|
||||
HLSL_SAMPLER_DIM_1D,
|
||||
HLSL_SAMPLER_DIM_2D,
|
||||
HLSL_SAMPLER_DIM_3D,
|
||||
HLSL_SAMPLER_DIM_CUBE,
|
||||
HLSL_SAMPLER_DIM_MAX = HLSL_SAMPLER_DIM_CUBE
|
||||
};
|
||||
|
||||
enum hlsl_matrix_majority
|
||||
{
|
||||
HLSL_COLUMN_MAJOR,
|
||||
HLSL_ROW_MAJOR
|
||||
};
|
||||
|
||||
struct hlsl_type
|
||||
{
|
||||
struct list entry;
|
||||
struct wine_rb_entry scope_entry;
|
||||
enum hlsl_type_class type;
|
||||
enum hlsl_base_type base_type;
|
||||
enum hlsl_sampler_dim sampler_dim;
|
||||
const char *name;
|
||||
unsigned int modifiers;
|
||||
unsigned int dimx;
|
||||
unsigned int dimy;
|
||||
unsigned int reg_size;
|
||||
union
|
||||
{
|
||||
struct list *elements;
|
||||
struct
|
||||
{
|
||||
struct hlsl_type *type;
|
||||
unsigned int elements_count;
|
||||
} array;
|
||||
} e;
|
||||
};
|
||||
|
||||
struct hlsl_struct_field
|
||||
{
|
||||
struct list entry;
|
||||
struct hlsl_type *type;
|
||||
const char *name;
|
||||
const char *semantic;
|
||||
DWORD modifiers;
|
||||
unsigned int reg_offset;
|
||||
};
|
||||
|
||||
struct source_location
|
||||
{
|
||||
const char *file;
|
||||
unsigned int line;
|
||||
unsigned int col;
|
||||
};
|
||||
|
||||
enum hlsl_ir_node_type
|
||||
{
|
||||
HLSL_IR_ASSIGNMENT = 0,
|
||||
HLSL_IR_CONSTANT,
|
||||
HLSL_IR_EXPR,
|
||||
HLSL_IR_IF,
|
||||
HLSL_IR_LOAD,
|
||||
HLSL_IR_LOOP,
|
||||
HLSL_IR_JUMP,
|
||||
HLSL_IR_SWIZZLE,
|
||||
};
|
||||
|
||||
struct hlsl_ir_node
|
||||
{
|
||||
struct list entry;
|
||||
enum hlsl_ir_node_type type;
|
||||
struct hlsl_type *data_type;
|
||||
|
||||
struct list uses;
|
||||
|
||||
struct source_location loc;
|
||||
|
||||
/* Liveness ranges. "index" is the index of this instruction. Since this is
|
||||
* essentially an SSA value, the earliest live point is the index. This is
|
||||
* true even for loops, since currently we can't have a reference to a
|
||||
* value generated in an earlier iteration of the loop. */
|
||||
unsigned int index, last_read;
|
||||
};
|
||||
|
||||
struct hlsl_src
|
||||
{
|
||||
struct hlsl_ir_node *node;
|
||||
struct list entry;
|
||||
};
|
||||
|
||||
#define HLSL_STORAGE_EXTERN 0x00000001
|
||||
#define HLSL_STORAGE_NOINTERPOLATION 0x00000002
|
||||
#define HLSL_MODIFIER_PRECISE 0x00000004
|
||||
#define HLSL_STORAGE_SHARED 0x00000008
|
||||
#define HLSL_STORAGE_GROUPSHARED 0x00000010
|
||||
#define HLSL_STORAGE_STATIC 0x00000020
|
||||
#define HLSL_STORAGE_UNIFORM 0x00000040
|
||||
#define HLSL_STORAGE_VOLATILE 0x00000080
|
||||
#define HLSL_MODIFIER_CONST 0x00000100
|
||||
#define HLSL_MODIFIER_ROW_MAJOR 0x00000200
|
||||
#define HLSL_MODIFIER_COLUMN_MAJOR 0x00000400
|
||||
#define HLSL_STORAGE_IN 0x00000800
|
||||
#define HLSL_STORAGE_OUT 0x00001000
|
||||
|
||||
#define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_STORAGE_VOLATILE | \
|
||||
HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \
|
||||
HLSL_MODIFIER_COLUMN_MAJOR)
|
||||
|
||||
#define HLSL_MODIFIERS_MAJORITY_MASK (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)
|
||||
|
||||
struct reg_reservation
|
||||
{
|
||||
enum bwritershader_param_register_type type;
|
||||
DWORD regnum;
|
||||
};
|
||||
|
||||
struct hlsl_ir_var
|
||||
{
|
||||
struct hlsl_type *data_type;
|
||||
struct source_location loc;
|
||||
const char *name;
|
||||
const char *semantic;
|
||||
unsigned int modifiers;
|
||||
const struct reg_reservation *reg_reservation;
|
||||
struct list scope_entry, param_entry;
|
||||
|
||||
unsigned int first_write, last_read;
|
||||
};
|
||||
|
||||
struct hlsl_ir_function
|
||||
{
|
||||
struct wine_rb_entry entry;
|
||||
const char *name;
|
||||
struct wine_rb_tree overloads;
|
||||
BOOL intrinsic;
|
||||
};
|
||||
|
||||
struct hlsl_ir_function_decl
|
||||
{
|
||||
struct hlsl_type *return_type;
|
||||
struct hlsl_ir_var *return_var;
|
||||
struct source_location loc;
|
||||
struct wine_rb_entry entry;
|
||||
struct hlsl_ir_function *func;
|
||||
const char *semantic;
|
||||
struct list *parameters;
|
||||
struct list *body;
|
||||
};
|
||||
|
||||
struct hlsl_ir_if
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
struct hlsl_src condition;
|
||||
struct list then_instrs;
|
||||
struct list else_instrs;
|
||||
};
|
||||
|
||||
struct hlsl_ir_loop
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
/* loop condition is stored in the body (as "if (!condition) break;") */
|
||||
struct list body;
|
||||
unsigned int next_index; /* liveness index of the end of the loop */
|
||||
};
|
||||
|
||||
enum hlsl_ir_expr_op {
|
||||
HLSL_IR_UNOP_BIT_NOT = 0,
|
||||
HLSL_IR_UNOP_LOGIC_NOT,
|
||||
HLSL_IR_UNOP_NEG,
|
||||
HLSL_IR_UNOP_ABS,
|
||||
HLSL_IR_UNOP_SIGN,
|
||||
HLSL_IR_UNOP_RCP,
|
||||
HLSL_IR_UNOP_RSQ,
|
||||
HLSL_IR_UNOP_SQRT,
|
||||
HLSL_IR_UNOP_NRM,
|
||||
HLSL_IR_UNOP_EXP2,
|
||||
HLSL_IR_UNOP_LOG2,
|
||||
|
||||
HLSL_IR_UNOP_CAST,
|
||||
|
||||
HLSL_IR_UNOP_FRACT,
|
||||
|
||||
HLSL_IR_UNOP_SIN,
|
||||
HLSL_IR_UNOP_COS,
|
||||
HLSL_IR_UNOP_SIN_REDUCED, /* Reduced range [-pi, pi] */
|
||||
HLSL_IR_UNOP_COS_REDUCED, /* Reduced range [-pi, pi] */
|
||||
|
||||
HLSL_IR_UNOP_DSX,
|
||||
HLSL_IR_UNOP_DSY,
|
||||
|
||||
HLSL_IR_UNOP_SAT,
|
||||
|
||||
HLSL_IR_UNOP_PREINC,
|
||||
HLSL_IR_UNOP_PREDEC,
|
||||
HLSL_IR_UNOP_POSTINC,
|
||||
HLSL_IR_UNOP_POSTDEC,
|
||||
|
||||
HLSL_IR_BINOP_ADD,
|
||||
HLSL_IR_BINOP_SUB,
|
||||
HLSL_IR_BINOP_MUL,
|
||||
HLSL_IR_BINOP_DIV,
|
||||
|
||||
HLSL_IR_BINOP_MOD,
|
||||
|
||||
HLSL_IR_BINOP_LESS,
|
||||
HLSL_IR_BINOP_GREATER,
|
||||
HLSL_IR_BINOP_LEQUAL,
|
||||
HLSL_IR_BINOP_GEQUAL,
|
||||
HLSL_IR_BINOP_EQUAL,
|
||||
HLSL_IR_BINOP_NEQUAL,
|
||||
|
||||
HLSL_IR_BINOP_LOGIC_AND,
|
||||
HLSL_IR_BINOP_LOGIC_OR,
|
||||
|
||||
HLSL_IR_BINOP_LSHIFT,
|
||||
HLSL_IR_BINOP_RSHIFT,
|
||||
HLSL_IR_BINOP_BIT_AND,
|
||||
HLSL_IR_BINOP_BIT_OR,
|
||||
HLSL_IR_BINOP_BIT_XOR,
|
||||
|
||||
HLSL_IR_BINOP_DOT,
|
||||
HLSL_IR_BINOP_CRS,
|
||||
HLSL_IR_BINOP_MIN,
|
||||
HLSL_IR_BINOP_MAX,
|
||||
|
||||
HLSL_IR_BINOP_POW,
|
||||
|
||||
HLSL_IR_TEROP_LERP,
|
||||
|
||||
HLSL_IR_SEQUENCE,
|
||||
};
|
||||
|
||||
struct hlsl_ir_expr
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
enum hlsl_ir_expr_op op;
|
||||
struct hlsl_src operands[3];
|
||||
};
|
||||
|
||||
enum hlsl_ir_jump_type
|
||||
{
|
||||
HLSL_IR_JUMP_BREAK,
|
||||
HLSL_IR_JUMP_CONTINUE,
|
||||
HLSL_IR_JUMP_DISCARD,
|
||||
HLSL_IR_JUMP_RETURN,
|
||||
};
|
||||
|
||||
struct hlsl_ir_jump
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
enum hlsl_ir_jump_type type;
|
||||
};
|
||||
|
||||
struct hlsl_ir_swizzle
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
struct hlsl_src val;
|
||||
DWORD swizzle;
|
||||
};
|
||||
|
||||
struct hlsl_deref
|
||||
{
|
||||
struct hlsl_ir_var *var;
|
||||
struct hlsl_src offset;
|
||||
};
|
||||
|
||||
struct hlsl_ir_load
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
struct hlsl_deref src;
|
||||
};
|
||||
|
||||
struct hlsl_ir_assignment
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
struct hlsl_deref lhs;
|
||||
struct hlsl_src rhs;
|
||||
unsigned char writemask;
|
||||
};
|
||||
|
||||
struct hlsl_ir_constant
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
union
|
||||
{
|
||||
unsigned u[4];
|
||||
int i[4];
|
||||
float f[4];
|
||||
double d[4];
|
||||
BOOL b[4];
|
||||
} value;
|
||||
};
|
||||
|
||||
struct hlsl_scope
|
||||
{
|
||||
struct list entry;
|
||||
struct list vars;
|
||||
struct wine_rb_tree types;
|
||||
struct hlsl_scope *upper;
|
||||
};
|
||||
|
||||
/* Structures used only during parsing */
|
||||
struct parse_parameter
|
||||
{
|
||||
struct hlsl_type *type;
|
||||
const char *name;
|
||||
const char *semantic;
|
||||
const struct reg_reservation *reg_reservation;
|
||||
unsigned int modifiers;
|
||||
};
|
||||
|
||||
struct parse_colon_attribute
|
||||
{
|
||||
const char *semantic;
|
||||
struct reg_reservation *reg_reservation;
|
||||
};
|
||||
|
||||
struct parse_initializer
|
||||
{
|
||||
struct hlsl_ir_node **args;
|
||||
unsigned int args_count;
|
||||
struct list *instrs;
|
||||
};
|
||||
|
||||
struct parse_variable_def
|
||||
{
|
||||
struct list entry;
|
||||
struct source_location loc;
|
||||
|
||||
char *name;
|
||||
unsigned int array_size;
|
||||
const char *semantic;
|
||||
struct reg_reservation *reg_reservation;
|
||||
struct parse_initializer initializer;
|
||||
};
|
||||
|
||||
struct parse_function
|
||||
{
|
||||
char *name;
|
||||
struct hlsl_ir_function_decl *decl;
|
||||
};
|
||||
|
||||
struct parse_if_body
|
||||
{
|
||||
struct list *then_instrs;
|
||||
struct list *else_instrs;
|
||||
};
|
||||
|
||||
enum parse_unary_op
|
||||
{
|
||||
UNARY_OP_PLUS,
|
||||
UNARY_OP_MINUS,
|
||||
UNARY_OP_LOGICNOT,
|
||||
UNARY_OP_BITNOT,
|
||||
};
|
||||
|
||||
enum parse_assign_op
|
||||
{
|
||||
ASSIGN_OP_ASSIGN,
|
||||
ASSIGN_OP_ADD,
|
||||
ASSIGN_OP_SUB,
|
||||
ASSIGN_OP_MUL,
|
||||
ASSIGN_OP_DIV,
|
||||
ASSIGN_OP_MOD,
|
||||
ASSIGN_OP_LSHIFT,
|
||||
ASSIGN_OP_RSHIFT,
|
||||
ASSIGN_OP_AND,
|
||||
ASSIGN_OP_OR,
|
||||
ASSIGN_OP_XOR,
|
||||
};
|
||||
|
||||
struct hlsl_parse_ctx
|
||||
{
|
||||
const char **source_files;
|
||||
unsigned int source_files_count;
|
||||
const char *source_file;
|
||||
unsigned int line_no;
|
||||
unsigned int column;
|
||||
enum parse_status status;
|
||||
struct compilation_messages messages;
|
||||
|
||||
struct hlsl_scope *cur_scope;
|
||||
struct hlsl_scope *globals;
|
||||
struct list scopes;
|
||||
|
||||
struct list types;
|
||||
struct wine_rb_tree functions;
|
||||
const struct hlsl_ir_function_decl *cur_function;
|
||||
|
||||
enum hlsl_matrix_majority matrix_majority;
|
||||
|
||||
struct
|
||||
{
|
||||
struct hlsl_type *scalar[HLSL_TYPE_LAST_SCALAR + 1];
|
||||
struct hlsl_type *vector[HLSL_TYPE_LAST_SCALAR + 1][4];
|
||||
struct hlsl_type *sampler[HLSL_SAMPLER_DIM_MAX + 1];
|
||||
struct hlsl_type *Void;
|
||||
} builtin_types;
|
||||
|
||||
struct list static_initializers;
|
||||
};
|
||||
|
||||
extern struct hlsl_parse_ctx hlsl_ctx DECLSPEC_HIDDEN;
|
||||
|
||||
enum hlsl_error_level
|
||||
{
|
||||
HLSL_LEVEL_ERROR = 0,
|
||||
HLSL_LEVEL_WARNING,
|
||||
HLSL_LEVEL_NOTE,
|
||||
};
|
||||
|
||||
void WINAPIV hlsl_message(const char *fmt, ...) PRINTF_ATTR(1,2) DECLSPEC_HIDDEN;
|
||||
void WINAPIV hlsl_report_message(const struct source_location loc,
|
||||
enum hlsl_error_level level, const char *fmt, ...) PRINTF_ATTR(3,4) DECLSPEC_HIDDEN;
|
||||
|
||||
static inline struct hlsl_ir_expr *expr_from_node(const struct hlsl_ir_node *node)
|
||||
{
|
||||
assert(node->type == HLSL_IR_EXPR);
|
||||
return CONTAINING_RECORD(node, struct hlsl_ir_expr, node);
|
||||
}
|
||||
|
||||
static inline struct hlsl_ir_load *load_from_node(const struct hlsl_ir_node *node)
|
||||
{
|
||||
assert(node->type == HLSL_IR_LOAD);
|
||||
return CONTAINING_RECORD(node, struct hlsl_ir_load, node);
|
||||
}
|
||||
|
||||
static inline struct hlsl_ir_constant *constant_from_node(const struct hlsl_ir_node *node)
|
||||
{
|
||||
assert(node->type == HLSL_IR_CONSTANT);
|
||||
return CONTAINING_RECORD(node, struct hlsl_ir_constant, node);
|
||||
}
|
||||
|
||||
static inline struct hlsl_ir_jump *jump_from_node(const struct hlsl_ir_node *node)
|
||||
{
|
||||
assert(node->type == HLSL_IR_JUMP);
|
||||
return CONTAINING_RECORD(node, struct hlsl_ir_jump, node);
|
||||
}
|
||||
|
||||
static inline struct hlsl_ir_assignment *assignment_from_node(const struct hlsl_ir_node *node)
|
||||
{
|
||||
assert(node->type == HLSL_IR_ASSIGNMENT);
|
||||
return CONTAINING_RECORD(node, struct hlsl_ir_assignment, node);
|
||||
}
|
||||
|
||||
static inline struct hlsl_ir_swizzle *swizzle_from_node(const struct hlsl_ir_node *node)
|
||||
{
|
||||
assert(node->type == HLSL_IR_SWIZZLE);
|
||||
return CONTAINING_RECORD(node, struct hlsl_ir_swizzle, node);
|
||||
}
|
||||
|
||||
static inline struct hlsl_ir_if *if_from_node(const struct hlsl_ir_node *node)
|
||||
{
|
||||
assert(node->type == HLSL_IR_IF);
|
||||
return CONTAINING_RECORD(node, struct hlsl_ir_if, node);
|
||||
}
|
||||
|
||||
static inline struct hlsl_ir_loop *loop_from_node(const struct hlsl_ir_node *node)
|
||||
{
|
||||
assert(node->type == HLSL_IR_LOOP);
|
||||
return CONTAINING_RECORD(node, struct hlsl_ir_loop, node);
|
||||
}
|
||||
|
||||
static inline struct hlsl_ir_node *node_from_list(struct list *list)
|
||||
{
|
||||
return LIST_ENTRY(list_tail(list), struct hlsl_ir_node, entry);
|
||||
}
|
||||
|
||||
static inline void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type type,
|
||||
struct hlsl_type *data_type, struct source_location loc)
|
||||
{
|
||||
node->type = type;
|
||||
node->data_type = data_type;
|
||||
node->loc = loc;
|
||||
list_init(&node->uses);
|
||||
}
|
||||
|
||||
static inline void hlsl_src_from_node(struct hlsl_src *src, struct hlsl_ir_node *node)
|
||||
{
|
||||
src->node = node;
|
||||
if (node)
|
||||
list_add_tail(&node->uses, &src->entry);
|
||||
}
|
||||
|
||||
static inline void hlsl_src_remove(struct hlsl_src *src)
|
||||
{
|
||||
if (src->node)
|
||||
list_remove(&src->entry);
|
||||
src->node = NULL;
|
||||
}
|
||||
|
||||
struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lhs,
|
||||
enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_expr *add_expr(struct list *instrs, enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[3],
|
||||
struct source_location *loc) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_node *add_implicit_conversion(struct list *instrs, struct hlsl_ir_node *node, struct hlsl_type *type,
|
||||
struct source_location *loc) DECLSPEC_HIDDEN;
|
||||
|
||||
struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
|
||||
struct source_location *loc) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_node *new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1,
|
||||
struct hlsl_ir_node *arg2) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_node *new_unary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
|
||||
struct source_location loc) DECLSPEC_HIDDEN;
|
||||
|
||||
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN;
|
||||
void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN;
|
||||
struct hlsl_type *new_hlsl_type(const char *name, enum hlsl_type_class type_class,
|
||||
enum hlsl_base_type base_type, unsigned dimx, unsigned dimy) DECLSPEC_HIDDEN;
|
||||
struct hlsl_type *new_array_type(struct hlsl_type *basic_type, unsigned int array_size) DECLSPEC_HIDDEN;
|
||||
struct hlsl_type *clone_hlsl_type(struct hlsl_type *old, unsigned int default_majority) DECLSPEC_HIDDEN;
|
||||
struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN;
|
||||
BOOL is_row_major(const struct hlsl_type *type) DECLSPEC_HIDDEN;
|
||||
BOOL find_function(const char *name) DECLSPEC_HIDDEN;
|
||||
unsigned int components_count_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
|
||||
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2) DECLSPEC_HIDDEN;
|
||||
BOOL compatible_data_types(struct hlsl_type *s1, struct hlsl_type *s2) DECLSPEC_HIDDEN;
|
||||
void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
|
||||
BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
|
||||
void init_functions_tree(struct wine_rb_tree *funcs) DECLSPEC_HIDDEN;
|
||||
void add_function_decl(struct wine_rb_tree *funcs, char *name, struct hlsl_ir_function_decl *decl,
|
||||
BOOL intrinsic) DECLSPEC_HIDDEN;
|
||||
HRESULT parse_hlsl_shader(const char *text, enum shader_type type, DWORD major, DWORD minor,
|
||||
const char *entrypoint, ID3D10Blob **shader, char **messages) DECLSPEC_HIDDEN;
|
||||
|
||||
const char *debug_base_type(const struct hlsl_type *type) DECLSPEC_HIDDEN;
|
||||
const char *debug_hlsl_type(const struct hlsl_type *type) DECLSPEC_HIDDEN;
|
||||
const char *debug_modifiers(DWORD modifiers) DECLSPEC_HIDDEN;
|
||||
const char *debug_node_type(enum hlsl_ir_node_type type) DECLSPEC_HIDDEN;
|
||||
void debug_dump_ir_function_decl(const struct hlsl_ir_function_decl *func) DECLSPEC_HIDDEN;
|
||||
|
||||
void free_hlsl_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
|
||||
void free_instr(struct hlsl_ir_node *node) DECLSPEC_HIDDEN;
|
||||
void free_instr_list(struct list *list) DECLSPEC_HIDDEN;
|
||||
void free_function_rb(struct wine_rb_entry *entry, void *context) DECLSPEC_HIDDEN;
|
||||
|
||||
#define MAKE_TAG(ch0, ch1, ch2, ch3) \
|
||||
((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
|
||||
((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
|
||||
|
|
|
@ -1,292 +0,0 @@
|
|||
/*
|
||||
* HLSL parser
|
||||
*
|
||||
* Copyright 2008 Stefan Dösinger
|
||||
* Copyright 2012 Matteo Bruni 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
|
||||
*/
|
||||
|
||||
%{
|
||||
#include "wine/debug.h"
|
||||
|
||||
#define YY_NO_UNISTD_H
|
||||
#include "d3dcompiler_private.h"
|
||||
#include "hlsl.tab.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(hlsl_parser);
|
||||
|
||||
#define YY_USER_ACTION \
|
||||
do { \
|
||||
hlsl_lloc.first_column = hlsl_ctx.column; \
|
||||
hlsl_lloc.first_line = hlsl_ctx.line_no; \
|
||||
hlsl_ctx.column += yyleng; \
|
||||
} while(0);
|
||||
|
||||
%}
|
||||
|
||||
%option noyywrap nounput noinput never-interactive
|
||||
%option prefix="hlsl_"
|
||||
|
||||
%x pp pp_line pp_pragma pp_ignore
|
||||
|
||||
RESERVED1 auto|case|catch|char|class|const_cast|default|delete|dynamic_cast|enum
|
||||
RESERVED2 explicit|friend|goto|long|mutable|new|operator|private|protected|public
|
||||
RESERVED3 reinterpret_cast|short|signed|sizeof|static_cast|template|this|throw|try
|
||||
RESERVED4 typename|union|unsigned|using|virtual
|
||||
|
||||
WS [ \t]
|
||||
NEWLINE (\n)|(\r\n)
|
||||
DOUBLESLASHCOMMENT "//"[^\n]*
|
||||
STRING \"[^\"]*\"
|
||||
IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
|
||||
|
||||
ANY (.)
|
||||
|
||||
%%
|
||||
{RESERVED1} {
|
||||
hlsl_message("Line %u: Reserved keyword \"%s\" used.\n", hlsl_ctx.line_no, yytext);
|
||||
set_parse_status(&hlsl_ctx.status, PARSE_ERR);
|
||||
}
|
||||
{RESERVED2} {
|
||||
hlsl_message("Line %u: Reserved keyword \"%s\" used.\n", hlsl_ctx.line_no, yytext);
|
||||
set_parse_status(&hlsl_ctx.status, PARSE_ERR);
|
||||
}
|
||||
{RESERVED3} {
|
||||
hlsl_message("Line %u: Reserved keyword \"%s\" used.\n", hlsl_ctx.line_no, yytext);
|
||||
set_parse_status(&hlsl_ctx.status, PARSE_ERR);
|
||||
}
|
||||
{RESERVED4} {
|
||||
hlsl_message("Line %u: Reserved keyword \"%s\" used.\n", hlsl_ctx.line_no, yytext);
|
||||
set_parse_status(&hlsl_ctx.status, PARSE_ERR);
|
||||
}
|
||||
|
||||
BlendState {return KW_BLENDSTATE; }
|
||||
break {return KW_BREAK; }
|
||||
Buffer {return KW_BUFFER; }
|
||||
cbuffer {return KW_CBUFFER; }
|
||||
compile {return KW_COMPILE; }
|
||||
const {return KW_CONST; }
|
||||
continue {return KW_CONTINUE; }
|
||||
DepthStencilState {return KW_DEPTHSTENCILSTATE; }
|
||||
DepthStencilView {return KW_DEPTHSTENCILVIEW; }
|
||||
discard {return KW_DISCARD; }
|
||||
do {return KW_DO; }
|
||||
double {return KW_DOUBLE; }
|
||||
else {return KW_ELSE; }
|
||||
extern {return KW_EXTERN; }
|
||||
false {return KW_FALSE; }
|
||||
for {return KW_FOR; }
|
||||
GeometryShader {return KW_GEOMETRYSHADER; }
|
||||
groupshared {return KW_GROUPSHARED; }
|
||||
if {return KW_IF; }
|
||||
in {return KW_IN; }
|
||||
inline {return KW_INLINE; }
|
||||
inout {return KW_INOUT; }
|
||||
matrix {return KW_MATRIX; }
|
||||
namespace {return KW_NAMESPACE; }
|
||||
nointerpolation {return KW_NOINTERPOLATION; }
|
||||
out {return KW_OUT; }
|
||||
pass {return KW_PASS; }
|
||||
PixelShader {return KW_PIXELSHADER; }
|
||||
precise {return KW_PRECISE; }
|
||||
RasterizerState {return KW_RASTERIZERSTATE; }
|
||||
RenderTargetView {return KW_RENDERTARGETVIEW; }
|
||||
return {return KW_RETURN; }
|
||||
register {return KW_REGISTER; }
|
||||
sampler {return KW_SAMPLER; }
|
||||
sampler1D {return KW_SAMPLER1D; }
|
||||
sampler2D {return KW_SAMPLER2D; }
|
||||
sampler3D {return KW_SAMPLER3D; }
|
||||
samplerCUBE {return KW_SAMPLERCUBE; }
|
||||
sampler_state {return KW_SAMPLER_STATE; }
|
||||
SamplerComparisonState {return KW_SAMPLERCOMPARISONSTATE;}
|
||||
shared {return KW_SHARED; }
|
||||
stateblock {return KW_STATEBLOCK; }
|
||||
stateblock_state {return KW_STATEBLOCK_STATE; }
|
||||
static {return KW_STATIC; }
|
||||
string {return KW_STRING; }
|
||||
struct {return KW_STRUCT; }
|
||||
switch {return KW_SWITCH; }
|
||||
tbuffer {return KW_TBUFFER; }
|
||||
technique {return KW_TECHNIQUE; }
|
||||
technique10 {return KW_TECHNIQUE10; }
|
||||
texture {return KW_TEXTURE; }
|
||||
texture1D {return KW_TEXTURE1D; }
|
||||
Texture1DArray {return KW_TEXTURE1DARRAY; }
|
||||
texture2D {return KW_TEXTURE2D; }
|
||||
Texture2DArray {return KW_TEXTURE2DARRAY; }
|
||||
Texture2DMS {return KW_TEXTURE2DMS; }
|
||||
Texture2DMSArray {return KW_TEXTURE2DMSARRAY; }
|
||||
texture3D {return KW_TEXTURE3D; }
|
||||
Texture3DArray {return KW_TEXTURE3DARRAY; }
|
||||
textureCUBE {return KW_TEXTURECUBE; }
|
||||
true {return KW_TRUE; }
|
||||
typedef {return KW_TYPEDEF; }
|
||||
uniform {return KW_UNIFORM; }
|
||||
vector {return KW_VECTOR; }
|
||||
VertexShader {return KW_VERTEXSHADER; }
|
||||
void {return KW_VOID; }
|
||||
volatile {return KW_VOLATILE; }
|
||||
while {return KW_WHILE; }
|
||||
|
||||
\+\+ {return OP_INC; }
|
||||
\-\- {return OP_DEC; }
|
||||
&& {return OP_AND; }
|
||||
\|\| {return OP_OR; }
|
||||
== {return OP_EQ; }
|
||||
\<\< {return OP_LEFTSHIFT; }
|
||||
\<\<= {return OP_LEFTSHIFTASSIGN; }
|
||||
\>\> {return OP_RIGHTSHIFT; }
|
||||
\>\>= {return OP_RIGHTSHIFTASSIGN; }
|
||||
\.\.\. {return OP_ELLIPSIS; }
|
||||
\<= {return OP_LE; }
|
||||
\>= {return OP_GE; }
|
||||
!= {return OP_NE; }
|
||||
\+= {return OP_ADDASSIGN; }
|
||||
\-= {return OP_SUBASSIGN; }
|
||||
\*= {return OP_MULASSIGN; }
|
||||
\/= {return OP_DIVASSIGN; }
|
||||
%= {return OP_MODASSIGN; }
|
||||
&= {return OP_ANDASSIGN; }
|
||||
\|= {return OP_ORASSIGN; }
|
||||
^= {return OP_XORASSIGN; }
|
||||
## {return OP_UNKNOWN1; }
|
||||
#@ {return OP_UNKNOWN2; }
|
||||
:: {return OP_UNKNOWN3; }
|
||||
\-\> {return OP_UNKNOWN4; }
|
||||
|
||||
column_major {return KW_COLUMN_MAJOR; }
|
||||
row_major {return KW_ROW_MAJOR; }
|
||||
|
||||
{IDENTIFIER} {
|
||||
hlsl_lval.name = d3dcompiler_strdup(yytext);
|
||||
if (get_variable(hlsl_ctx.cur_scope, yytext)
|
||||
|| find_function(yytext))
|
||||
return VAR_IDENTIFIER;
|
||||
else if (get_type(hlsl_ctx.cur_scope, yytext, TRUE))
|
||||
return TYPE_IDENTIFIER;
|
||||
else
|
||||
return NEW_IDENTIFIER;
|
||||
}
|
||||
|
||||
[0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[h|H|f|F]? {
|
||||
hlsl_lval.floatval = atof(yytext);
|
||||
return C_FLOAT;
|
||||
}
|
||||
[0-9]+\.([eE][+-]?[0-9]+)?[h|H|f|F]? {
|
||||
hlsl_lval.floatval = atof(yytext);
|
||||
return C_FLOAT;
|
||||
}
|
||||
[0-9]+([eE][+-]?[0-9]+)?[h|H|f|F] {
|
||||
hlsl_lval.floatval = atof(yytext);
|
||||
return C_FLOAT;
|
||||
}
|
||||
0x[0-9a-fA-F]+ {
|
||||
sscanf(yytext, "0x%x", &hlsl_lval.intval);
|
||||
return C_INTEGER;
|
||||
}
|
||||
0[0-7]+ {
|
||||
sscanf(yytext, "0%o", &hlsl_lval.intval);
|
||||
return C_INTEGER;
|
||||
}
|
||||
[0-9]+ {
|
||||
hlsl_lval.intval = (atoi(yytext));
|
||||
return C_INTEGER;
|
||||
}
|
||||
|
||||
{DOUBLESLASHCOMMENT} {}
|
||||
|
||||
{WS}+ {}
|
||||
{NEWLINE} {
|
||||
hlsl_ctx.line_no++;
|
||||
hlsl_ctx.column = 1;
|
||||
}
|
||||
|
||||
^# {
|
||||
BEGIN pp;
|
||||
}
|
||||
|
||||
<pp>pragma{WS}+ {
|
||||
TRACE("Got a #pragma.\n");
|
||||
BEGIN pp_pragma;
|
||||
}
|
||||
<pp_pragma>pack_matrix{WS}*\({WS}*row_major{WS}*\) {
|
||||
TRACE("#pragma setting row_major mode.\n");
|
||||
hlsl_ctx.matrix_majority = HLSL_ROW_MAJOR;
|
||||
BEGIN pp_ignore;
|
||||
}
|
||||
<pp_pragma>pack_matrix{WS}*\({WS}*column_major{WS}*\) {
|
||||
TRACE("#pragma setting column_major mode.\n");
|
||||
hlsl_ctx.matrix_majority = HLSL_COLUMN_MAJOR;
|
||||
BEGIN pp_ignore;
|
||||
}
|
||||
<pp_pragma>{NEWLINE} {
|
||||
FIXME("Unsupported preprocessor #pragma directive at line %u.\n", hlsl_ctx.line_no);
|
||||
BEGIN INITIAL;
|
||||
}
|
||||
<pp_pragma>{ANY} {}
|
||||
<pp>[0-9]+ {
|
||||
TRACE("Preprocessor line info.\n");
|
||||
BEGIN pp_line;
|
||||
hlsl_lval.intval = (atoi(yytext));
|
||||
return PRE_LINE;
|
||||
}
|
||||
<pp_line>{STRING} {
|
||||
char *string = d3dcompiler_strdup(yytext + 1);
|
||||
|
||||
BEGIN pp_ignore;
|
||||
string[strlen(string) - 1] = 0;
|
||||
hlsl_lval.name = string;
|
||||
return STRING;
|
||||
}
|
||||
<pp_line>{WS}+ {}
|
||||
<pp_line>{NEWLINE} {
|
||||
FIXME("Malformed preprocessor line directive?\n");
|
||||
BEGIN INITIAL;
|
||||
}
|
||||
<pp_ignore>{NEWLINE} {
|
||||
BEGIN INITIAL;
|
||||
}
|
||||
<pp_ignore>{ANY} {}
|
||||
<pp>{NEWLINE} {
|
||||
FIXME("Unexpected preprocessor directive.\n");
|
||||
BEGIN INITIAL;
|
||||
}
|
||||
<pp>{ANY} {}
|
||||
|
||||
{ANY} {
|
||||
return yytext[0];
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
HRESULT parse_hlsl(enum shader_type type, DWORD major, DWORD minor,
|
||||
const char *entrypoint, ID3D10Blob **shader, char **messages);
|
||||
|
||||
HRESULT parse_hlsl_shader(const char *text, enum shader_type type, DWORD major, DWORD minor,
|
||||
const char *entrypoint, ID3D10Blob **shader, char **messages)
|
||||
{
|
||||
YY_BUFFER_STATE buffer;
|
||||
HRESULT hr;
|
||||
|
||||
buffer = hlsl__scan_string(text);
|
||||
hlsl__switch_to_buffer(buffer);
|
||||
|
||||
hr = parse_hlsl(type, major, minor, entrypoint, shader, messages);
|
||||
|
||||
hlsl__delete_buffer(buffer);
|
||||
return hr;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue