2008-03-14 14:12:30 +01:00
|
|
|
/*
|
2009-07-11 18:00:20 +02:00
|
|
|
* Copyright (C) 2002 Raphael Junqueira
|
2009-07-11 18:06:44 +02:00
|
|
|
* Copyright (C) 2008 David Adam
|
2008-03-14 14:12:30 +01:00
|
|
|
* Copyright (C) 2008 Tony Wasserka
|
2010-03-28 21:16:09 +02:00
|
|
|
* Copyright (C) 2008 Stefan Dösinger
|
|
|
|
* Copyright (C) 2009 Matteo Bruni
|
2008-03-14 14:12:30 +01: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_D3DX9_36_PRIVATE_H
|
|
|
|
#define __WINE_D3DX9_36_PRIVATE_H
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
2009-06-01 18:30:15 +02:00
|
|
|
#include "winbase.h"
|
2008-03-14 14:12:30 +01:00
|
|
|
#include "wingdi.h"
|
2009-06-01 18:30:15 +02:00
|
|
|
#include "winuser.h"
|
2008-03-14 14:12:30 +01:00
|
|
|
#include "d3dx9.h"
|
|
|
|
|
2009-06-01 18:25:32 +02:00
|
|
|
/* for internal use */
|
2009-10-13 13:58:29 +02:00
|
|
|
typedef enum _FormatType {
|
|
|
|
FORMAT_ARGB, /* unsigned */
|
|
|
|
FORMAT_UNKNOWN
|
|
|
|
} FormatType;
|
|
|
|
|
|
|
|
typedef struct _PixelFormatDesc {
|
|
|
|
D3DFORMAT format;
|
|
|
|
BYTE bits[4];
|
|
|
|
BYTE shift[4];
|
|
|
|
UINT bytes_per_pixel;
|
|
|
|
FormatType type;
|
|
|
|
} PixelFormatDesc;
|
|
|
|
|
2009-06-01 18:25:32 +02:00
|
|
|
HRESULT map_view_of_file(LPCWSTR filename, LPVOID *buffer, DWORD *length);
|
|
|
|
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, LPVOID *buffer, DWORD *length);
|
|
|
|
|
2009-10-13 13:58:29 +02:00
|
|
|
const PixelFormatDesc *get_format_info(D3DFORMAT format);
|
|
|
|
|
|
|
|
|
2009-07-11 18:00:20 +02:00
|
|
|
extern const ID3DXBufferVtbl D3DXBuffer_Vtbl;
|
|
|
|
|
|
|
|
/* ID3DXBUFFER */
|
|
|
|
typedef struct ID3DXBufferImpl
|
|
|
|
{
|
|
|
|
/* IUnknown fields */
|
|
|
|
const ID3DXBufferVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
/* ID3DXBuffer fields */
|
|
|
|
DWORD *buffer;
|
|
|
|
DWORD bufferSize;
|
|
|
|
} ID3DXBufferImpl;
|
|
|
|
|
2008-03-14 14:12:30 +01:00
|
|
|
|
2008-11-05 12:32:47 +01:00
|
|
|
/* ID3DXFont */
|
2008-03-14 14:12:30 +01:00
|
|
|
typedef struct ID3DXFontImpl
|
|
|
|
{
|
2008-07-23 16:50:01 +02:00
|
|
|
/* IUnknown fields */
|
|
|
|
const ID3DXFontVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
2008-03-14 14:12:30 +01:00
|
|
|
|
2008-07-23 16:50:01 +02:00
|
|
|
/* ID3DXFont fields */
|
2009-06-05 13:15:44 +02:00
|
|
|
IDirect3DDevice9 *device;
|
2009-06-05 13:26:11 +02:00
|
|
|
D3DXFONT_DESCW desc;
|
2009-06-05 13:45:12 +02:00
|
|
|
|
|
|
|
HDC hdc;
|
2009-06-05 13:57:23 +02:00
|
|
|
HFONT hfont;
|
2008-03-14 14:12:30 +01:00
|
|
|
} ID3DXFontImpl;
|
|
|
|
|
2009-07-11 18:06:44 +02:00
|
|
|
/* ID3DXMatrixStack */
|
|
|
|
typedef struct ID3DXMatrixStackImpl
|
|
|
|
{
|
|
|
|
/* IUnknown fields */
|
|
|
|
const ID3DXMatrixStackVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
/* ID3DXMatrixStack fields */
|
|
|
|
unsigned int current;
|
|
|
|
unsigned int stack_size;
|
|
|
|
D3DXMATRIX *stack;
|
|
|
|
} ID3DXMatrixStackImpl;
|
2008-11-05 12:32:47 +01:00
|
|
|
|
|
|
|
/*ID3DXSprite */
|
|
|
|
typedef struct _SPRITE {
|
|
|
|
LPDIRECT3DTEXTURE9 texture;
|
|
|
|
UINT texw, texh;
|
|
|
|
RECT rect;
|
|
|
|
D3DXVECTOR3 center;
|
|
|
|
D3DXVECTOR3 pos;
|
|
|
|
D3DCOLOR color;
|
|
|
|
} SPRITE;
|
|
|
|
|
2008-07-23 16:50:01 +02:00
|
|
|
typedef struct ID3DXSpriteImpl
|
|
|
|
{
|
|
|
|
/* IUnknown fields */
|
|
|
|
const ID3DXSpriteVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
/* ID3DXSprite fields */
|
2008-11-05 12:32:47 +01:00
|
|
|
IDirect3DDevice9 *device;
|
|
|
|
IDirect3DVertexDeclaration9 *vdecl;
|
|
|
|
IDirect3DStateBlock9 *stateblock;
|
|
|
|
D3DXMATRIX transform;
|
|
|
|
D3DXMATRIX view;
|
|
|
|
DWORD flags;
|
2008-11-07 16:50:22 +01:00
|
|
|
BOOL ready;
|
2008-11-05 12:32:47 +01:00
|
|
|
|
|
|
|
/* Store the relevant caps to prevent multiple GetDeviceCaps calls */
|
|
|
|
DWORD texfilter_caps;
|
|
|
|
DWORD maxanisotropy;
|
|
|
|
DWORD alphacmp_caps;
|
|
|
|
|
|
|
|
SPRITE *sprites;
|
2008-11-05 13:00:35 +01:00
|
|
|
int sprite_count; /* number of sprites to be drawn */
|
|
|
|
int allocated_sprites; /* number of (pre-)allocated sprites */
|
2008-07-23 16:50:01 +02:00
|
|
|
} ID3DXSpriteImpl;
|
|
|
|
|
2010-03-28 21:16:09 +02:00
|
|
|
/* Shader assembler definitions */
|
|
|
|
typedef enum _shader_type {
|
|
|
|
ST_VERTEX,
|
|
|
|
ST_PIXEL,
|
|
|
|
} shader_type;
|
|
|
|
|
|
|
|
typedef enum BWRITER_COMPARISON_TYPE {
|
2009-11-24 02:08:32 +01:00
|
|
|
BWRITER_COMPARISON_NONE,
|
|
|
|
BWRITER_COMPARISON_GT,
|
|
|
|
BWRITER_COMPARISON_EQ,
|
|
|
|
BWRITER_COMPARISON_GE,
|
|
|
|
BWRITER_COMPARISON_LT,
|
|
|
|
BWRITER_COMPARISON_NE,
|
|
|
|
BWRITER_COMPARISON_LE
|
2010-03-28 21:16:09 +02:00
|
|
|
} BWRITER_COMPARISON_TYPE;
|
|
|
|
|
2010-05-14 17:21:42 +02:00
|
|
|
struct constant {
|
|
|
|
DWORD regnum;
|
|
|
|
union {
|
|
|
|
float f;
|
|
|
|
INT i;
|
|
|
|
BOOL b;
|
|
|
|
DWORD d;
|
|
|
|
} value[4];
|
|
|
|
};
|
|
|
|
|
2010-03-28 21:16:09 +02:00
|
|
|
struct shader_reg {
|
|
|
|
DWORD type;
|
|
|
|
DWORD regnum;
|
|
|
|
struct shader_reg *rel_reg;
|
|
|
|
DWORD srcmod;
|
|
|
|
union {
|
|
|
|
DWORD swizzle;
|
|
|
|
DWORD writemask;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct instruction {
|
|
|
|
DWORD opcode;
|
|
|
|
DWORD dstmod;
|
|
|
|
DWORD shift;
|
|
|
|
BWRITER_COMPARISON_TYPE comptype;
|
|
|
|
BOOL has_dst;
|
|
|
|
struct shader_reg dst;
|
|
|
|
struct shader_reg *src;
|
|
|
|
unsigned int num_srcs; /* For freeing the rel_regs */
|
2010-03-29 17:57:30 +02:00
|
|
|
BOOL has_predicate;
|
|
|
|
struct shader_reg predicate;
|
2009-08-16 01:02:16 +02:00
|
|
|
BOOL coissue;
|
2010-03-28 21:16:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct declaration {
|
|
|
|
DWORD usage, usage_idx;
|
|
|
|
DWORD regnum;
|
2010-05-30 22:24:54 +02:00
|
|
|
DWORD mod;
|
2010-03-28 21:16:09 +02:00
|
|
|
DWORD writemask;
|
2010-06-08 00:35:10 +02:00
|
|
|
BOOL builtin;
|
2010-03-28 21:16:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct samplerdecl {
|
|
|
|
DWORD type;
|
|
|
|
DWORD regnum;
|
2010-05-30 22:57:13 +02:00
|
|
|
DWORD mod;
|
2010-03-28 21:16:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#define INSTRARRAY_INITIAL_SIZE 8
|
|
|
|
struct bwriter_shader {
|
|
|
|
shader_type type;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline LPVOID asm_alloc(SIZE_T size) {
|
|
|
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline LPVOID asm_realloc(LPVOID ptr, SIZE_T size) {
|
|
|
|
return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL asm_free(LPVOID ptr) {
|
|
|
|
return HeapFree(GetProcessHeap(), 0, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2010-05-14 17:21:42 +02:00
|
|
|
void (*constF)(struct asm_parser *This, DWORD reg, float x, float y, float z, float w);
|
2010-05-14 17:21:42 +02:00
|
|
|
void (*constI)(struct asm_parser *This, DWORD reg, INT x, INT y, INT z, INT w);
|
2010-05-14 17:21:42 +02:00
|
|
|
void (*constB)(struct asm_parser *This, DWORD reg, BOOL x);
|
2010-05-14 17:21:42 +02:00
|
|
|
|
2010-03-28 21:16:09 +02:00
|
|
|
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);
|
|
|
|
|
2010-05-13 17:21:58 +02:00
|
|
|
void (*dcl_output)(struct asm_parser *This, DWORD usage, DWORD num,
|
|
|
|
const struct shader_reg *reg);
|
2010-05-13 17:21:58 +02:00
|
|
|
void (*dcl_input)(struct asm_parser *This, DWORD usage, DWORD num,
|
2010-05-30 22:24:54 +02:00
|
|
|
DWORD mod, const struct shader_reg *reg);
|
2010-05-30 22:57:13 +02:00
|
|
|
void (*dcl_sampler)(struct asm_parser *This, DWORD samptype, DWORD mod,
|
|
|
|
DWORD regnum, unsigned int line_no);
|
2010-05-13 17:21:58 +02:00
|
|
|
|
2010-03-28 21:16:09 +02:00
|
|
|
void (*end)(struct asm_parser *This);
|
|
|
|
|
|
|
|
void (*instr)(struct asm_parser *This, DWORD opcode, DWORD mod, DWORD shift,
|
|
|
|
BWRITER_COMPARISON_TYPE comp, const struct shader_reg *dst,
|
|
|
|
const struct src_regs *srcs, int expectednsrcs);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct instruction *alloc_instr(unsigned int srcs);
|
|
|
|
BOOL add_instruction(struct bwriter_shader *shader, struct instruction *instr);
|
2010-05-14 17:21:42 +02:00
|
|
|
BOOL add_constF(struct bwriter_shader *shader, DWORD reg, float x, float y, float z, float w);
|
2010-05-14 17:21:42 +02:00
|
|
|
BOOL add_constI(struct bwriter_shader *shader, DWORD reg, INT x, INT y, INT z, INT w);
|
2010-05-14 17:21:42 +02:00
|
|
|
BOOL add_constB(struct bwriter_shader *shader, DWORD reg, BOOL x);
|
2010-06-08 00:35:10 +02:00
|
|
|
BOOL record_declaration(struct bwriter_shader *shader, DWORD usage,
|
|
|
|
DWORD usage_idx, DWORD mod, BOOL output,
|
|
|
|
DWORD regnum, DWORD writemask, BOOL builtin);
|
2010-05-30 22:57:13 +02:00
|
|
|
BOOL record_sampler(struct bwriter_shader *shader, DWORD samptype,
|
|
|
|
DWORD mod, DWORD regnum);
|
2010-03-28 21:16:09 +02:00
|
|
|
|
2010-03-28 16:00:36 +02:00
|
|
|
#define MESSAGEBUFFER_INITIAL_SIZE 256
|
|
|
|
|
2010-03-28 21:16:09 +02:00
|
|
|
struct asm_parser {
|
|
|
|
/* The function table of the parser implementation */
|
|
|
|
const struct asmparser_backend *funcs;
|
|
|
|
|
|
|
|
/* Private data follows */
|
|
|
|
struct bwriter_shader *shader;
|
|
|
|
unsigned int m3x3pad_count;
|
|
|
|
|
|
|
|
enum parse_status {
|
|
|
|
PARSE_SUCCESS = 0,
|
|
|
|
PARSE_WARN = 1,
|
|
|
|
PARSE_ERR = 2
|
|
|
|
} status;
|
|
|
|
char *messages;
|
|
|
|
unsigned int messagesize;
|
|
|
|
unsigned int messagecapacity;
|
|
|
|
unsigned int line_no;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct asm_parser asm_ctx;
|
|
|
|
|
2009-08-16 01:02:16 +02:00
|
|
|
void create_vs10_parser(struct asm_parser *ret);
|
|
|
|
void create_vs11_parser(struct asm_parser *ret);
|
2010-05-16 20:57:52 +02:00
|
|
|
void create_vs20_parser(struct asm_parser *ret);
|
|
|
|
void create_vs2x_parser(struct asm_parser *ret);
|
2010-03-28 21:16:09 +02:00
|
|
|
void create_vs30_parser(struct asm_parser *ret);
|
2010-05-20 01:14:25 +02:00
|
|
|
void create_ps20_parser(struct asm_parser *ret);
|
|
|
|
void create_ps2x_parser(struct asm_parser *ret);
|
2010-05-19 14:57:38 +02:00
|
|
|
void create_ps30_parser(struct asm_parser *ret);
|
2010-03-28 21:16:09 +02:00
|
|
|
|
|
|
|
struct bwriter_shader *parse_asm_shader(char **messages);
|
|
|
|
|
2010-03-28 16:00:36 +02:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
|
|
|
|
#else
|
|
|
|
#define PRINTF_ATTR(fmt,args)
|
|
|
|
#endif
|
2008-03-14 14:12:30 +01:00
|
|
|
|
2010-03-28 21:16:09 +02:00
|
|
|
void asmparser_message(struct asm_parser *ctx, const char *fmt, ...) PRINTF_ATTR(2,3);
|
|
|
|
void set_parse_status(struct asm_parser *ctx, enum parse_status status);
|
|
|
|
|
|
|
|
/* 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,
|
|
|
|
struct bytecode_buffer *buffer);
|
|
|
|
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;
|
2010-05-16 20:57:52 +02:00
|
|
|
|
|
|
|
/* 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;
|
2010-05-20 01:14:25 +02:00
|
|
|
|
|
|
|
/* Pixel shader specific members */
|
|
|
|
DWORD t_regnum[8];
|
|
|
|
DWORD v_regnum[2];
|
2010-03-28 21:16:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Debug utility routines */
|
2010-05-18 14:11:42 +02:00
|
|
|
const char *debug_print_srcmod(DWORD mod);
|
2010-04-21 16:15:46 +02:00
|
|
|
const char *debug_print_dstmod(DWORD mod);
|
2010-03-28 21:16:09 +02:00
|
|
|
const char *debug_print_dstreg(const struct shader_reg *reg, shader_type st);
|
|
|
|
const char *debug_print_srcreg(const struct shader_reg *reg, shader_type st);
|
2010-04-21 16:15:46 +02:00
|
|
|
const char *debug_print_swizzle(DWORD swizzle);
|
|
|
|
const char *debug_print_writemask(DWORD mask);
|
2009-11-24 02:08:32 +01:00
|
|
|
const char *debug_print_comp(DWORD comp);
|
2010-03-28 21:16:09 +02:00
|
|
|
const char *debug_print_opcode(DWORD opcode);
|
|
|
|
|
2010-03-29 17:57:30 +02:00
|
|
|
/* Utilities for internal->d3d constant mapping */
|
|
|
|
DWORD d3d9_swizzle(DWORD bwriter_swizzle);
|
|
|
|
DWORD d3d9_writemask(DWORD bwriter_writemask);
|
2010-04-21 16:15:46 +02:00
|
|
|
DWORD d3d9_srcmod(DWORD bwriter_srcmod);
|
2010-04-21 16:15:46 +02:00
|
|
|
DWORD d3d9_dstmod(DWORD bwriter_mod);
|
2009-11-24 02:08:32 +01:00
|
|
|
DWORD d3d9_comparetype(DWORD bwriter_comparetype);
|
2010-05-13 17:21:59 +02:00
|
|
|
DWORD d3d9_sampler(DWORD bwriter_sampler);
|
2010-03-29 17:57:30 +02:00
|
|
|
DWORD d3d9_register(DWORD bwriter_register);
|
|
|
|
DWORD d3d9_opcode(DWORD bwriter_opcode);
|
|
|
|
|
2010-04-21 16:15:46 +02:00
|
|
|
/* Used to signal an incorrect swizzle/writemask */
|
|
|
|
#define SWIZZLE_ERR ~0U
|
|
|
|
|
2010-03-28 21:16:09 +02:00
|
|
|
/*
|
|
|
|
Enumerations and defines used in the bytecode writer
|
|
|
|
intermediate representation
|
|
|
|
*/
|
|
|
|
typedef enum _BWRITERSHADER_INSTRUCTION_OPCODE_TYPE {
|
2010-05-05 20:21:10 +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,
|
2010-05-11 20:29:07 +02:00
|
|
|
BWRITERSIO_CALL,
|
|
|
|
BWRITERSIO_CALLNZ,
|
|
|
|
BWRITERSIO_LOOP,
|
|
|
|
BWRITERSIO_RET,
|
|
|
|
BWRITERSIO_ENDLOOP,
|
|
|
|
BWRITERSIO_LABEL,
|
2010-05-13 17:21:58 +02:00
|
|
|
BWRITERSIO_DCL,
|
2010-05-05 20:21:10 +02:00
|
|
|
BWRITERSIO_POW,
|
|
|
|
BWRITERSIO_CRS,
|
|
|
|
BWRITERSIO_SGN,
|
|
|
|
BWRITERSIO_ABS,
|
|
|
|
BWRITERSIO_NRM,
|
|
|
|
BWRITERSIO_SINCOS,
|
2010-05-11 20:29:07 +02:00
|
|
|
BWRITERSIO_REP,
|
|
|
|
BWRITERSIO_ENDREP,
|
|
|
|
BWRITERSIO_IF,
|
2009-11-24 02:08:32 +01:00
|
|
|
BWRITERSIO_IFC,
|
2010-05-11 20:29:07 +02:00
|
|
|
BWRITERSIO_ELSE,
|
|
|
|
BWRITERSIO_ENDIF,
|
|
|
|
BWRITERSIO_BREAK,
|
2009-11-24 02:08:32 +01:00
|
|
|
BWRITERSIO_BREAKC,
|
2010-05-05 20:21:10 +02:00
|
|
|
BWRITERSIO_MOVA,
|
2010-05-14 17:21:42 +02:00
|
|
|
BWRITERSIO_DEFB,
|
2010-05-14 17:21:42 +02:00
|
|
|
BWRITERSIO_DEFI,
|
2010-05-05 20:21:10 +02:00
|
|
|
|
2010-05-19 14:57:38 +02:00
|
|
|
BWRITERSIO_TEXKILL,
|
|
|
|
BWRITERSIO_TEX,
|
2010-05-05 20:21:10 +02:00
|
|
|
BWRITERSIO_EXPP,
|
|
|
|
BWRITERSIO_LOGP,
|
2010-05-14 17:21:42 +02:00
|
|
|
BWRITERSIO_DEF,
|
2010-05-19 14:57:38 +02:00
|
|
|
BWRITERSIO_CMP,
|
|
|
|
BWRITERSIO_DP2ADD,
|
|
|
|
BWRITERSIO_DSX,
|
|
|
|
BWRITERSIO_DSY,
|
|
|
|
BWRITERSIO_TEXLDD,
|
2010-05-11 20:29:07 +02:00
|
|
|
BWRITERSIO_SETP,
|
2010-05-05 20:21:10 +02:00
|
|
|
BWRITERSIO_TEXLDL,
|
2010-05-11 20:29:07 +02:00
|
|
|
BWRITERSIO_BREAKP,
|
2010-05-21 14:56:43 +02:00
|
|
|
BWRITERSIO_TEXLDP,
|
|
|
|
BWRITERSIO_TEXLDB,
|
2010-05-05 20:21:10 +02:00
|
|
|
|
|
|
|
BWRITERSIO_COMMENT,
|
|
|
|
BWRITERSIO_END,
|
2010-03-28 21:16:09 +02:00
|
|
|
} BWRITERSHADER_INSTRUCTION_OPCODE_TYPE;
|
|
|
|
|
|
|
|
typedef enum _BWRITERSHADER_PARAM_REGISTER_TYPE {
|
2010-05-05 16:56:09 +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
|
2010-03-28 21:16:09 +02:00
|
|
|
} BWRITERSHADER_PARAM_REGISTER_TYPE;
|
|
|
|
|
2010-05-05 16:56:09 +02:00
|
|
|
typedef enum _BWRITERVS_RASTOUT_OFFSETS
|
|
|
|
{
|
|
|
|
BWRITERSRO_POSITION,
|
|
|
|
BWRITERSRO_FOG,
|
|
|
|
BWRITERSRO_POINT_SIZE
|
|
|
|
} BWRITERVS_RASTOUT_OFFSETS;
|
|
|
|
|
2010-03-28 21:16:09 +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 */
|
|
|
|
|
2010-04-21 16:15:46 +02:00
|
|
|
typedef enum _BWRITERSHADER_PARAM_DSTMOD_TYPE {
|
|
|
|
BWRITERSPDM_NONE = 0,
|
|
|
|
BWRITERSPDM_SATURATE = 1,
|
|
|
|
BWRITERSPDM_PARTIALPRECISION = 2,
|
|
|
|
BWRITERSPDM_MSAMPCENTROID = 4,
|
|
|
|
} BWRITERSHADER_PARAM_DSTMOD_TYPE;
|
|
|
|
|
2010-05-13 17:21:59 +02:00
|
|
|
typedef enum _BWRITERSAMPLER_TEXTURE_TYPE {
|
|
|
|
BWRITERSTT_UNKNOWN = 0,
|
|
|
|
BWRITERSTT_1D = 1,
|
|
|
|
BWRITERSTT_2D = 2,
|
|
|
|
BWRITERSTT_CUBE = 3,
|
|
|
|
BWRITERSTT_VOLUME = 4,
|
|
|
|
} BWRITERSAMPLER_TEXTURE_TYPE;
|
|
|
|
|
2010-05-19 14:57:38 +02:00
|
|
|
#define BWRITERSI_TEXLD_PROJECT 1
|
|
|
|
#define BWRITERSI_TEXLD_BIAS 2
|
|
|
|
|
2010-03-28 21:16:09 +02:00
|
|
|
typedef enum _BWRITERSHADER_PARAM_SRCMOD_TYPE {
|
|
|
|
BWRITERSPSM_NONE = 0,
|
2010-04-21 16:15:46 +02:00
|
|
|
BWRITERSPSM_NEG,
|
2010-05-18 14:11:42 +02:00
|
|
|
BWRITERSPSM_BIAS,
|
|
|
|
BWRITERSPSM_BIASNEG,
|
|
|
|
BWRITERSPSM_SIGN,
|
|
|
|
BWRITERSPSM_SIGNNEG,
|
|
|
|
BWRITERSPSM_COMP,
|
|
|
|
BWRITERSPSM_X2,
|
|
|
|
BWRITERSPSM_X2NEG,
|
|
|
|
BWRITERSPSM_DZ,
|
|
|
|
BWRITERSPSM_DW,
|
2010-04-21 16:15:46 +02:00
|
|
|
BWRITERSPSM_ABS,
|
|
|
|
BWRITERSPSM_ABSNEG,
|
2010-05-11 20:29:07 +02:00
|
|
|
BWRITERSPSM_NOT,
|
2010-03-28 21:16:09 +02:00
|
|
|
} BWRITERSHADER_PARAM_SRCMOD_TYPE;
|
|
|
|
|
|
|
|
#define BWRITER_SM1_VS 0xfffe
|
|
|
|
#define BWRITER_SM1_PS 0xffff
|
|
|
|
|
|
|
|
#define BWRITERPS_VERSION(major, minor) ((BWRITER_SM1_PS << 16) | ((major) << 8) | (minor))
|
|
|
|
#define BWRITERVS_VERSION(major, minor) ((BWRITER_SM1_VS << 16) | ((major) << 8) | (minor))
|
|
|
|
|
|
|
|
#define BWRITERVS_SWIZZLE_SHIFT 16
|
|
|
|
#define BWRITERVS_SWIZZLE_MASK (0xFF << BWRITERVS_SWIZZLE_SHIFT)
|
|
|
|
|
|
|
|
#define BWRITERVS_X_X (0 << BWRITERVS_SWIZZLE_SHIFT)
|
|
|
|
#define BWRITERVS_X_Y (1 << BWRITERVS_SWIZZLE_SHIFT)
|
|
|
|
#define BWRITERVS_X_Z (2 << BWRITERVS_SWIZZLE_SHIFT)
|
|
|
|
#define BWRITERVS_X_W (3 << BWRITERVS_SWIZZLE_SHIFT)
|
|
|
|
|
|
|
|
#define BWRITERVS_Y_X (0 << (BWRITERVS_SWIZZLE_SHIFT + 2))
|
|
|
|
#define BWRITERVS_Y_Y (1 << (BWRITERVS_SWIZZLE_SHIFT + 2))
|
|
|
|
#define BWRITERVS_Y_Z (2 << (BWRITERVS_SWIZZLE_SHIFT + 2))
|
|
|
|
#define BWRITERVS_Y_W (3 << (BWRITERVS_SWIZZLE_SHIFT + 2))
|
|
|
|
|
|
|
|
#define BWRITERVS_Z_X (0 << (BWRITERVS_SWIZZLE_SHIFT + 4))
|
|
|
|
#define BWRITERVS_Z_Y (1 << (BWRITERVS_SWIZZLE_SHIFT + 4))
|
|
|
|
#define BWRITERVS_Z_Z (2 << (BWRITERVS_SWIZZLE_SHIFT + 4))
|
|
|
|
#define BWRITERVS_Z_W (3 << (BWRITERVS_SWIZZLE_SHIFT + 4))
|
|
|
|
|
|
|
|
#define BWRITERVS_W_X (0 << (BWRITERVS_SWIZZLE_SHIFT + 6))
|
|
|
|
#define BWRITERVS_W_Y (1 << (BWRITERVS_SWIZZLE_SHIFT + 6))
|
|
|
|
#define BWRITERVS_W_Z (2 << (BWRITERVS_SWIZZLE_SHIFT + 6))
|
|
|
|
#define BWRITERVS_W_W (3 << (BWRITERVS_SWIZZLE_SHIFT + 6))
|
|
|
|
|
|
|
|
#define BWRITERVS_NOSWIZZLE (BWRITERVS_X_X | BWRITERVS_Y_Y | BWRITERVS_Z_Z | BWRITERVS_W_W)
|
|
|
|
|
2010-04-21 16:15:46 +02:00
|
|
|
#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)
|
|
|
|
|
2010-05-13 17:21:58 +02:00
|
|
|
typedef enum _BWRITERDECLUSAGE {
|
|
|
|
BWRITERDECLUSAGE_POSITION,
|
2010-05-13 17:21:58 +02:00
|
|
|
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
|
2010-05-13 17:21:58 +02:00
|
|
|
} BWRITERDECLUSAGE;
|
|
|
|
|
2010-03-28 21:16:09 +02:00
|
|
|
struct bwriter_shader *SlAssembleShader(const char *text, char **messages);
|
2010-03-29 17:57:30 +02:00
|
|
|
DWORD SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result);
|
2010-03-28 21:16:09 +02:00
|
|
|
void SlDeleteShader(struct bwriter_shader *shader);
|
|
|
|
|
2008-03-14 14:12:30 +01:00
|
|
|
#endif /* __WINE_D3DX9_36_PRIVATE_H */
|