2010-08-15 17:05:31 +02:00
|
|
|
/*
|
2010-08-24 23:05:12 +02:00
|
|
|
* Copyright 2008 Stefan Dösinger
|
|
|
|
* Copyright 2009 Matteo Bruni
|
2010-08-15 17:05:31 +02:00
|
|
|
* Copyright 2010 Rico Schüller
|
2012-05-08 16:17:32 +02:00
|
|
|
* Copyright 2012 Matteo Bruni for CodeWeavers
|
2010-08-15 17:05:31 +02:00
|
|
|
*
|
|
|
|
* 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 __WINE_D3DCOMPILER_PRIVATE_H
|
|
|
|
#define __WINE_D3DCOMPILER_PRIVATE_H
|
|
|
|
|
2010-10-03 15:11:54 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/list.h"
|
2011-02-21 22:52:13 +01:00
|
|
|
#include "wine/rbtree.h"
|
2019-05-07 22:42:24 +02:00
|
|
|
#include "wine/heap.h"
|
2010-08-15 17:05:31 +02:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
|
|
|
|
#include "d3dcompiler.h"
|
|
|
|
|
2012-06-07 00:19:04 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
2010-08-15 17:05:31 +02:00
|
|
|
/*
|
|
|
|
* This doesn't belong here, but for some functions it is possible to return that value,
|
|
|
|
* see http://msdn.microsoft.com/en-us/library/bb205278%28v=VS.85%29.aspx
|
|
|
|
* The original definition is in D3DX10core.h.
|
|
|
|
*/
|
|
|
|
#define D3DERR_INVALIDCALL 0x8876086c
|
|
|
|
|
2010-10-03 15:11:54 +02:00
|
|
|
/* TRACE helper functions */
|
2010-10-18 13:05:51 +02:00
|
|
|
const char *debug_d3dcompiler_d3d_blob_part(D3D_BLOB_PART part) DECLSPEC_HIDDEN;
|
2011-03-03 21:44:00 +01:00
|
|
|
const char *debug_d3dcompiler_shader_variable_class(D3D_SHADER_VARIABLE_CLASS c) DECLSPEC_HIDDEN;
|
2011-03-03 21:44:02 +01:00
|
|
|
const char *debug_d3dcompiler_shader_variable_type(D3D_SHADER_VARIABLE_TYPE t) DECLSPEC_HIDDEN;
|
2010-10-03 15:11:54 +02:00
|
|
|
|
2012-05-08 16:17:29 +02:00
|
|
|
enum shader_type
|
|
|
|
{
|
2013-05-12 23:55:51 +02:00
|
|
|
ST_UNKNOWN,
|
2010-08-24 23:05:12 +02:00
|
|
|
ST_VERTEX,
|
2013-05-12 23:55:51 +02:00
|
|
|
ST_PIXEL
|
2012-05-08 16:17:29 +02:00
|
|
|
};
|
2010-08-24 23:05:12 +02:00
|
|
|
|
2013-09-30 09:40:43 +02:00
|
|
|
enum bwriter_comparison_type
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
BWRITER_COMPARISON_NONE,
|
|
|
|
BWRITER_COMPARISON_GT,
|
|
|
|
BWRITER_COMPARISON_EQ,
|
|
|
|
BWRITER_COMPARISON_GE,
|
|
|
|
BWRITER_COMPARISON_LT,
|
|
|
|
BWRITER_COMPARISON_NE,
|
|
|
|
BWRITER_COMPARISON_LE
|
2013-09-30 09:40:43 +02:00
|
|
|
};
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
struct constant {
|
|
|
|
DWORD regnum;
|
|
|
|
union {
|
|
|
|
float f;
|
|
|
|
INT i;
|
|
|
|
BOOL b;
|
|
|
|
DWORD d;
|
|
|
|
} value[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct shader_reg {
|
|
|
|
DWORD type;
|
|
|
|
DWORD regnum;
|
|
|
|
struct shader_reg *rel_reg;
|
|
|
|
DWORD srcmod;
|
|
|
|
union {
|
|
|
|
DWORD swizzle;
|
|
|
|
DWORD writemask;
|
2010-08-29 23:40:33 +02:00
|
|
|
} u;
|
2010-08-24 23:05:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct instruction {
|
|
|
|
DWORD opcode;
|
|
|
|
DWORD dstmod;
|
|
|
|
DWORD shift;
|
2013-09-30 09:40:43 +02:00
|
|
|
enum bwriter_comparison_type comptype;
|
2010-08-24 23:05:12 +02:00
|
|
|
BOOL has_dst;
|
|
|
|
struct shader_reg dst;
|
|
|
|
struct shader_reg *src;
|
|
|
|
unsigned int num_srcs; /* For freeing the rel_regs */
|
|
|
|
BOOL has_predicate;
|
|
|
|
struct shader_reg predicate;
|
|
|
|
BOOL coissue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct declaration {
|
|
|
|
DWORD usage, usage_idx;
|
|
|
|
DWORD regnum;
|
|
|
|
DWORD mod;
|
|
|
|
DWORD writemask;
|
|
|
|
BOOL builtin;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct samplerdecl {
|
|
|
|
DWORD type;
|
|
|
|
DWORD regnum;
|
|
|
|
DWORD mod;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define INSTRARRAY_INITIAL_SIZE 8
|
|
|
|
struct bwriter_shader {
|
2012-05-08 16:17:29 +02:00
|
|
|
enum shader_type type;
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
/* Shader version selected */
|
|
|
|
DWORD version;
|
|
|
|
|
|
|
|
/* Local constants. Every constant that is not defined below is loaded from
|
|
|
|
* the global constant set at shader runtime
|
|
|
|
*/
|
|
|
|
struct constant **constF;
|
|
|
|
struct constant **constI;
|
|
|
|
struct constant **constB;
|
|
|
|
unsigned int num_cf, num_ci, num_cb;
|
|
|
|
|
|
|
|
/* Declared input and output varyings */
|
|
|
|
struct declaration *inputs, *outputs;
|
|
|
|
unsigned int num_inputs, num_outputs;
|
|
|
|
struct samplerdecl *samplers;
|
|
|
|
unsigned int num_samplers;
|
|
|
|
|
|
|
|
/* Are special pixel shader 3.0 registers declared? */
|
|
|
|
BOOL vPos, vFace;
|
|
|
|
|
|
|
|
/* Array of shader instructions - The shader code itself */
|
|
|
|
struct instruction **instr;
|
|
|
|
unsigned int num_instrs, instr_alloc_size;
|
|
|
|
};
|
|
|
|
|
2012-05-08 16:17:32 +02:00
|
|
|
static inline void *d3dcompiler_alloc(SIZE_T size)
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
|
|
|
}
|
|
|
|
|
2012-05-08 16:17:32 +02:00
|
|
|
static inline void *d3dcompiler_realloc(void *ptr, SIZE_T size)
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
|
|
|
|
}
|
|
|
|
|
2012-05-08 16:17:32 +02:00
|
|
|
static inline BOOL d3dcompiler_free(void *ptr)
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
return HeapFree(GetProcessHeap(), 0, ptr);
|
|
|
|
}
|
|
|
|
|
2012-05-15 16:12:57 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-08-24 23:05:12 +02:00
|
|
|
struct asm_parser;
|
|
|
|
|
|
|
|
/* This structure is only used in asmshader.y, but since the .l file accesses the semantic types
|
|
|
|
* too it has to know it as well
|
|
|
|
*/
|
|
|
|
struct rel_reg {
|
|
|
|
BOOL has_rel_reg;
|
|
|
|
DWORD type;
|
|
|
|
DWORD additional_offset;
|
|
|
|
DWORD rel_regnum;
|
|
|
|
DWORD swizzle;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_SRC_REGS 4
|
|
|
|
|
|
|
|
struct src_regs {
|
|
|
|
struct shader_reg reg[MAX_SRC_REGS];
|
|
|
|
unsigned int count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct asmparser_backend {
|
|
|
|
void (*constF)(struct asm_parser *This, DWORD reg, float x, float y, float z, float w);
|
|
|
|
void (*constI)(struct asm_parser *This, DWORD reg, INT x, INT y, INT z, INT w);
|
|
|
|
void (*constB)(struct asm_parser *This, DWORD reg, BOOL x);
|
|
|
|
|
|
|
|
void (*dstreg)(struct asm_parser *This, struct instruction *instr,
|
|
|
|
const struct shader_reg *dst);
|
|
|
|
void (*srcreg)(struct asm_parser *This, struct instruction *instr, int num,
|
|
|
|
const struct shader_reg *src);
|
|
|
|
|
|
|
|
void (*predicate)(struct asm_parser *This,
|
|
|
|
const struct shader_reg *predicate);
|
|
|
|
void (*coissue)(struct asm_parser *This);
|
|
|
|
|
|
|
|
void (*dcl_output)(struct asm_parser *This, DWORD usage, DWORD num,
|
|
|
|
const struct shader_reg *reg);
|
|
|
|
void (*dcl_input)(struct asm_parser *This, DWORD usage, DWORD num,
|
|
|
|
DWORD mod, const struct shader_reg *reg);
|
|
|
|
void (*dcl_sampler)(struct asm_parser *This, DWORD samptype, DWORD mod,
|
|
|
|
DWORD regnum, unsigned int line_no);
|
|
|
|
|
|
|
|
void (*end)(struct asm_parser *This);
|
|
|
|
|
2013-09-30 09:40:43 +02:00
|
|
|
void (*instr)(struct asm_parser *parser, DWORD opcode, DWORD mod, DWORD shift,
|
|
|
|
enum bwriter_comparison_type comp, const struct shader_reg *dst,
|
|
|
|
const struct src_regs *srcs, int expectednsrcs);
|
2010-08-24 23:05:12 +02:00
|
|
|
};
|
|
|
|
|
2010-10-18 13:05:51 +02:00
|
|
|
struct instruction *alloc_instr(unsigned int srcs) DECLSPEC_HIDDEN;
|
|
|
|
BOOL add_instruction(struct bwriter_shader *shader, struct instruction *instr) DECLSPEC_HIDDEN;
|
|
|
|
BOOL add_constF(struct bwriter_shader *shader, DWORD reg, float x, float y, float z, float w) DECLSPEC_HIDDEN;
|
|
|
|
BOOL add_constI(struct bwriter_shader *shader, DWORD reg, INT x, INT y, INT z, INT w) DECLSPEC_HIDDEN;
|
|
|
|
BOOL add_constB(struct bwriter_shader *shader, DWORD reg, BOOL x) DECLSPEC_HIDDEN;
|
|
|
|
BOOL record_declaration(struct bwriter_shader *shader, DWORD usage, DWORD usage_idx,
|
|
|
|
DWORD mod, BOOL output, DWORD regnum, DWORD writemask, BOOL builtin) DECLSPEC_HIDDEN;
|
|
|
|
BOOL record_sampler(struct bwriter_shader *shader, DWORD samptype, DWORD mod, DWORD regnum) DECLSPEC_HIDDEN;
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
#define MESSAGEBUFFER_INITIAL_SIZE 256
|
|
|
|
|
2012-05-08 16:17:30 +02:00
|
|
|
enum parse_status
|
|
|
|
{
|
|
|
|
PARSE_SUCCESS = 0,
|
|
|
|
PARSE_WARN = 1,
|
|
|
|
PARSE_ERR = 2
|
|
|
|
};
|
|
|
|
|
2012-05-08 16:17:31 +02:00
|
|
|
struct compilation_messages
|
|
|
|
{
|
|
|
|
char *string;
|
|
|
|
unsigned int size;
|
|
|
|
unsigned int capacity;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct asm_parser
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
/* The function table of the parser implementation */
|
|
|
|
const struct asmparser_backend *funcs;
|
|
|
|
|
|
|
|
/* Private data follows */
|
|
|
|
struct bwriter_shader *shader;
|
|
|
|
unsigned int m3x3pad_count;
|
|
|
|
|
2012-05-08 16:17:30 +02:00
|
|
|
enum parse_status status;
|
2012-05-08 16:17:31 +02:00
|
|
|
struct compilation_messages messages;
|
2010-08-24 23:05:12 +02:00
|
|
|
unsigned int line_no;
|
|
|
|
};
|
|
|
|
|
2010-10-18 13:05:51 +02:00
|
|
|
extern struct asm_parser asm_ctx DECLSPEC_HIDDEN;
|
2010-08-24 23:05:12 +02:00
|
|
|
|
2010-10-18 13:05:51 +02:00
|
|
|
void create_vs10_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_vs11_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_vs20_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_vs2x_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_vs30_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_ps10_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_ps11_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_ps12_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_ps13_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_ps14_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_ps20_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_ps2x_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
|
|
|
void create_ps30_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
|
2010-08-24 23:05:12 +02:00
|
|
|
|
2010-10-18 13:05:51 +02:00
|
|
|
struct bwriter_shader *parse_asm_shader(char **messages) DECLSPEC_HIDDEN;
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
|
|
|
|
#else
|
|
|
|
#define PRINTF_ATTR(fmt,args)
|
|
|
|
#endif
|
|
|
|
|
2019-07-02 13:37:18 +02:00
|
|
|
void compilation_message(struct compilation_messages *msg, const char *fmt, __ms_va_list args) DECLSPEC_HIDDEN;
|
2019-07-07 08:02:55 +02:00
|
|
|
void WINAPIV asmparser_message(struct asm_parser *ctx, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
|
2012-05-08 16:17:30 +02:00
|
|
|
static inline void set_parse_status(enum parse_status *current, enum parse_status update)
|
|
|
|
{
|
|
|
|
if (update == PARSE_ERR)
|
|
|
|
*current = PARSE_ERR;
|
|
|
|
else if (update == PARSE_WARN && *current == PARSE_SUCCESS)
|
|
|
|
*current = PARSE_WARN;
|
|
|
|
}
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
/* A reasonable value as initial size */
|
|
|
|
#define BYTECODEBUFFER_INITIAL_SIZE 32
|
|
|
|
struct bytecode_buffer {
|
|
|
|
DWORD *data;
|
|
|
|
DWORD size;
|
|
|
|
DWORD alloc_size;
|
|
|
|
/* For tracking rare out of memory situations without passing
|
|
|
|
* return values around everywhere
|
|
|
|
*/
|
|
|
|
HRESULT state;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bc_writer; /* Predeclaration for use in vtable parameters */
|
|
|
|
|
|
|
|
typedef void (*instr_writer)(struct bc_writer *This,
|
|
|
|
const struct instruction *instr,
|
|
|
|
struct bytecode_buffer *buffer);
|
|
|
|
|
|
|
|
struct bytecode_backend {
|
|
|
|
void (*header)(struct bc_writer *This, const struct bwriter_shader *shader,
|
2010-10-15 14:35:15 +02:00
|
|
|
struct bytecode_buffer *buffer);
|
2010-08-24 23:05:12 +02:00
|
|
|
void (*end)(struct bc_writer *This, const struct bwriter_shader *shader,
|
|
|
|
struct bytecode_buffer *buffer);
|
|
|
|
void (*srcreg)(struct bc_writer *This, const struct shader_reg *reg,
|
|
|
|
struct bytecode_buffer *buffer);
|
|
|
|
void (*dstreg)(struct bc_writer *This, const struct shader_reg *reg,
|
|
|
|
struct bytecode_buffer *buffer, DWORD shift, DWORD mod);
|
|
|
|
void (*opcode)(struct bc_writer *This, const struct instruction *instr,
|
|
|
|
DWORD token, struct bytecode_buffer *buffer);
|
|
|
|
|
|
|
|
const struct instr_handler_table {
|
|
|
|
DWORD opcode;
|
|
|
|
instr_writer func;
|
|
|
|
} *instructions;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Bytecode writing stuff */
|
|
|
|
struct bc_writer {
|
|
|
|
const struct bytecode_backend *funcs;
|
|
|
|
|
|
|
|
/* Avoid result checking */
|
|
|
|
HRESULT state;
|
|
|
|
|
|
|
|
DWORD version;
|
|
|
|
|
|
|
|
/* Vertex shader varying mapping */
|
|
|
|
DWORD oPos_regnum;
|
|
|
|
DWORD oD_regnum[2];
|
|
|
|
DWORD oT_regnum[8];
|
|
|
|
DWORD oFog_regnum;
|
|
|
|
DWORD oFog_mask;
|
|
|
|
DWORD oPts_regnum;
|
|
|
|
DWORD oPts_mask;
|
|
|
|
|
|
|
|
/* Pixel shader specific members */
|
|
|
|
DWORD t_regnum[8];
|
|
|
|
DWORD v_regnum[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Debug utility routines */
|
2010-10-18 13:05:51 +02:00
|
|
|
const char *debug_print_srcmod(DWORD mod) DECLSPEC_HIDDEN;
|
|
|
|
const char *debug_print_dstmod(DWORD mod) DECLSPEC_HIDDEN;
|
|
|
|
const char *debug_print_shift(DWORD shift) DECLSPEC_HIDDEN;
|
|
|
|
const char *debug_print_dstreg(const struct shader_reg *reg) DECLSPEC_HIDDEN;
|
|
|
|
const char *debug_print_srcreg(const struct shader_reg *reg) DECLSPEC_HIDDEN;
|
|
|
|
const char *debug_print_comp(DWORD comp) DECLSPEC_HIDDEN;
|
|
|
|
const char *debug_print_opcode(DWORD opcode) DECLSPEC_HIDDEN;
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
/* Used to signal an incorrect swizzle/writemask */
|
|
|
|
#define SWIZZLE_ERR ~0U
|
|
|
|
|
2013-10-01 10:38:32 +02:00
|
|
|
/* Enumerations and defines used in the bytecode writer intermediate
|
|
|
|
* representation. */
|
|
|
|
enum bwritershader_instruction_opcode_type
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
BWRITERSIO_NOP,
|
|
|
|
BWRITERSIO_MOV,
|
|
|
|
BWRITERSIO_ADD,
|
|
|
|
BWRITERSIO_SUB,
|
|
|
|
BWRITERSIO_MAD,
|
|
|
|
BWRITERSIO_MUL,
|
|
|
|
BWRITERSIO_RCP,
|
|
|
|
BWRITERSIO_RSQ,
|
|
|
|
BWRITERSIO_DP3,
|
|
|
|
BWRITERSIO_DP4,
|
|
|
|
BWRITERSIO_MIN,
|
|
|
|
BWRITERSIO_MAX,
|
|
|
|
BWRITERSIO_SLT,
|
|
|
|
BWRITERSIO_SGE,
|
|
|
|
BWRITERSIO_EXP,
|
|
|
|
BWRITERSIO_LOG,
|
|
|
|
BWRITERSIO_LIT,
|
|
|
|
BWRITERSIO_DST,
|
|
|
|
BWRITERSIO_LRP,
|
|
|
|
BWRITERSIO_FRC,
|
|
|
|
BWRITERSIO_M4x4,
|
|
|
|
BWRITERSIO_M4x3,
|
|
|
|
BWRITERSIO_M3x4,
|
|
|
|
BWRITERSIO_M3x3,
|
|
|
|
BWRITERSIO_M3x2,
|
|
|
|
BWRITERSIO_CALL,
|
|
|
|
BWRITERSIO_CALLNZ,
|
|
|
|
BWRITERSIO_LOOP,
|
|
|
|
BWRITERSIO_RET,
|
|
|
|
BWRITERSIO_ENDLOOP,
|
|
|
|
BWRITERSIO_LABEL,
|
|
|
|
BWRITERSIO_DCL,
|
|
|
|
BWRITERSIO_POW,
|
|
|
|
BWRITERSIO_CRS,
|
|
|
|
BWRITERSIO_SGN,
|
|
|
|
BWRITERSIO_ABS,
|
|
|
|
BWRITERSIO_NRM,
|
|
|
|
BWRITERSIO_SINCOS,
|
|
|
|
BWRITERSIO_REP,
|
|
|
|
BWRITERSIO_ENDREP,
|
|
|
|
BWRITERSIO_IF,
|
|
|
|
BWRITERSIO_IFC,
|
|
|
|
BWRITERSIO_ELSE,
|
|
|
|
BWRITERSIO_ENDIF,
|
|
|
|
BWRITERSIO_BREAK,
|
|
|
|
BWRITERSIO_BREAKC,
|
|
|
|
BWRITERSIO_MOVA,
|
|
|
|
BWRITERSIO_DEFB,
|
|
|
|
BWRITERSIO_DEFI,
|
|
|
|
|
|
|
|
BWRITERSIO_TEXCOORD,
|
|
|
|
BWRITERSIO_TEXKILL,
|
|
|
|
BWRITERSIO_TEX,
|
|
|
|
BWRITERSIO_TEXBEM,
|
|
|
|
BWRITERSIO_TEXBEML,
|
|
|
|
BWRITERSIO_TEXREG2AR,
|
|
|
|
BWRITERSIO_TEXREG2GB,
|
|
|
|
BWRITERSIO_TEXM3x2PAD,
|
|
|
|
BWRITERSIO_TEXM3x2TEX,
|
|
|
|
BWRITERSIO_TEXM3x3PAD,
|
|
|
|
BWRITERSIO_TEXM3x3TEX,
|
|
|
|
BWRITERSIO_TEXM3x3SPEC,
|
|
|
|
BWRITERSIO_TEXM3x3VSPEC,
|
|
|
|
BWRITERSIO_EXPP,
|
|
|
|
BWRITERSIO_LOGP,
|
|
|
|
BWRITERSIO_CND,
|
|
|
|
BWRITERSIO_DEF,
|
|
|
|
BWRITERSIO_TEXREG2RGB,
|
|
|
|
BWRITERSIO_TEXDP3TEX,
|
|
|
|
BWRITERSIO_TEXM3x2DEPTH,
|
|
|
|
BWRITERSIO_TEXDP3,
|
|
|
|
BWRITERSIO_TEXM3x3,
|
|
|
|
BWRITERSIO_TEXDEPTH,
|
|
|
|
BWRITERSIO_CMP,
|
|
|
|
BWRITERSIO_BEM,
|
|
|
|
BWRITERSIO_DP2ADD,
|
|
|
|
BWRITERSIO_DSX,
|
|
|
|
BWRITERSIO_DSY,
|
|
|
|
BWRITERSIO_TEXLDD,
|
|
|
|
BWRITERSIO_SETP,
|
|
|
|
BWRITERSIO_TEXLDL,
|
|
|
|
BWRITERSIO_BREAKP,
|
|
|
|
BWRITERSIO_TEXLDP,
|
|
|
|
BWRITERSIO_TEXLDB,
|
|
|
|
|
|
|
|
BWRITERSIO_PHASE,
|
|
|
|
BWRITERSIO_COMMENT,
|
|
|
|
BWRITERSIO_END,
|
2013-10-01 10:38:32 +02:00
|
|
|
};
|
2010-08-24 23:05:12 +02:00
|
|
|
|
2013-10-01 10:38:33 +02:00
|
|
|
enum bwritershader_param_register_type
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
BWRITERSPR_TEMP,
|
|
|
|
BWRITERSPR_INPUT,
|
|
|
|
BWRITERSPR_CONST,
|
|
|
|
BWRITERSPR_ADDR,
|
|
|
|
BWRITERSPR_TEXTURE,
|
|
|
|
BWRITERSPR_RASTOUT,
|
|
|
|
BWRITERSPR_ATTROUT,
|
|
|
|
BWRITERSPR_TEXCRDOUT,
|
|
|
|
BWRITERSPR_OUTPUT,
|
|
|
|
BWRITERSPR_CONSTINT,
|
|
|
|
BWRITERSPR_COLOROUT,
|
|
|
|
BWRITERSPR_DEPTHOUT,
|
|
|
|
BWRITERSPR_SAMPLER,
|
|
|
|
BWRITERSPR_CONSTBOOL,
|
|
|
|
BWRITERSPR_LOOP,
|
|
|
|
BWRITERSPR_MISCTYPE,
|
|
|
|
BWRITERSPR_LABEL,
|
|
|
|
BWRITERSPR_PREDICATE
|
2013-10-01 10:38:33 +02:00
|
|
|
};
|
2010-08-24 23:05:12 +02:00
|
|
|
|
2013-10-02 09:55:27 +02:00
|
|
|
enum bwritervs_rastout_offsets
|
2010-08-24 23:05:12 +02:00
|
|
|
{
|
|
|
|
BWRITERSRO_POSITION,
|
|
|
|
BWRITERSRO_FOG,
|
|
|
|
BWRITERSRO_POINT_SIZE
|
2013-10-02 09:55:27 +02:00
|
|
|
};
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
#define BWRITERSP_WRITEMASK_0 0x1 /* .x r */
|
|
|
|
#define BWRITERSP_WRITEMASK_1 0x2 /* .y g */
|
|
|
|
#define BWRITERSP_WRITEMASK_2 0x4 /* .z b */
|
|
|
|
#define BWRITERSP_WRITEMASK_3 0x8 /* .w a */
|
|
|
|
#define BWRITERSP_WRITEMASK_ALL 0xf /* all */
|
|
|
|
|
2013-10-02 09:55:28 +02:00
|
|
|
enum bwritershader_param_dstmod_type
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
BWRITERSPDM_NONE = 0,
|
|
|
|
BWRITERSPDM_SATURATE = 1,
|
|
|
|
BWRITERSPDM_PARTIALPRECISION = 2,
|
|
|
|
BWRITERSPDM_MSAMPCENTROID = 4,
|
2013-10-02 09:55:28 +02:00
|
|
|
};
|
2010-08-24 23:05:12 +02:00
|
|
|
|
2013-10-03 08:54:14 +02:00
|
|
|
enum bwritersampler_texture_type
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
BWRITERSTT_UNKNOWN = 0,
|
|
|
|
BWRITERSTT_1D = 1,
|
|
|
|
BWRITERSTT_2D = 2,
|
|
|
|
BWRITERSTT_CUBE = 3,
|
|
|
|
BWRITERSTT_VOLUME = 4,
|
2013-10-03 08:54:14 +02:00
|
|
|
};
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
#define BWRITERSI_TEXLD_PROJECT 1
|
|
|
|
#define BWRITERSI_TEXLD_BIAS 2
|
|
|
|
|
2013-10-03 08:54:15 +02:00
|
|
|
enum bwritershader_param_srcmod_type
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
BWRITERSPSM_NONE = 0,
|
|
|
|
BWRITERSPSM_NEG,
|
|
|
|
BWRITERSPSM_BIAS,
|
|
|
|
BWRITERSPSM_BIASNEG,
|
|
|
|
BWRITERSPSM_SIGN,
|
|
|
|
BWRITERSPSM_SIGNNEG,
|
|
|
|
BWRITERSPSM_COMP,
|
|
|
|
BWRITERSPSM_X2,
|
|
|
|
BWRITERSPSM_X2NEG,
|
|
|
|
BWRITERSPSM_DZ,
|
|
|
|
BWRITERSPSM_DW,
|
|
|
|
BWRITERSPSM_ABS,
|
|
|
|
BWRITERSPSM_ABSNEG,
|
|
|
|
BWRITERSPSM_NOT,
|
2013-10-03 08:54:15 +02:00
|
|
|
};
|
2010-08-24 23:05:12 +02:00
|
|
|
|
2015-08-10 12:31:25 +02:00
|
|
|
#define BWRITER_SM1_VS 0xfffeu
|
|
|
|
#define BWRITER_SM1_PS 0xffffu
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
#define BWRITERPS_VERSION(major, minor) ((BWRITER_SM1_PS << 16) | ((major) << 8) | (minor))
|
|
|
|
#define BWRITERVS_VERSION(major, minor) ((BWRITER_SM1_VS << 16) | ((major) << 8) | (minor))
|
|
|
|
|
2020-02-05 21:52:32 +01:00
|
|
|
#define BWRITERVS_X_X (0)
|
|
|
|
#define BWRITERVS_X_Y (1)
|
|
|
|
#define BWRITERVS_X_Z (2)
|
|
|
|
#define BWRITERVS_X_W (3)
|
|
|
|
|
|
|
|
#define BWRITERVS_Y_X (0 << 2)
|
|
|
|
#define BWRITERVS_Y_Y (1 << 2)
|
|
|
|
#define BWRITERVS_Y_Z (2 << 2)
|
|
|
|
#define BWRITERVS_Y_W (3 << 2)
|
|
|
|
|
|
|
|
#define BWRITERVS_Z_X (0 << 4)
|
|
|
|
#define BWRITERVS_Z_Y (1 << 4)
|
|
|
|
#define BWRITERVS_Z_Z (2 << 4)
|
|
|
|
#define BWRITERVS_Z_W (3 << 4)
|
|
|
|
|
|
|
|
#define BWRITERVS_W_X (0 << 6)
|
|
|
|
#define BWRITERVS_W_Y (1 << 6)
|
|
|
|
#define BWRITERVS_W_Z (2 << 6)
|
|
|
|
#define BWRITERVS_W_W (3 << 6)
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
#define BWRITERVS_NOSWIZZLE (BWRITERVS_X_X | BWRITERVS_Y_Y | BWRITERVS_Z_Z | BWRITERVS_W_W)
|
|
|
|
|
|
|
|
#define BWRITERVS_SWIZZLE_X (BWRITERVS_X_X | BWRITERVS_Y_X | BWRITERVS_Z_X | BWRITERVS_W_X)
|
|
|
|
#define BWRITERVS_SWIZZLE_Y (BWRITERVS_X_Y | BWRITERVS_Y_Y | BWRITERVS_Z_Y | BWRITERVS_W_Y)
|
|
|
|
#define BWRITERVS_SWIZZLE_Z (BWRITERVS_X_Z | BWRITERVS_Y_Z | BWRITERVS_Z_Z | BWRITERVS_W_Z)
|
|
|
|
#define BWRITERVS_SWIZZLE_W (BWRITERVS_X_W | BWRITERVS_Y_W | BWRITERVS_Z_W | BWRITERVS_W_W)
|
|
|
|
|
2013-10-03 23:31:47 +02:00
|
|
|
enum bwriterdeclusage
|
|
|
|
{
|
2010-08-24 23:05:12 +02:00
|
|
|
BWRITERDECLUSAGE_POSITION,
|
|
|
|
BWRITERDECLUSAGE_BLENDWEIGHT,
|
|
|
|
BWRITERDECLUSAGE_BLENDINDICES,
|
|
|
|
BWRITERDECLUSAGE_NORMAL,
|
|
|
|
BWRITERDECLUSAGE_PSIZE,
|
|
|
|
BWRITERDECLUSAGE_TEXCOORD,
|
|
|
|
BWRITERDECLUSAGE_TANGENT,
|
|
|
|
BWRITERDECLUSAGE_BINORMAL,
|
|
|
|
BWRITERDECLUSAGE_TESSFACTOR,
|
|
|
|
BWRITERDECLUSAGE_POSITIONT,
|
|
|
|
BWRITERDECLUSAGE_COLOR,
|
|
|
|
BWRITERDECLUSAGE_FOG,
|
|
|
|
BWRITERDECLUSAGE_DEPTH,
|
|
|
|
BWRITERDECLUSAGE_SAMPLE
|
2013-10-03 23:31:47 +02:00
|
|
|
};
|
2010-08-24 23:05:12 +02:00
|
|
|
|
|
|
|
/* ps 1.x texture registers mappings */
|
|
|
|
#define T0_REG 2
|
|
|
|
#define T1_REG 3
|
|
|
|
#define T2_REG 4
|
|
|
|
#define T3_REG 5
|
|
|
|
|
2010-10-18 13:05:51 +02:00
|
|
|
struct bwriter_shader *SlAssembleShader(const char *text, char **messages) DECLSPEC_HIDDEN;
|
2012-05-15 16:12:53 +02:00
|
|
|
HRESULT SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result, DWORD *size) DECLSPEC_HIDDEN;
|
2010-10-18 13:05:51 +02:00
|
|
|
void SlDeleteShader(struct bwriter_shader *shader) DECLSPEC_HIDDEN;
|
2010-08-24 23:05:12 +02:00
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2012-06-07 00:19:02 +02:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2012-06-11 19:18:32 +02:00
|
|
|
enum hlsl_sampler_dim
|
|
|
|
{
|
|
|
|
HLSL_SAMPLER_DIM_GENERIC,
|
|
|
|
HLSL_SAMPLER_DIM_1D,
|
|
|
|
HLSL_SAMPLER_DIM_2D,
|
|
|
|
HLSL_SAMPLER_DIM_3D,
|
|
|
|
HLSL_SAMPLER_DIM_CUBE,
|
|
|
|
};
|
|
|
|
|
2012-05-15 16:12:56 +02:00
|
|
|
enum hlsl_matrix_majority
|
|
|
|
{
|
|
|
|
HLSL_COLUMN_MAJOR,
|
|
|
|
HLSL_ROW_MAJOR
|
|
|
|
};
|
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
struct hlsl_type
|
|
|
|
{
|
|
|
|
struct list entry;
|
2012-09-19 19:46:12 +02:00
|
|
|
struct wine_rb_entry scope_entry;
|
2012-06-07 00:19:02 +02:00
|
|
|
enum hlsl_type_class type;
|
2012-06-04 17:58:24 +02:00
|
|
|
enum hlsl_base_type base_type;
|
2012-06-11 19:18:32 +02:00
|
|
|
enum hlsl_sampler_dim sampler_dim;
|
2012-06-04 17:58:24 +02:00
|
|
|
const char *name;
|
|
|
|
unsigned int modifiers;
|
|
|
|
unsigned int dimx;
|
|
|
|
unsigned int dimy;
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2012-07-12 16:01:34 +02:00
|
|
|
struct source_location
|
|
|
|
{
|
|
|
|
const char *file;
|
|
|
|
unsigned int line;
|
|
|
|
unsigned int col;
|
|
|
|
};
|
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
enum hlsl_ir_node_type
|
|
|
|
{
|
2019-08-13 17:23:32 +02:00
|
|
|
HLSL_IR_ASSIGNMENT = 0,
|
2012-06-07 00:19:04 +02:00
|
|
|
HLSL_IR_CONSTANT,
|
2012-06-11 19:18:35 +02:00
|
|
|
HLSL_IR_CONSTRUCTOR,
|
2012-06-07 00:19:05 +02:00
|
|
|
HLSL_IR_DEREF,
|
2012-07-16 20:39:23 +02:00
|
|
|
HLSL_IR_EXPR,
|
2012-09-19 19:46:11 +02:00
|
|
|
HLSL_IR_IF,
|
2012-09-21 16:25:56 +02:00
|
|
|
HLSL_IR_LOOP,
|
2012-09-18 18:18:08 +02:00
|
|
|
HLSL_IR_JUMP,
|
2012-09-17 15:32:04 +02:00
|
|
|
HLSL_IR_SWIZZLE,
|
2012-06-04 17:58:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct hlsl_ir_node
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
enum hlsl_ir_node_type type;
|
|
|
|
struct hlsl_type *data_type;
|
|
|
|
|
2012-07-12 16:01:34 +02:00
|
|
|
struct source_location loc;
|
2012-06-04 17:58:24 +02:00
|
|
|
};
|
|
|
|
|
2012-06-07 00:19:03 +02:00
|
|
|
#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_MODIFIER_IN 0x00000800
|
|
|
|
#define HLSL_MODIFIER_OUT 0x00001000
|
|
|
|
|
2012-09-19 19:46:13 +02:00
|
|
|
#define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_STORAGE_VOLATILE | \
|
|
|
|
HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \
|
|
|
|
HLSL_MODIFIER_COLUMN_MAJOR)
|
|
|
|
|
2012-09-18 18:18:07 +02:00
|
|
|
#define HLSL_MODIFIERS_COMPARISON_MASK (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)
|
|
|
|
|
2015-06-16 22:45:44 +02:00
|
|
|
struct reg_reservation
|
|
|
|
{
|
|
|
|
enum bwritershader_param_register_type type;
|
|
|
|
DWORD regnum;
|
|
|
|
};
|
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
struct hlsl_ir_var
|
|
|
|
{
|
2019-08-13 17:23:32 +02:00
|
|
|
struct hlsl_type *data_type;
|
|
|
|
struct source_location loc;
|
2012-06-04 17:58:24 +02:00
|
|
|
const char *name;
|
|
|
|
const char *semantic;
|
|
|
|
unsigned int modifiers;
|
2015-06-16 22:45:44 +02:00
|
|
|
const struct reg_reservation *reg_reservation;
|
2019-08-13 17:23:32 +02:00
|
|
|
struct list scope_entry, param_entry;
|
2012-06-04 17:58:24 +02:00
|
|
|
|
|
|
|
struct hlsl_var_allocation *allocation;
|
|
|
|
};
|
|
|
|
|
2012-10-11 19:48:48 +02:00
|
|
|
struct hlsl_ir_function
|
|
|
|
{
|
|
|
|
struct wine_rb_entry entry;
|
|
|
|
const char *name;
|
|
|
|
struct wine_rb_tree overloads;
|
|
|
|
BOOL intrinsic;
|
|
|
|
};
|
|
|
|
|
2012-06-11 19:18:33 +02:00
|
|
|
struct hlsl_ir_function_decl
|
|
|
|
{
|
2019-08-13 17:23:31 +02:00
|
|
|
struct hlsl_type *return_type;
|
|
|
|
struct source_location loc;
|
2012-10-11 19:48:48 +02:00
|
|
|
struct wine_rb_entry entry;
|
|
|
|
struct hlsl_ir_function *func;
|
2012-06-11 19:18:33 +02:00
|
|
|
const char *semantic;
|
|
|
|
struct list *parameters;
|
|
|
|
struct list *body;
|
|
|
|
};
|
|
|
|
|
2012-09-19 19:46:11 +02:00
|
|
|
struct hlsl_ir_if
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node node;
|
|
|
|
struct hlsl_ir_node *condition;
|
|
|
|
struct list *then_instrs;
|
|
|
|
struct list *else_instrs;
|
|
|
|
};
|
|
|
|
|
2012-09-21 16:25:56 +02:00
|
|
|
struct hlsl_ir_loop
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node node;
|
|
|
|
/* loop condition is stored in the body (as "if (!condition) break;") */
|
|
|
|
struct list *body;
|
|
|
|
};
|
|
|
|
|
2012-07-20 16:37:41 +02:00
|
|
|
struct hlsl_ir_assignment
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node node;
|
|
|
|
struct hlsl_ir_node *lhs;
|
|
|
|
struct hlsl_ir_node *rhs;
|
|
|
|
unsigned char writemask;
|
|
|
|
};
|
|
|
|
|
2012-07-16 20:39:23 +02:00
|
|
|
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,
|
|
|
|
|
2014-05-02 16:30:13 +02:00
|
|
|
HLSL_IR_UNOP_PREINC,
|
|
|
|
HLSL_IR_UNOP_PREDEC,
|
|
|
|
HLSL_IR_UNOP_POSTINC,
|
|
|
|
HLSL_IR_UNOP_POSTDEC,
|
|
|
|
|
2012-07-16 20:39:23 +02:00
|
|
|
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_ir_node *operands[3];
|
|
|
|
};
|
|
|
|
|
2012-09-18 18:18:08 +02:00
|
|
|
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_node *return_value;
|
|
|
|
};
|
|
|
|
|
2012-09-17 15:32:04 +02:00
|
|
|
struct hlsl_ir_swizzle
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node node;
|
|
|
|
struct hlsl_ir_node *val;
|
|
|
|
DWORD swizzle;
|
|
|
|
};
|
|
|
|
|
2012-06-07 00:19:05 +02:00
|
|
|
enum hlsl_ir_deref_type
|
|
|
|
{
|
|
|
|
HLSL_IR_DEREF_VAR,
|
|
|
|
HLSL_IR_DEREF_ARRAY,
|
|
|
|
HLSL_IR_DEREF_RECORD,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hlsl_ir_deref
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node node;
|
|
|
|
enum hlsl_ir_deref_type type;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct hlsl_ir_var *var;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node *array;
|
|
|
|
struct hlsl_ir_node *index;
|
|
|
|
} array;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node *record;
|
2012-09-26 19:22:34 +02:00
|
|
|
struct hlsl_struct_field *field;
|
2012-06-07 00:19:05 +02:00
|
|
|
} record;
|
|
|
|
} v;
|
|
|
|
};
|
|
|
|
|
2012-06-07 00:19:04 +02:00
|
|
|
struct hlsl_ir_constant
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node node;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
unsigned u[16];
|
|
|
|
int i[16];
|
|
|
|
float f[16];
|
|
|
|
double d[16];
|
|
|
|
BOOL b[16];
|
|
|
|
} value;
|
|
|
|
struct hlsl_ir_constant *array_elements;
|
|
|
|
struct list *struct_elements;
|
|
|
|
} v;
|
|
|
|
};
|
|
|
|
|
2012-06-11 19:18:35 +02:00
|
|
|
struct hlsl_ir_constructor
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node node;
|
2019-08-09 16:52:45 +02:00
|
|
|
struct hlsl_ir_node *args[16];
|
|
|
|
unsigned int args_count;
|
2012-06-11 19:18:35 +02:00
|
|
|
};
|
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
struct hlsl_scope
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
struct list vars;
|
2012-09-19 19:46:12 +02:00
|
|
|
struct wine_rb_tree types;
|
2012-06-04 17:58:24 +02:00
|
|
|
struct hlsl_scope *upper;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Structures used only during parsing */
|
2012-06-11 19:18:33 +02:00
|
|
|
struct parse_parameter
|
|
|
|
{
|
|
|
|
struct hlsl_type *type;
|
|
|
|
const char *name;
|
|
|
|
const char *semantic;
|
2015-06-16 22:45:44 +02:00
|
|
|
const struct reg_reservation *reg_reservation;
|
2012-06-11 19:18:33 +02:00
|
|
|
unsigned int modifiers;
|
|
|
|
};
|
|
|
|
|
2015-06-16 22:45:44 +02:00
|
|
|
struct parse_colon_attribute
|
|
|
|
{
|
|
|
|
const char *semantic;
|
|
|
|
struct reg_reservation *reg_reservation;
|
|
|
|
};
|
|
|
|
|
2019-08-12 17:27:28 +02:00
|
|
|
struct parse_initializer
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node **args;
|
|
|
|
unsigned int args_count;
|
2020-02-13 04:57:18 +01:00
|
|
|
struct list *instrs;
|
2019-08-12 17:27:28 +02:00
|
|
|
};
|
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
struct parse_variable_def
|
|
|
|
{
|
|
|
|
struct list entry;
|
2012-07-12 16:01:35 +02:00
|
|
|
struct source_location loc;
|
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
char *name;
|
|
|
|
unsigned int array_size;
|
2015-06-16 22:45:44 +02:00
|
|
|
const char *semantic;
|
|
|
|
struct reg_reservation *reg_reservation;
|
2019-08-12 17:27:28 +02:00
|
|
|
struct parse_initializer initializer;
|
2012-06-04 17:58:24 +02:00
|
|
|
};
|
|
|
|
|
2012-10-11 19:48:48 +02:00
|
|
|
struct parse_function
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
struct hlsl_ir_function_decl *decl;
|
|
|
|
};
|
|
|
|
|
2012-09-19 19:46:11 +02:00
|
|
|
struct parse_if_body
|
|
|
|
{
|
|
|
|
struct list *then_instrs;
|
|
|
|
struct list *else_instrs;
|
|
|
|
};
|
|
|
|
|
2012-07-20 16:37:38 +02:00
|
|
|
enum parse_unary_op
|
|
|
|
{
|
|
|
|
UNARY_OP_PLUS,
|
|
|
|
UNARY_OP_MINUS,
|
|
|
|
UNARY_OP_LOGICNOT,
|
|
|
|
UNARY_OP_BITNOT,
|
|
|
|
};
|
|
|
|
|
2012-07-20 16:37:40 +02:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2012-05-15 16:12:56 +02:00
|
|
|
struct hlsl_parse_ctx
|
|
|
|
{
|
2012-07-12 16:01:33 +02:00
|
|
|
const char **source_files;
|
|
|
|
unsigned int source_files_count;
|
|
|
|
const char *source_file;
|
2012-05-15 16:12:56 +02:00
|
|
|
unsigned int line_no;
|
2012-07-12 16:01:33 +02:00
|
|
|
unsigned int column;
|
2012-05-15 16:12:56 +02:00
|
|
|
enum parse_status status;
|
|
|
|
struct compilation_messages messages;
|
|
|
|
|
|
|
|
struct hlsl_scope *cur_scope;
|
|
|
|
struct hlsl_scope *globals;
|
|
|
|
struct list scopes;
|
|
|
|
|
|
|
|
struct list types;
|
2012-10-11 19:48:48 +02:00
|
|
|
struct wine_rb_tree functions;
|
2020-03-02 05:55:26 +01:00
|
|
|
const struct hlsl_ir_function_decl *cur_function;
|
2012-05-15 16:12:56 +02:00
|
|
|
|
|
|
|
enum hlsl_matrix_majority matrix_majority;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct hlsl_parse_ctx hlsl_ctx DECLSPEC_HIDDEN;
|
|
|
|
|
2012-07-12 16:01:32 +02:00
|
|
|
enum hlsl_error_level
|
|
|
|
{
|
|
|
|
HLSL_LEVEL_ERROR = 0,
|
|
|
|
HLSL_LEVEL_WARNING,
|
|
|
|
HLSL_LEVEL_NOTE,
|
|
|
|
};
|
|
|
|
|
2019-07-07 08:02:55 +02:00
|
|
|
void WINAPIV hlsl_message(const char *fmt, ...) PRINTF_ATTR(1,2) DECLSPEC_HIDDEN;
|
2020-03-04 03:29:47 +01:00
|
|
|
void WINAPIV hlsl_report_message(const struct source_location loc,
|
|
|
|
enum hlsl_error_level level, const char *fmt, ...) PRINTF_ATTR(3,4) DECLSPEC_HIDDEN;
|
2012-06-04 17:58:24 +02:00
|
|
|
|
2012-07-16 20:39:23 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-06-07 00:19:05 +02:00
|
|
|
static inline struct hlsl_ir_deref *deref_from_node(const struct hlsl_ir_node *node)
|
|
|
|
{
|
|
|
|
assert(node->type == HLSL_IR_DEREF);
|
|
|
|
return CONTAINING_RECORD(node, struct hlsl_ir_deref, node);
|
|
|
|
}
|
|
|
|
|
2012-06-07 00:19:04 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-09-18 18:18:08 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-07-20 16:37:41 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-09-17 15:32:04 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-06-11 19:18:35 +02:00
|
|
|
static inline struct hlsl_ir_constructor *constructor_from_node(const struct hlsl_ir_node *node)
|
|
|
|
{
|
|
|
|
assert(node->type == HLSL_IR_CONSTRUCTOR);
|
|
|
|
return CONTAINING_RECORD(node, struct hlsl_ir_constructor, node);
|
|
|
|
}
|
|
|
|
|
2012-09-19 19:46:11 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-09-21 16:25:56 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-02-13 04:57:18 +01:00
|
|
|
static inline struct hlsl_ir_node *node_from_list(struct list *list)
|
|
|
|
{
|
|
|
|
return LIST_ENTRY(list_tail(list), struct hlsl_ir_node, entry);
|
|
|
|
}
|
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN;
|
2012-06-04 17:58:23 +02:00
|
|
|
struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN;
|
2012-06-04 17:58:24 +02:00
|
|
|
void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN;
|
2012-06-07 00:19:02 +02:00
|
|
|
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;
|
2012-06-04 17:58:24 +02:00
|
|
|
struct hlsl_type *new_array_type(struct hlsl_type *basic_type, unsigned int array_size) DECLSPEC_HIDDEN;
|
2012-09-17 15:32:05 +02:00
|
|
|
struct hlsl_type *clone_hlsl_type(struct hlsl_type *old) DECLSPEC_HIDDEN;
|
2012-06-04 17:58:23 +02:00
|
|
|
struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN;
|
|
|
|
BOOL find_function(const char *name) DECLSPEC_HIDDEN;
|
2012-06-04 17:58:24 +02:00
|
|
|
unsigned int components_count_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
|
2012-10-11 19:48:49 +02:00
|
|
|
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2) DECLSPEC_HIDDEN;
|
2012-09-19 19:46:15 +02:00
|
|
|
BOOL compatible_data_types(struct hlsl_type *s1, struct hlsl_type *s2) DECLSPEC_HIDDEN;
|
2012-07-16 20:39:23 +02:00
|
|
|
struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **operands,
|
|
|
|
struct source_location *loc) DECLSPEC_HIDDEN;
|
2012-09-19 19:46:15 +02:00
|
|
|
struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
|
|
|
|
struct source_location *loc) DECLSPEC_HIDDEN;
|
2020-03-02 05:55:26 +01:00
|
|
|
struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *type,
|
|
|
|
struct source_location *loc) DECLSPEC_HIDDEN;
|
2012-06-04 17:58:24 +02:00
|
|
|
struct hlsl_ir_deref *new_var_deref(struct hlsl_ir_var *var) DECLSPEC_HIDDEN;
|
2012-09-26 19:22:35 +02:00
|
|
|
struct hlsl_ir_deref *new_record_deref(struct hlsl_ir_node *record, struct hlsl_struct_field *field) DECLSPEC_HIDDEN;
|
2012-07-20 16:37:41 +02:00
|
|
|
struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assign_op assign_op,
|
|
|
|
DWORD writemask, struct hlsl_ir_node *right) DECLSPEC_HIDDEN;
|
2012-06-04 17:58:24 +02:00
|
|
|
void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
|
|
|
|
BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
|
2012-10-11 19:48:48 +02:00
|
|
|
struct hlsl_ir_function_decl *new_func_decl(struct hlsl_type *return_type, struct list *parameters) 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;
|
2012-07-10 15:39:43 +02:00
|
|
|
struct bwriter_shader *parse_hlsl_shader(const char *text, enum shader_type type, DWORD major, DWORD minor,
|
2012-05-15 16:12:56 +02:00
|
|
|
const char *entrypoint, char **messages) DECLSPEC_HIDDEN;
|
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
const char *debug_hlsl_type(const struct hlsl_type *type) DECLSPEC_HIDDEN;
|
|
|
|
const char *debug_modifiers(DWORD modifiers) DECLSPEC_HIDDEN;
|
2012-10-11 19:48:48 +02:00
|
|
|
void debug_dump_ir_function_decl(const struct hlsl_ir_function_decl *func) DECLSPEC_HIDDEN;
|
2012-06-11 19:18:33 +02:00
|
|
|
|
2012-06-04 17:58:24 +02:00
|
|
|
void free_hlsl_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
|
2012-06-07 00:19:04 +02:00
|
|
|
void free_instr(struct hlsl_ir_node *node) DECLSPEC_HIDDEN;
|
|
|
|
void free_instr_list(struct list *list) DECLSPEC_HIDDEN;
|
2012-10-11 19:48:48 +02:00
|
|
|
void free_function_rb(struct wine_rb_entry *entry, void *context) DECLSPEC_HIDDEN;
|
2012-06-04 17:58:24 +02:00
|
|
|
|
2019-08-12 17:27:30 +02:00
|
|
|
static inline struct hlsl_ir_node *new_unary_expr(enum hlsl_ir_expr_op op,
|
|
|
|
struct hlsl_ir_node *op1, struct source_location loc)
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node *operands[3] = {op1};
|
|
|
|
return &new_expr(op, operands, &loc)->node;
|
|
|
|
}
|
2012-06-04 17:58:24 +02:00
|
|
|
|
2019-08-12 17:27:31 +02:00
|
|
|
static inline struct hlsl_ir_node *new_binary_expr(enum hlsl_ir_expr_op op,
|
|
|
|
struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location loc)
|
|
|
|
{
|
|
|
|
struct hlsl_ir_node *operands[3] = {op1, op2};
|
|
|
|
return &new_expr(op, operands, &loc)->node;
|
|
|
|
}
|
|
|
|
|
2010-10-03 15:11:54 +02:00
|
|
|
#define MAKE_TAG(ch0, ch1, ch2, ch3) \
|
|
|
|
((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
|
|
|
|
((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
|
2010-10-12 19:24:55 +02:00
|
|
|
#define TAG_Aon9 MAKE_TAG('A', 'o', 'n', '9')
|
2010-10-03 15:11:54 +02:00
|
|
|
#define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C')
|
2010-10-03 15:12:00 +02:00
|
|
|
#define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N')
|
2010-10-03 15:12:06 +02:00
|
|
|
#define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N')
|
2010-12-12 21:48:25 +01:00
|
|
|
#define TAG_OSG5 MAKE_TAG('O', 'S', 'G', '5')
|
2010-10-12 19:24:44 +02:00
|
|
|
#define TAG_PCSG MAKE_TAG('P', 'C', 'S', 'G')
|
2010-10-12 19:25:26 +02:00
|
|
|
#define TAG_RDEF MAKE_TAG('R', 'D', 'E', 'F')
|
2010-10-03 15:12:17 +02:00
|
|
|
#define TAG_SDBG MAKE_TAG('S', 'D', 'B', 'G')
|
2010-12-28 11:50:13 +01:00
|
|
|
#define TAG_SHDR MAKE_TAG('S', 'H', 'D', 'R')
|
|
|
|
#define TAG_SHEX MAKE_TAG('S', 'H', 'E', 'X')
|
2010-10-12 19:25:26 +02:00
|
|
|
#define TAG_STAT MAKE_TAG('S', 'T', 'A', 'T')
|
2010-10-12 19:24:59 +02:00
|
|
|
#define TAG_XNAP MAKE_TAG('X', 'N', 'A', 'P')
|
2010-10-12 19:25:02 +02:00
|
|
|
#define TAG_XNAS MAKE_TAG('X', 'N', 'A', 'S')
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
struct dxbc_section
|
|
|
|
{
|
|
|
|
DWORD tag;
|
|
|
|
const char *data;
|
|
|
|
DWORD data_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dxbc
|
|
|
|
{
|
|
|
|
UINT size;
|
|
|
|
UINT count;
|
|
|
|
struct dxbc_section *sections;
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT dxbc_write_blob(struct dxbc *dxbc, ID3DBlob **blob) DECLSPEC_HIDDEN;
|
|
|
|
void dxbc_destroy(struct dxbc *dxbc) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT dxbc_parse(const char *data, SIZE_T data_size, struct dxbc *dxbc) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT dxbc_add_section(struct dxbc *dxbc, DWORD tag, const char *data, DWORD data_size) DECLSPEC_HIDDEN;
|
2018-12-19 23:06:46 +01:00
|
|
|
HRESULT dxbc_init(struct dxbc *dxbc, unsigned int size) DECLSPEC_HIDDEN;
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
static inline void read_dword(const char **ptr, DWORD *d)
|
|
|
|
{
|
|
|
|
memcpy(d, *ptr, sizeof(*d));
|
|
|
|
*ptr += sizeof(*d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void write_dword(char **ptr, DWORD d)
|
|
|
|
{
|
|
|
|
memcpy(*ptr, &d, sizeof(d));
|
|
|
|
*ptr += sizeof(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN;
|
|
|
|
|
2010-08-15 17:05:31 +02:00
|
|
|
#endif /* __WINE_D3DCOMPILER_PRIVATE_H */
|