Commit 2e769540 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Move part of the shader instruction table to the backend.

parent 87e2c255
......@@ -2215,7 +2215,95 @@ static BOOL shader_arb_conv_supported(WINED3DFORMAT fmt) {
}
}
static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABLE_SIZE] =
{
/* WINED3DSIH_ABS */ shader_hw_map2gl,
/* WINED3DSIH_ADD */ shader_hw_map2gl,
/* WINED3DSIH_BEM */ pshader_hw_bem,
/* WINED3DSIH_BREAK */ NULL,
/* WINED3DSIH_BREAKC */ NULL,
/* WINED3DSIH_BREAKP */ NULL,
/* WINED3DSIH_CALL */ NULL,
/* WINED3DSIH_CALLNZ */ NULL,
/* WINED3DSIH_CMP */ pshader_hw_cmp,
/* WINED3DSIH_CND */ pshader_hw_cnd,
/* WINED3DSIH_CRS */ shader_hw_map2gl,
/* WINED3DSIH_DCL */ NULL,
/* WINED3DSIH_DEF */ NULL,
/* WINED3DSIH_DEFB */ NULL,
/* WINED3DSIH_DEFI */ NULL,
/* WINED3DSIH_DP2ADD */ pshader_hw_dp2add,
/* WINED3DSIH_DP3 */ shader_hw_map2gl,
/* WINED3DSIH_DP4 */ shader_hw_map2gl,
/* WINED3DSIH_DST */ shader_hw_map2gl,
/* WINED3DSIH_DSX */ NULL,
/* WINED3DSIH_DSY */ NULL,
/* WINED3DSIH_ELSE */ NULL,
/* WINED3DSIH_ENDIF */ NULL,
/* WINED3DSIH_ENDLOOP */ NULL,
/* WINED3DSIH_ENDREP */ NULL,
/* WINED3DSIH_EXP */ shader_hw_map2gl,
/* WINED3DSIH_EXPP */ shader_hw_map2gl,
/* WINED3DSIH_FRC */ shader_hw_map2gl,
/* WINED3DSIH_IF */ NULL,
/* WINED3DSIH_IFC */ NULL,
/* WINED3DSIH_LABEL */ NULL,
/* WINED3DSIH_LIT */ shader_hw_map2gl,
/* WINED3DSIH_LOG */ shader_hw_map2gl,
/* WINED3DSIH_LOGP */ shader_hw_map2gl,
/* WINED3DSIH_LOOP */ NULL,
/* WINED3DSIH_LRP */ shader_hw_map2gl,
/* WINED3DSIH_M3x2 */ shader_hw_mnxn,
/* WINED3DSIH_M3x3 */ shader_hw_mnxn,
/* WINED3DSIH_M3x4 */ shader_hw_mnxn,
/* WINED3DSIH_M4x3 */ shader_hw_mnxn,
/* WINED3DSIH_M4x4 */ shader_hw_mnxn,
/* WINED3DSIH_MAD */ shader_hw_map2gl,
/* WINED3DSIH_MAX */ shader_hw_map2gl,
/* WINED3DSIH_MIN */ shader_hw_map2gl,
/* WINED3DSIH_MOV */ shader_hw_map2gl,
/* WINED3DSIH_MOVA */ shader_hw_map2gl,
/* WINED3DSIH_MUL */ shader_hw_map2gl,
/* WINED3DSIH_NOP */ shader_hw_map2gl,
/* WINED3DSIH_NRM */ shader_hw_nrm,
/* WINED3DSIH_PHASE */ NULL,
/* WINED3DSIH_POW */ shader_hw_map2gl,
/* WINED3DSIH_RCP */ vshader_hw_rsq_rcp,
/* WINED3DSIH_REP */ NULL,
/* WINED3DSIH_RET */ NULL,
/* WINED3DSIH_RSQ */ vshader_hw_rsq_rcp,
/* WINED3DSIH_SETP */ NULL,
/* WINED3DSIH_SGE */ shader_hw_map2gl,
/* WINED3DSIH_SGN */ NULL,
/* WINED3DSIH_SINCOS */ shader_hw_sincos,
/* WINED3DSIH_SLT */ shader_hw_map2gl,
/* WINED3DSIH_SUB */ shader_hw_map2gl,
/* WINED3DSIH_TEX */ pshader_hw_tex,
/* WINED3DSIH_TEXBEM */ pshader_hw_texbem,
/* WINED3DSIH_TEXBEML */ pshader_hw_texbem,
/* WINED3DSIH_TEXCOORD */ pshader_hw_texcoord,
/* WINED3DSIH_TEXDEPTH */ pshader_hw_texdepth,
/* WINED3DSIH_TEXDP3 */ pshader_hw_texdp3,
/* WINED3DSIH_TEXDP3TEX */ pshader_hw_texdp3tex,
/* WINED3DSIH_TEXKILL */ pshader_hw_texkill,
/* WINED3DSIH_TEXLDD */ NULL,
/* WINED3DSIH_TEXLDL */ NULL,
/* WINED3DSIH_TEXM3x2DEPTH */ pshader_hw_texm3x2depth,
/* WINED3DSIH_TEXM3x2PAD */ pshader_hw_texm3x2pad,
/* WINED3DSIH_TEXM3x2TEX */ pshader_hw_texm3x2tex,
/* WINED3DSIH_TEXM3x3 */ pshader_hw_texm3x3,
/* WINED3DSIH_TEXM3x3DIFF */ NULL,
/* WINED3DSIH_TEXM3x3PAD */ pshader_hw_texm3x3pad,
/* WINED3DSIH_TEXM3x3SPEC */ pshader_hw_texm3x3spec,
/* WINED3DSIH_TEXM3x3TEX */ pshader_hw_texm3x3tex,
/* WINED3DSIH_TEXM3x3VSPEC */ pshader_hw_texm3x3vspec,
/* WINED3DSIH_TEXREG2AR */ pshader_hw_texreg2ar,
/* WINED3DSIH_TEXREG2GB */ pshader_hw_texreg2gb,
/* WINED3DSIH_TEXREG2RGB */ pshader_hw_texreg2rgb,
};
const shader_backend_t arb_program_shader_backend = {
shader_arb_instruction_handler_table,
shader_arb_select,
shader_arb_select_depth_blt,
shader_arb_deselect_depth_blt,
......
......@@ -790,6 +790,7 @@ void shader_generate_main(
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */
const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table;
const DWORD *pToken = pFunction;
const SHADER_OPCODE *curOpcode = NULL;
SHADER_HANDLER hw_fct = NULL;
......@@ -828,10 +829,8 @@ void shader_generate_main(
/* Select handler */
if (curOpcode == NULL)
hw_fct = NULL;
else if (This->baseShader.shader_mode == SHADER_GLSL)
hw_fct = curOpcode->hw_glsl_fct;
else if (This->baseShader.shader_mode == SHADER_ARB)
hw_fct = curOpcode->hw_fct;
else
hw_fct = handler_table[curOpcode->handler_idx];
/* Unknown opcode and its parameters */
if (NULL == curOpcode) {
......@@ -1089,6 +1088,7 @@ void shader_trace_init(
}
}
static const SHADER_HANDLER shader_none_instruction_handler_table[WINED3DSIH_TABLE_SIZE] = {0};
static void shader_none_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {}
static void shader_none_select_depth_blt(IWineD3DDevice *iface) {}
static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
......@@ -1132,6 +1132,7 @@ static BOOL shader_none_conv_supported(WINED3DFORMAT fmt) {
}
const shader_backend_t none_shader_backend = {
shader_none_instruction_handler_table,
shader_none_select,
shader_none_select_depth_blt,
shader_none_deselect_depth_blt,
......
......@@ -3783,7 +3783,95 @@ static BOOL shader_glsl_conv_supported(WINED3DFORMAT fmt) {
}
}
static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TABLE_SIZE] =
{
/* WINED3DSIH_ABS */ shader_glsl_map2gl,
/* WINED3DSIH_ADD */ shader_glsl_arith,
/* WINED3DSIH_BEM */ pshader_glsl_bem,
/* WINED3DSIH_BREAK */ shader_glsl_break,
/* WINED3DSIH_BREAKC */ shader_glsl_breakc,
/* WINED3DSIH_BREAKP */ NULL,
/* WINED3DSIH_CALL */ shader_glsl_call,
/* WINED3DSIH_CALLNZ */ shader_glsl_callnz,
/* WINED3DSIH_CMP */ shader_glsl_cmp,
/* WINED3DSIH_CND */ shader_glsl_cnd,
/* WINED3DSIH_CRS */ shader_glsl_cross,
/* WINED3DSIH_DCL */ NULL,
/* WINED3DSIH_DEF */ NULL,
/* WINED3DSIH_DEFB */ NULL,
/* WINED3DSIH_DEFI */ NULL,
/* WINED3DSIH_DP2ADD */ pshader_glsl_dp2add,
/* WINED3DSIH_DP3 */ shader_glsl_dot,
/* WINED3DSIH_DP4 */ shader_glsl_dot,
/* WINED3DSIH_DST */ shader_glsl_dst,
/* WINED3DSIH_DSX */ shader_glsl_map2gl,
/* WINED3DSIH_DSY */ shader_glsl_map2gl,
/* WINED3DSIH_ELSE */ shader_glsl_else,
/* WINED3DSIH_ENDIF */ shader_glsl_end,
/* WINED3DSIH_ENDLOOP */ shader_glsl_end,
/* WINED3DSIH_ENDREP */ shader_glsl_end,
/* WINED3DSIH_EXP */ shader_glsl_map2gl,
/* WINED3DSIH_EXPP */ shader_glsl_expp,
/* WINED3DSIH_FRC */ shader_glsl_map2gl,
/* WINED3DSIH_IF */ shader_glsl_if,
/* WINED3DSIH_IFC */ shader_glsl_ifc,
/* WINED3DSIH_LABEL */ shader_glsl_label,
/* WINED3DSIH_LIT */ shader_glsl_lit,
/* WINED3DSIH_LOG */ shader_glsl_log,
/* WINED3DSIH_LOGP */ shader_glsl_log,
/* WINED3DSIH_LOOP */ shader_glsl_loop,
/* WINED3DSIH_LRP */ shader_glsl_lrp,
/* WINED3DSIH_M3x2 */ shader_glsl_mnxn,
/* WINED3DSIH_M3x3 */ shader_glsl_mnxn,
/* WINED3DSIH_M3x4 */ shader_glsl_mnxn,
/* WINED3DSIH_M4x3 */ shader_glsl_mnxn,
/* WINED3DSIH_M4x4 */ shader_glsl_mnxn,
/* WINED3DSIH_MAD */ shader_glsl_mad,
/* WINED3DSIH_MAX */ shader_glsl_map2gl,
/* WINED3DSIH_MIN */ shader_glsl_map2gl,
/* WINED3DSIH_MOV */ shader_glsl_mov,
/* WINED3DSIH_MOVA */ shader_glsl_mov,
/* WINED3DSIH_MUL */ shader_glsl_arith,
/* WINED3DSIH_NOP */ NULL,
/* WINED3DSIH_NRM */ shader_glsl_map2gl,
/* WINED3DSIH_PHASE */ NULL,
/* WINED3DSIH_POW */ shader_glsl_pow,
/* WINED3DSIH_RCP */ shader_glsl_rcp,
/* WINED3DSIH_REP */ shader_glsl_rep,
/* WINED3DSIH_RET */ NULL,
/* WINED3DSIH_RSQ */ shader_glsl_rsq,
/* WINED3DSIH_SETP */ NULL,
/* WINED3DSIH_SGE */ shader_glsl_compare,
/* WINED3DSIH_SGN */ shader_glsl_map2gl,
/* WINED3DSIH_SINCOS */ shader_glsl_sincos,
/* WINED3DSIH_SLT */ shader_glsl_compare,
/* WINED3DSIH_SUB */ shader_glsl_arith,
/* WINED3DSIH_TEX */ pshader_glsl_tex,
/* WINED3DSIH_TEXBEM */ pshader_glsl_texbem,
/* WINED3DSIH_TEXBEML */ pshader_glsl_texbem,
/* WINED3DSIH_TEXCOORD */ pshader_glsl_texcoord,
/* WINED3DSIH_TEXDEPTH */ pshader_glsl_texdepth,
/* WINED3DSIH_TEXDP3 */ pshader_glsl_texdp3,
/* WINED3DSIH_TEXDP3TEX */ pshader_glsl_texdp3tex,
/* WINED3DSIH_TEXKILL */ pshader_glsl_texkill,
/* WINED3DSIH_TEXLDD */ NULL,
/* WINED3DSIH_TEXLDL */ shader_glsl_texldl,
/* WINED3DSIH_TEXM3x2DEPTH */ pshader_glsl_texm3x2depth,
/* WINED3DSIH_TEXM3x2PAD */ pshader_glsl_texm3x2pad,
/* WINED3DSIH_TEXM3x2TEX */ pshader_glsl_texm3x2tex,
/* WINED3DSIH_TEXM3x3 */ pshader_glsl_texm3x3,
/* WINED3DSIH_TEXM3x3DIFF */ NULL,
/* WINED3DSIH_TEXM3x3PAD */ pshader_glsl_texm3x3pad,
/* WINED3DSIH_TEXM3x3SPEC */ pshader_glsl_texm3x3spec,
/* WINED3DSIH_TEXM3x3TEX */ pshader_glsl_texm3x3tex,
/* WINED3DSIH_TEXM3x3VSPEC */ pshader_glsl_texm3x3vspec,
/* WINED3DSIH_TEXREG2AR */ pshader_glsl_texreg2ar,
/* WINED3DSIH_TEXREG2GB */ pshader_glsl_texreg2gb,
/* WINED3DSIH_TEXREG2RGB */ pshader_glsl_texreg2rgb,
};
const shader_backend_t glsl_shader_backend = {
shader_glsl_instruction_handler_table,
shader_glsl_select,
shader_glsl_select_depth_blt,
shader_glsl_deselect_depth_blt,
......
......@@ -217,6 +217,96 @@ typedef struct SHADER_BUFFER {
BOOL newline;
} SHADER_BUFFER;
enum WINED3D_SHADER_INSTRUCTION_HANDLER
{
WINED3DSIH_ABS,
WINED3DSIH_ADD,
WINED3DSIH_BEM,
WINED3DSIH_BREAK,
WINED3DSIH_BREAKC,
WINED3DSIH_BREAKP,
WINED3DSIH_CALL,
WINED3DSIH_CALLNZ,
WINED3DSIH_CMP,
WINED3DSIH_CND,
WINED3DSIH_CRS,
WINED3DSIH_DCL,
WINED3DSIH_DEF,
WINED3DSIH_DEFB,
WINED3DSIH_DEFI,
WINED3DSIH_DP2ADD,
WINED3DSIH_DP3,
WINED3DSIH_DP4,
WINED3DSIH_DST,
WINED3DSIH_DSX,
WINED3DSIH_DSY,
WINED3DSIH_ELSE,
WINED3DSIH_ENDIF,
WINED3DSIH_ENDLOOP,
WINED3DSIH_ENDREP,
WINED3DSIH_EXP,
WINED3DSIH_EXPP,
WINED3DSIH_FRC,
WINED3DSIH_IF,
WINED3DSIH_IFC,
WINED3DSIH_LABEL,
WINED3DSIH_LIT,
WINED3DSIH_LOG,
WINED3DSIH_LOGP,
WINED3DSIH_LOOP,
WINED3DSIH_LRP,
WINED3DSIH_M3x2,
WINED3DSIH_M3x3,
WINED3DSIH_M3x4,
WINED3DSIH_M4x3,
WINED3DSIH_M4x4,
WINED3DSIH_MAD,
WINED3DSIH_MAX,
WINED3DSIH_MIN,
WINED3DSIH_MOV,
WINED3DSIH_MOVA,
WINED3DSIH_MUL,
WINED3DSIH_NOP,
WINED3DSIH_NRM,
WINED3DSIH_PHASE,
WINED3DSIH_POW,
WINED3DSIH_RCP,
WINED3DSIH_REP,
WINED3DSIH_RET,
WINED3DSIH_RSQ,
WINED3DSIH_SETP,
WINED3DSIH_SGE,
WINED3DSIH_SGN,
WINED3DSIH_SINCOS,
WINED3DSIH_SLT,
WINED3DSIH_SUB,
WINED3DSIH_TEX,
WINED3DSIH_TEXBEM,
WINED3DSIH_TEXBEML,
WINED3DSIH_TEXCOORD,
WINED3DSIH_TEXDEPTH,
WINED3DSIH_TEXDP3,
WINED3DSIH_TEXDP3TEX,
WINED3DSIH_TEXKILL,
WINED3DSIH_TEXLDD,
WINED3DSIH_TEXLDL,
WINED3DSIH_TEXM3x2DEPTH,
WINED3DSIH_TEXM3x2PAD,
WINED3DSIH_TEXM3x2TEX,
WINED3DSIH_TEXM3x3,
WINED3DSIH_TEXM3x3DIFF,
WINED3DSIH_TEXM3x3PAD,
WINED3DSIH_TEXM3x3SPEC,
WINED3DSIH_TEXM3x3TEX,
WINED3DSIH_TEXM3x3VSPEC,
WINED3DSIH_TEXREG2AR,
WINED3DSIH_TEXREG2GB,
WINED3DSIH_TEXREG2RGB,
WINED3DSIH_TABLE_SIZE
};
typedef void (*SHADER_HANDLER) (struct SHADER_OPCODE_ARG*);
struct shader_caps {
DWORD VertexShaderVersion;
DWORD MaxVertexShaderConst;
......@@ -234,6 +324,7 @@ struct shader_caps {
};
typedef struct {
const SHADER_HANDLER *shader_instruction_handler_table;
void (*shader_select)(IWineD3DDevice *iface, BOOL usePS, BOOL useVS);
void (*shader_select_depth_blt)(IWineD3DDevice *iface);
void (*shader_deselect_depth_blt)(IWineD3DDevice *iface);
......@@ -1884,7 +1975,6 @@ unsigned int count_bits(unsigned int mask);
/*** class static members ***/
void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
typedef void (*SHADER_HANDLER) (struct SHADER_OPCODE_ARG*);
/* TODO: Make this dynamic, based on shader limits ? */
#define MAX_REG_ADDR 1
......@@ -1955,8 +2045,7 @@ typedef struct SHADER_OPCODE {
const char* glname;
char dst_token;
CONST UINT num_params;
SHADER_HANDLER hw_fct;
SHADER_HANDLER hw_glsl_fct;
enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx;
DWORD min_version;
DWORD max_version;
} SHADER_OPCODE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment