static const char * const shader_opcode_names[] =
{
- /* WINED3DSIH_ABS */ "abs",
- /* WINED3DSIH_ADD */ "add",
- /* WINED3DSIH_AND */ "and",
- /* WINED3DSIH_BEM */ "bem",
- /* WINED3DSIH_BREAK */ "break",
- /* WINED3DSIH_BREAKC */ "breakc",
- /* WINED3DSIH_BREAKP */ "breakp",
- /* WINED3DSIH_CALL */ "call",
- /* WINED3DSIH_CALLNZ */ "callnz",
- /* WINED3DSIH_CMP */ "cmp",
- /* WINED3DSIH_CND */ "cnd",
- /* WINED3DSIH_CRS */ "crs",
- /* WINED3DSIH_CUT */ "cut",
- /* WINED3DSIH_DCL */ "dcl",
- /* WINED3DSIH_DCL_CONSTANT_BUFFER */ "dcl_constantBuffer",
- /* WINED3DSIH_DCL_GLOBAL_FLAGS */ "dcl_globalFlags",
- /* WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER */ "dcl_immediateConstantBuffer",
- /* WINED3DSIH_DCL_INPUT */ "dcl_input",
- /* WINED3DSIH_DCL_INPUT_PRIMITIVE */ "dcl_inputPrimitive",
- /* WINED3DSIH_DCL_INPUT_PS */ "dcl_input_ps",
- /* WINED3DSIH_DCL_INPUT_PS_SGV */ "dcl_input_ps_sgv",
- /* WINED3DSIH_DCL_INPUT_PS_SIV */ "dcl_input_ps_siv",
- /* WINED3DSIH_DCL_INPUT_SGV */ "dcl_input_sgv",
- /* WINED3DSIH_DCL_INPUT_SIV */ "dcl_input_siv",
- /* WINED3DSIH_DCL_OUTPUT */ "dcl_output",
- /* WINED3DSIH_DCL_OUTPUT_SIV */ "dcl_output_siv",
- /* WINED3DSIH_DCL_OUTPUT_TOPOLOGY */ "dcl_outputTopology",
- /* WINED3DSIH_DCL_SAMPLER */ "dcl_sampler",
- /* WINED3DSIH_DCL_TEMPS */ "dcl_temps",
- /* WINED3DSIH_DCL_VERTICES_OUT */ "dcl_maxOutputVertexCount",
- /* WINED3DSIH_DEF */ "def",
- /* WINED3DSIH_DEFB */ "defb",
- /* WINED3DSIH_DEFI */ "defi",
- /* WINED3DSIH_DIV */ "div",
- /* WINED3DSIH_DP2 */ "dp2",
- /* WINED3DSIH_DP2ADD */ "dp2add",
- /* WINED3DSIH_DP3 */ "dp3",
- /* WINED3DSIH_DP4 */ "dp4",
- /* WINED3DSIH_DST */ "dst",
- /* WINED3DSIH_DSX */ "dsx",
- /* WINED3DSIH_DSY */ "dsy",
- /* WINED3DSIH_ELSE */ "else",
- /* WINED3DSIH_EMIT */ "emit",
- /* WINED3DSIH_ENDIF */ "endif",
- /* WINED3DSIH_ENDLOOP */ "endloop",
- /* WINED3DSIH_ENDREP */ "endrep",
- /* WINED3DSIH_EQ */ "eq",
- /* WINED3DSIH_EXP */ "exp",
- /* WINED3DSIH_EXPP */ "expp",
- /* WINED3DSIH_FRC */ "frc",
- /* WINED3DSIH_FTOI */ "ftoi",
- /* WINED3DSIH_FTOU */ "ftou",
- /* WINED3DSIH_GE */ "ge",
- /* WINED3DSIH_IADD */ "iadd",
- /* WINED3DSIH_IEQ */ "ieq",
- /* WINED3DSIH_IF */ "if",
- /* WINED3DSIH_IFC */ "ifc",
- /* WINED3DSIH_IGE */ "ige",
- /* WINED3DSIH_ILT */ "ilt",
- /* WINED3DSIH_IMAD */ "imad",
- /* WINED3DSIH_IMAX */ "imax",
- /* WINED3DSIH_IMIN */ "imin",
- /* WINED3DSIH_IMUL */ "imul",
- /* WINED3DSIH_INE */ "ine",
- /* WINED3DSIH_INEG */ "ineg",
- /* WINED3DSIH_ISHL */ "ishl",
- /* WINED3DSIH_ITOF */ "itof",
- /* WINED3DSIH_LABEL */ "label",
- /* WINED3DSIH_LD */ "ld",
- /* WINED3DSIH_LIT */ "lit",
- /* WINED3DSIH_LOG */ "log",
- /* WINED3DSIH_LOGP */ "logp",
- /* WINED3DSIH_LOOP */ "loop",
- /* WINED3DSIH_LRP */ "lrp",
- /* WINED3DSIH_LT */ "lt",
- /* WINED3DSIH_M3x2 */ "m3x2",
- /* WINED3DSIH_M3x3 */ "m3x3",
- /* WINED3DSIH_M3x4 */ "m3x4",
- /* WINED3DSIH_M4x3 */ "m4x3",
- /* WINED3DSIH_M4x4 */ "m4x4",
- /* WINED3DSIH_MAD */ "mad",
- /* WINED3DSIH_MAX */ "max",
- /* WINED3DSIH_MIN */ "min",
- /* WINED3DSIH_MOV */ "mov",
- /* WINED3DSIH_MOVA */ "mova",
- /* WINED3DSIH_MOVC */ "movc",
- /* WINED3DSIH_MUL */ "mul",
- /* WINED3DSIH_NE */ "ne",
- /* WINED3DSIH_NOP */ "nop",
- /* WINED3DSIH_NOT */ "not",
- /* WINED3DSIH_NRM */ "nrm",
- /* WINED3DSIH_OR */ "or",
- /* WINED3DSIH_PHASE */ "phase",
- /* WINED3DSIH_POW */ "pow",
- /* WINED3DSIH_RCP */ "rcp",
- /* WINED3DSIH_REP */ "rep",
- /* WINED3DSIH_RESINFO */ "resinfo",
- /* WINED3DSIH_RET */ "ret",
- /* WINED3DSIH_ROUND_NI */ "round_ni",
- /* WINED3DSIH_ROUND_PI */ "round_pi",
- /* WINED3DSIH_ROUND_Z */ "round_z",
- /* WINED3DSIH_RSQ */ "rsq",
- /* WINED3DSIH_SAMPLE */ "sample",
- /* WINED3DSIH_SAMPLE_B */ "sample_b",
- /* WINED3DSIH_SAMPLE_C */ "sample_c",
- /* WINED3DSIH_SAMPLE_C_LZ */ "sample_c_lz",
- /* WINED3DSIH_SAMPLE_GRAD */ "sample_d",
- /* WINED3DSIH_SAMPLE_LOD */ "sample_l",
- /* WINED3DSIH_SETP */ "setp",
- /* WINED3DSIH_SGE */ "sge",
- /* WINED3DSIH_SGN */ "sgn",
- /* WINED3DSIH_SINCOS */ "sincos",
- /* WINED3DSIH_SLT */ "slt",
- /* WINED3DSIH_SQRT */ "sqrt",
- /* WINED3DSIH_SUB */ "sub",
- /* WINED3DSIH_TEX */ "texld",
- /* WINED3DSIH_TEXBEM */ "texbem",
- /* WINED3DSIH_TEXBEML */ "texbeml",
- /* WINED3DSIH_TEXCOORD */ "texcrd",
- /* WINED3DSIH_TEXDEPTH */ "texdepth",
- /* WINED3DSIH_TEXDP3 */ "texdp3",
- /* WINED3DSIH_TEXDP3TEX */ "texdp3tex",
- /* WINED3DSIH_TEXKILL */ "texkill",
- /* WINED3DSIH_TEXLDD */ "texldd",
- /* WINED3DSIH_TEXLDL */ "texldl",
- /* WINED3DSIH_TEXM3x2DEPTH */ "texm3x2depth",
- /* WINED3DSIH_TEXM3x2PAD */ "texm3x2pad",
- /* WINED3DSIH_TEXM3x2TEX */ "texm3x2tex",
- /* WINED3DSIH_TEXM3x3 */ "texm3x3",
- /* WINED3DSIH_TEXM3x3DIFF */ "texm3x3diff",
- /* WINED3DSIH_TEXM3x3PAD */ "texm3x3pad",
- /* WINED3DSIH_TEXM3x3SPEC */ "texm3x3spec",
- /* WINED3DSIH_TEXM3x3TEX */ "texm3x3tex",
- /* WINED3DSIH_TEXM3x3VSPEC */ "texm3x3vspec",
- /* WINED3DSIH_TEXREG2AR */ "texreg2ar",
- /* WINED3DSIH_TEXREG2GB */ "texreg2gb",
- /* WINED3DSIH_TEXREG2RGB */ "texreg2rgb",
- /* WINED3DSIH_UDIV */ "udiv",
- /* WINED3DSIH_UGE */ "uge",
- /* WINED3DSIH_USHR */ "ushr",
- /* WINED3DSIH_UTOF */ "utof",
- /* WINED3DSIH_XOR */ "xor",
+ /* WINED3DSIH_ABS */ "abs",
+ /* WINED3DSIH_ADD */ "add",
+ /* WINED3DSIH_AND */ "and",
+ /* WINED3DSIH_ATOMIC_AND */ "atomic_and",
+ /* WINED3DSIH_ATOMIC_CMP_STORE */ "atomic_cmp_store",
+ /* WINED3DSIH_ATOMIC_IADD */ "atomic_iadd",
+ /* WINED3DSIH_ATOMIC_IMAX */ "atomic_imax",
+ /* WINED3DSIH_ATOMIC_IMIN */ "atomic_imin",
+ /* WINED3DSIH_ATOMIC_OR */ "atomic_or",
+ /* WINED3DSIH_ATOMIC_UMAX */ "atomic_umax",
+ /* WINED3DSIH_ATOMIC_UMIN */ "atomic_umin",
+ /* WINED3DSIH_ATOMIC_XOR */ "atomic_xor",
+ /* WINED3DSIH_BEM */ "bem",
+ /* WINED3DSIH_BFI */ "bfi",
+ /* WINED3DSIH_BFREV */ "bfrev",
+ /* WINED3DSIH_BREAK */ "break",
+ /* WINED3DSIH_BREAKC */ "breakc",
+ /* WINED3DSIH_BREAKP */ "breakp",
+ /* WINED3DSIH_BUFINFO */ "bufinfo",
+ /* WINED3DSIH_CALL */ "call",
+ /* WINED3DSIH_CALLNZ */ "callnz",
+ /* WINED3DSIH_CASE */ "case",
+ /* WINED3DSIH_CMP */ "cmp",
+ /* WINED3DSIH_CND */ "cnd",
+ /* WINED3DSIH_CONTINUE */ "continue",
+ /* WINED3DSIH_CONTINUEP */ "continuec",
+ /* WINED3DSIH_COUNTBITS */ "countbits",
+ /* WINED3DSIH_CRS */ "crs",
+ /* WINED3DSIH_CUT */ "cut",
+ /* WINED3DSIH_CUT_STREAM */ "cut_stream",
+ /* WINED3DSIH_DCL */ "dcl",
+ /* WINED3DSIH_DCL_CONSTANT_BUFFER */ "dcl_constantBuffer",
+ /* WINED3DSIH_DCL_FUNCTION_BODY */ "dcl_function_body",
+ /* WINED3DSIH_DCL_FUNCTION_TABLE */ "dcl_function_table",
+ /* WINED3DSIH_DCL_GLOBAL_FLAGS */ "dcl_globalFlags",
+ /* WINED3DSIH_DCL_GS_INSTANCES */ "dcl_gs_instances",
+ /* WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT */ "dcl_hs_fork_phase_instance_count",
+ /* WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT */ "dcl_hs_join_phase_instance_count",
+ /* WINED3DSIH_DCL_HS_MAX_TESSFACTOR */ "dcl_hs_max_tessfactor",
+ /* WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER */ "dcl_immediateConstantBuffer",
+ /* WINED3DSIH_DCL_INDEX_RANGE */ "dcl_index_range",
+ /* WINED3DSIH_DCL_INDEXABLE_TEMP */ "dcl_indexableTemp",
+ /* WINED3DSIH_DCL_INPUT */ "dcl_input",
+ /* WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT */ "dcl_input_control_point_count",
+ /* WINED3DSIH_DCL_INPUT_PRIMITIVE */ "dcl_inputPrimitive",
+ /* WINED3DSIH_DCL_INPUT_PS */ "dcl_input_ps",
+ /* WINED3DSIH_DCL_INPUT_PS_SGV */ "dcl_input_ps_sgv",
+ /* WINED3DSIH_DCL_INPUT_PS_SIV */ "dcl_input_ps_siv",
+ /* WINED3DSIH_DCL_INPUT_SGV */ "dcl_input_sgv",
+ /* WINED3DSIH_DCL_INPUT_SIV */ "dcl_input_siv",
+ /* WINED3DSIH_DCL_INTERFACE */ "dcl_interface",
+ /* WINED3DSIH_DCL_OUTPUT */ "dcl_output",
+ /* WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT */ "dcl_output_control_point_count",
+ /* WINED3DSIH_DCL_OUTPUT_SIV */ "dcl_output_siv",
+ /* WINED3DSIH_DCL_OUTPUT_TOPOLOGY */ "dcl_outputTopology",
+ /* WINED3DSIH_DCL_RESOURCE_RAW */ "dcl_resource_raw",
+ /* WINED3DSIH_DCL_RESOURCE_STRUCTURED */ "dcl_resource_structured",
+ /* WINED3DSIH_DCL_SAMPLER */ "dcl_sampler",
+ /* WINED3DSIH_DCL_STREAM */ "dcl_stream",
+ /* WINED3DSIH_DCL_TEMPS */ "dcl_temps",
+ /* WINED3DSIH_DCL_TESSELLATOR_DOMAIN */ "dcl_tessellator_domain",
+ /* WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE */ "dcl_tessellator_output_primitive",
+ /* WINED3DSIH_DCL_TESSELLATOR_PARTITIONING */ "dcl_tessellator_partitioning",
+ /* WINED3DSIH_DCL_TGSM_RAW */ "dcl_tgsm_raw",
+ /* WINED3DSIH_DCL_TGSM_STRUCTURED */ "dcl_tgsm_structured",
+ /* WINED3DSIH_DCL_THREAD_GROUP */ "dcl_thread_group",
+ /* WINED3DSIH_DCL_UAV_RAW */ "dcl_uav_raw",
+ /* WINED3DSIH_DCL_UAV_STRUCTURED */ "dcl_uav_structured",
+ /* WINED3DSIH_DCL_UAV_TYPED */ "dcl_uav_typed",
+ /* WINED3DSIH_DCL_VERTICES_OUT */ "dcl_maxOutputVertexCount",
+ /* WINED3DSIH_DEF */ "def",
+ /* WINED3DSIH_DEFAULT */ "default",
+ /* WINED3DSIH_DEFB */ "defb",
+ /* WINED3DSIH_DEFI */ "defi",
+ /* WINED3DSIH_DIV */ "div",
+ /* WINED3DSIH_DP2 */ "dp2",
+ /* WINED3DSIH_DP2ADD */ "dp2add",
+ /* WINED3DSIH_DP3 */ "dp3",
+ /* WINED3DSIH_DP4 */ "dp4",
+ /* WINED3DSIH_DST */ "dst",
+ /* WINED3DSIH_DSX */ "dsx",
+ /* WINED3DSIH_DSX_COARSE */ "deriv_rtx_coarse",
+ /* WINED3DSIH_DSX_FINE */ "deriv_rtx_fine",
+ /* WINED3DSIH_DSY */ "dsy",
+ /* WINED3DSIH_DSY_COARSE */ "deriv_rty_coarse",
+ /* WINED3DSIH_DSY_FINE */ "deriv_rty_fine",
+ /* WINED3DSIH_ELSE */ "else",
+ /* WINED3DSIH_EMIT */ "emit",
+ /* WINED3DSIH_EMIT_STREAM */ "emit_stream",
+ /* WINED3DSIH_ENDIF */ "endif",
+ /* WINED3DSIH_ENDLOOP */ "endloop",
+ /* WINED3DSIH_ENDREP */ "endrep",
+ /* WINED3DSIH_ENDSWITCH */ "endswitch",
+ /* WINED3DSIH_EQ */ "eq",
+ /* WINED3DSIH_EXP */ "exp",
+ /* WINED3DSIH_EXPP */ "expp",
+ /* WINED3DSIH_F16TOF32 */ "f16tof32",
+ /* WINED3DSIH_F32TOF16 */ "f32tof16",
+ /* WINED3DSIH_FCALL */ "fcall",
+ /* WINED3DSIH_FIRSTBIT_HI */ "firstbit_hi",
+ /* WINED3DSIH_FIRSTBIT_LO */ "firstbit_lo",
+ /* WINED3DSIH_FIRSTBIT_SHI */ "firstbit_shi",
+ /* WINED3DSIH_FRC */ "frc",
+ /* WINED3DSIH_FTOI */ "ftoi",
+ /* WINED3DSIH_FTOU */ "ftou",
+ /* WINED3DSIH_GATHER4 */ "gather4",
+ /* WINED3DSIH_GATHER4_C */ "gather4_c",
+ /* WINED3DSIH_GATHER4_PO */ "gather4_po",
+ /* WINED3DSIH_GATHER4_PO_C */ "gather4_po_c",
+ /* WINED3DSIH_GE */ "ge",
+ /* WINED3DSIH_HS_CONTROL_POINT_PHASE */ "hs_control_point_phase",
+ /* WINED3DSIH_HS_DECLS */ "hs_decls",
+ /* WINED3DSIH_HS_FORK_PHASE */ "hs_fork_phase",
+ /* WINED3DSIH_HS_JOIN_PHASE */ "hs_join_phase",
+ /* WINED3DSIH_IADD */ "iadd",
+ /* WINED3DSIH_IBFE */ "ibfe",
+ /* WINED3DSIH_IEQ */ "ieq",
+ /* WINED3DSIH_IF */ "if",
+ /* WINED3DSIH_IFC */ "ifc",
+ /* WINED3DSIH_IGE */ "ige",
+ /* WINED3DSIH_ILT */ "ilt",
+ /* WINED3DSIH_IMAD */ "imad",
+ /* WINED3DSIH_IMAX */ "imax",
+ /* WINED3DSIH_IMIN */ "imin",
+ /* WINED3DSIH_IMM_ATOMIC_ALLOC */ "imm_atomic_alloc",
+ /* WINED3DSIH_IMM_ATOMIC_AND */ "imm_atomic_and",
+ /* WINED3DSIH_IMM_ATOMIC_CMP_EXCH */ "imm_atomic_cmp_exch",
+ /* WINED3DSIH_IMM_ATOMIC_CONSUME */ "imm_atomic_consume",
+ /* WINED3DSIH_IMM_ATOMIC_EXCH */ "imm_atomic_exch",
+ /* WINED3DSIH_IMM_ATOMIC_IADD */ "imm_atomic_iadd",
+ /* WINED3DSIH_IMM_ATOMIC_IMAX */ "imm_atomic_imax",
+ /* WINED3DSIH_IMM_ATOMIC_IMIN */ "imm_atomic_imin",
+ /* WINED3DSIH_IMM_ATOMIC_OR */ "imm_atomic_or",
+ /* WINED3DSIH_IMM_ATOMIC_UMAX */ "imm_atomic_umax",
+ /* WINED3DSIH_IMM_ATOMIC_UMIN */ "imm_atomic_umin",
+ /* WINED3DSIH_IMM_ATOMIC_XOR */ "imm_atomic_xor",
+ /* WINED3DSIH_IMUL */ "imul",
+ /* WINED3DSIH_INE */ "ine",
+ /* WINED3DSIH_INEG */ "ineg",
+ /* WINED3DSIH_ISHL */ "ishl",
+ /* WINED3DSIH_ISHR */ "ishr",
+ /* WINED3DSIH_ITOF */ "itof",
+ /* WINED3DSIH_LABEL */ "label",
+ /* WINED3DSIH_LD */ "ld",
+ /* WINED3DSIH_LD2DMS */ "ld2dms",
+ /* WINED3DSIH_LD_RAW */ "ld_raw",
+ /* WINED3DSIH_LD_STRUCTURED */ "ld_structured",
+ /* WINED3DSIH_LD_UAV_TYPED */ "ld_uav_typed",
+ /* WINED3DSIH_LIT */ "lit",
+ /* WINED3DSIH_LOD */ "lod",
+ /* WINED3DSIH_LOG */ "log",
+ /* WINED3DSIH_LOGP */ "logp",
+ /* WINED3DSIH_LOOP */ "loop",
+ /* WINED3DSIH_LRP */ "lrp",
+ /* WINED3DSIH_LT */ "lt",
+ /* WINED3DSIH_M3x2 */ "m3x2",
+ /* WINED3DSIH_M3x3 */ "m3x3",
+ /* WINED3DSIH_M3x4 */ "m3x4",
+ /* WINED3DSIH_M4x3 */ "m4x3",
+ /* WINED3DSIH_M4x4 */ "m4x4",
+ /* WINED3DSIH_MAD */ "mad",
+ /* WINED3DSIH_MAX */ "max",
+ /* WINED3DSIH_MIN */ "min",
+ /* WINED3DSIH_MOV */ "mov",
+ /* WINED3DSIH_MOVA */ "mova",
+ /* WINED3DSIH_MOVC */ "movc",
+ /* WINED3DSIH_MUL */ "mul",
+ /* WINED3DSIH_NE */ "ne",
+ /* WINED3DSIH_NOP */ "nop",
+ /* WINED3DSIH_NOT */ "not",
+ /* WINED3DSIH_NRM */ "nrm",
+ /* WINED3DSIH_OR */ "or",
+ /* WINED3DSIH_PHASE */ "phase",
+ /* WINED3DSIH_POW */ "pow",
+ /* WINED3DSIH_RCP */ "rcp",
+ /* WINED3DSIH_REP */ "rep",
+ /* WINED3DSIH_RESINFO */ "resinfo",
+ /* WINED3DSIH_RET */ "ret",
+ /* WINED3DSIH_RETP */ "retp",
+ /* WINED3DSIH_ROUND_NE */ "round_ne",
+ /* WINED3DSIH_ROUND_NI */ "round_ni",
+ /* WINED3DSIH_ROUND_PI */ "round_pi",
+ /* WINED3DSIH_ROUND_Z */ "round_z",
+ /* WINED3DSIH_RSQ */ "rsq",
+ /* WINED3DSIH_SAMPLE */ "sample",
+ /* WINED3DSIH_SAMPLE_B */ "sample_b",
+ /* WINED3DSIH_SAMPLE_C */ "sample_c",
+ /* WINED3DSIH_SAMPLE_C_LZ */ "sample_c_lz",
+ /* WINED3DSIH_SAMPLE_GRAD */ "sample_d",
+ /* WINED3DSIH_SAMPLE_INFO */ "sample_info",
+ /* WINED3DSIH_SAMPLE_LOD */ "sample_l",
+ /* WINED3DSIH_SAMPLE_POS */ "sample_pos",
+ /* WINED3DSIH_SETP */ "setp",
+ /* WINED3DSIH_SGE */ "sge",
+ /* WINED3DSIH_SGN */ "sgn",
+ /* WINED3DSIH_SINCOS */ "sincos",
+ /* WINED3DSIH_SLT */ "slt",
+ /* WINED3DSIH_SQRT */ "sqrt",
+ /* WINED3DSIH_STORE_RAW */ "store_raw",
+ /* WINED3DSIH_STORE_STRUCTURED */ "store_structured",
+ /* WINED3DSIH_STORE_UAV_TYPED */ "store_uav_typed",
+ /* WINED3DSIH_SUB */ "sub",
+ /* WINED3DSIH_SWAPC */ "swapc",
+ /* WINED3DSIH_SWITCH */ "switch",
+ /* WINED3DSIH_SYNC */ "sync",
+ /* WINED3DSIH_TEX */ "texld",
+ /* WINED3DSIH_TEXBEM */ "texbem",
+ /* WINED3DSIH_TEXBEML */ "texbeml",
+ /* WINED3DSIH_TEXCOORD */ "texcrd",
+ /* WINED3DSIH_TEXDEPTH */ "texdepth",
+ /* WINED3DSIH_TEXDP3 */ "texdp3",
+ /* WINED3DSIH_TEXDP3TEX */ "texdp3tex",
+ /* WINED3DSIH_TEXKILL */ "texkill",
+ /* WINED3DSIH_TEXLDD */ "texldd",
+ /* WINED3DSIH_TEXLDL */ "texldl",
+ /* WINED3DSIH_TEXM3x2DEPTH */ "texm3x2depth",
+ /* WINED3DSIH_TEXM3x2PAD */ "texm3x2pad",
+ /* WINED3DSIH_TEXM3x2TEX */ "texm3x2tex",
+ /* WINED3DSIH_TEXM3x3 */ "texm3x3",
+ /* WINED3DSIH_TEXM3x3DIFF */ "texm3x3diff",
+ /* WINED3DSIH_TEXM3x3PAD */ "texm3x3pad",
+ /* WINED3DSIH_TEXM3x3SPEC */ "texm3x3spec",
+ /* WINED3DSIH_TEXM3x3TEX */ "texm3x3tex",
+ /* WINED3DSIH_TEXM3x3VSPEC */ "texm3x3vspec",
+ /* WINED3DSIH_TEXREG2AR */ "texreg2ar",
+ /* WINED3DSIH_TEXREG2GB */ "texreg2gb",
+ /* WINED3DSIH_TEXREG2RGB */ "texreg2rgb",
+ /* WINED3DSIH_UBFE */ "ubfe",
+ /* WINED3DSIH_UDIV */ "udiv",
+ /* WINED3DSIH_UGE */ "uge",
+ /* WINED3DSIH_ULT */ "ult",
+ /* WINED3DSIH_UMAX */ "umax",
+ /* WINED3DSIH_UMIN */ "umin",
+ /* WINED3DSIH_UMUL */ "umul",
+ /* WINED3DSIH_USHR */ "ushr",
+ /* WINED3DSIH_UTOF */ "utof",
+ /* WINED3DSIH_XOR */ "xor",
};
static const char * const semantic_names[] =
static const struct
{
- enum wined3d_sysval_semantic sysval_semantic;
+ enum wined3d_shader_input_sysval_semantic sysval_semantic;
const char *sysval_name;
}
-sysval_semantic_names[] =
+shader_input_sysval_semantic_names[] =
{
- {WINED3D_SV_POSITION, "SV_Position"},
- {WINED3D_SV_INSTANCEID, "SV_InstanceID"},
- {WINED3D_SV_PRIMITIVEID, "SV_PrimitiveID"},
- {WINED3D_SV_ISFRONTFACE, "SV_IsFrontFace"},
- {WINED3D_SV_SAMPLEINDEX, "SV_SampleIndex"},
+ {WINED3D_SIV_POSITION, "position"},
+ {WINED3D_SIV_CLIP_DISTANCE, "clip_distance"},
+ {WINED3D_SIV_CULL_DISTANCE, "cull_distance"},
+ {WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX, "render_target_array_index"},
+ {WINED3D_SIV_VIEWPORT_ARRAY_INDEX, "viewport_array_index"},
+ {WINED3D_SIV_VERTEX_ID, "vertex_id"},
+ {WINED3D_SIV_INSTANCE_ID, "instance_id"},
+ {WINED3D_SIV_PRIMITIVE_ID, "primitive_id"},
+ {WINED3D_SIV_IS_FRONT_FACE, "is_front_face"},
+ {WINED3D_SIV_SAMPLE_INDEX, "sample_index"},
+ {WINED3D_SIV_QUAD_U0_TESS_FACTOR, "finalQuadUeq0EdgeTessFactor"},
+ {WINED3D_SIV_QUAD_V0_TESS_FACTOR, "finalQuadVeq0EdgeTessFactor"},
+ {WINED3D_SIV_QUAD_U1_TESS_FACTOR, "finalQuadUeq1EdgeTessFactor"},
+ {WINED3D_SIV_QUAD_V1_TESS_FACTOR, "finalQuadVeq1EdgeTessFactor"},
+ {WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR, "finalQuadUInsideTessFactor"},
+ {WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR, "finalQuadVInsideTessFactor"},
+ {WINED3D_SIV_TRIANGLE_U_TESS_FACTOR, "finalTriUeq0EdgeTessFactor"},
+ {WINED3D_SIV_TRIANGLE_V_TESS_FACTOR, "finalTriVeq0EdgeTessFactor"},
+ {WINED3D_SIV_TRIANGLE_W_TESS_FACTOR, "finalTriWeq0EdgeTessFactor"},
+ {WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR, "finalTriInsideTessFactor"},
+ {WINED3D_SIV_LINE_DETAIL_TESS_FACTOR, "finalLineDetailTessFactor"},
+ {WINED3D_SIV_LINE_DENSITY_TESS_FACTOR, "finalLineDensityTessFactor"},
};
static void shader_dump_src_param(struct wined3d_string_buffer *buffer,
const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx)
{
- if (handler_idx >= sizeof(shader_opcode_names) / sizeof(*shader_opcode_names))
+ if (handler_idx >= ARRAY_SIZE(shader_opcode_names))
return wine_dbg_sprintf("UNRECOGNIZED(%#x)", handler_idx);
return shader_opcode_names[handler_idx];
static const char *shader_semantic_name_from_usage(enum wined3d_decl_usage usage)
{
- if (usage >= sizeof(semantic_names) / sizeof(*semantic_names))
+ if (usage >= ARRAY_SIZE(semantic_names))
{
FIXME("Unrecognized usage %#x.\n", usage);
return "UNRECOGNIZED";
{
unsigned int i;
- for (i = 0; i < sizeof(semantic_names) / sizeof(*semantic_names); ++i)
+ for (i = 0; i < ARRAY_SIZE(semantic_names); ++i)
{
- if (!strcmp(name, semantic_names[i])) return i;
+ if (!strcmp(name, semantic_names[i]))
+ return i;
}
return ~0U;
}
+static enum wined3d_sysval_semantic shader_sysval_semantic_from_usage(enum wined3d_decl_usage usage)
+{
+ switch (usage)
+ {
+ case WINED3D_DECL_USAGE_POSITION:
+ return WINED3D_SV_POSITION;
+ default:
+ return 0;
+ }
+}
+
BOOL shader_match_semantic(const char *semantic_name, enum wined3d_decl_usage usage)
{
return !strcmp(semantic_name, shader_semantic_name_from_usage(usage));
{
e->semantic_name = shader_semantic_name_from_usage(s->usage);
e->semantic_idx = s->usage_idx;
- e->sysval_semantic = 0;
- e->component_type = 0;
+ e->stream_idx = 0;
+ e->sysval_semantic = shader_sysval_semantic_from_usage(s->usage);
+ e->component_type = WINED3D_TYPE_FLOAT;
e->register_idx = s->reg.reg.idx[0].offset;
e->mask = s->reg.write_mask;
}
{
e->semantic_name = shader_semantic_name_from_usage(usage);
e->semantic_idx = usage_idx;
- e->sysval_semantic = 0;
- e->component_type = 0;
+ e->stream_idx = 0;
+ e->sysval_semantic = shader_sysval_semantic_from_usage(usage);
+ e->component_type = WINED3D_TYPE_FLOAT;
e->register_idx = reg_idx;
e->mask = write_mask;
}
-static const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token)
+static const struct wined3d_shader_frontend *shader_select_frontend(enum wined3d_shader_byte_code_format format)
{
- switch (version_token >> 16)
+ switch (format)
{
- case WINED3D_SM1_VS:
- case WINED3D_SM1_PS:
+ case WINED3D_SHADER_BYTE_CODE_FORMAT_SM1:
return &sm1_shader_frontend;
- case WINED3D_SM4_PS:
- case WINED3D_SM4_VS:
- case WINED3D_SM4_GS:
+ case WINED3D_SHADER_BYTE_CODE_FORMAT_SM4:
return &sm4_shader_frontend;
default:
- FIXME("Unrecognised version token %#x\n", version_token);
+ WARN("Invalid byte code format %#x specified.\n", format);
return NULL;
}
}
if (!buffer || !string_buffer_init(buffer))
{
ERR("Couldn't allocate buffer for temporary string.\n");
- if (buffer)
- HeapFree(GetProcessHeap(), 0, buffer);
+ HeapFree(GetProcessHeap(), 0, buffer);
return NULL;
}
}
* shaders to 256. */
{WINED3D_SHADER_VERSION(3, 0), WINED3D_SHADER_VERSION(3, 0), { 4, 16, 256, 16, 12, 0}},
{WINED3D_SHADER_VERSION(4, 0), WINED3D_SHADER_VERSION(4, 0), {16, 0, 0, 0, 16, 0}},
- {WINED3D_SHADER_VERSION(5, 0), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 32, 0}},
+ {WINED3D_SHADER_VERSION(4, 1), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 32, 0}},
{0}
},
+ hs_limits[] =
+ {
+ /* min_version, max_version, sampler, constant_int, constant_float, constant_bool, packed_output, packet_input */
+ {WINED3D_SHADER_VERSION(5, 0), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 32, 32}},
+ },
+ ds_limits[] =
+ {
+ /* min_version, max_version, sampler, constant_int, constant_float, constant_bool, packed_output, packet_input */
+ {WINED3D_SHADER_VERSION(5, 0), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 32, 32}},
+ },
gs_limits[] =
{
/* min_version, max_version, sampler, constant_int, constant_float, constant_bool, packed_output, packed_input */
{WINED3D_SHADER_VERSION(4, 0), WINED3D_SHADER_VERSION(4, 0), {16, 0, 0, 0, 32, 16}},
- {WINED3D_SHADER_VERSION(5, 0), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 32, 32}},
+ {WINED3D_SHADER_VERSION(4, 1), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 32, 32}},
{0}
},
ps_limits[] =
{WINED3D_SHADER_VERSION(1, 4), WINED3D_SHADER_VERSION(1, 4), { 6, 0, 8, 0, 0, 0}},
{WINED3D_SHADER_VERSION(2, 0), WINED3D_SHADER_VERSION(2, 0), {16, 0, 32, 0, 0, 0}},
{WINED3D_SHADER_VERSION(2, 1), WINED3D_SHADER_VERSION(2, 1), {16, 16, 32, 16, 0, 0}},
- {WINED3D_SHADER_VERSION(3, 0), WINED3D_SHADER_VERSION(3, 0), {16, 16, 224, 16, 0, 12}},
+ {WINED3D_SHADER_VERSION(3, 0), WINED3D_SHADER_VERSION(3, 0), {16, 16, 224, 16, 0, 10}},
{WINED3D_SHADER_VERSION(4, 0), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 0, 32}},
{0}
+ },
+ cs_limits[] =
+ {
+ /* min_version, max_version, sampler, constant_int, constant_float, constant_bool, packed_output, packed_input */
+ {WINED3D_SHADER_VERSION(5, 0), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 0, 0}},
};
const struct limits_entry *limits_array;
DWORD shader_version = WINED3D_SHADER_VERSION(shader->reg_maps.shader_version.major,
case WINED3D_SHADER_TYPE_VERTEX:
limits_array = vs_limits;
break;
+ case WINED3D_SHADER_TYPE_HULL:
+ limits_array = hs_limits;
+ break;
+ case WINED3D_SHADER_TYPE_DOMAIN:
+ limits_array = ds_limits;
+ break;
case WINED3D_SHADER_TYPE_GEOMETRY:
limits_array = gs_limits;
break;
case WINED3D_SHADER_TYPE_PIXEL:
limits_array = ps_limits;
break;
+ case WINED3D_SHADER_TYPE_COMPUTE:
+ limits_array = cs_limits;
+ break;
}
while (limits_array[i].min_version && limits_array[i].min_version <= shader_version)
case WINED3DSPR_INPUT:
if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
{
+ /* If relative addressing is used, we must assume that all
+ * registers are used. Even if it is a construct like v3[aL],
+ * we can't assume that v0, v1 and v2 aren't read because aL
+ * can be negative. */
if (reg->idx[0].rel_addr)
- {
- /* If relative addressing is used, we must assume that all registers
- * are used. Even if it is a construct like v3[aL], we can't assume
- * that v0, v1 and v2 aren't read because aL can be negative */
- unsigned int i;
- for (i = 0; i < MAX_REG_INPUT; ++i)
- {
- shader->u.ps.input_reg_used[i] = TRUE;
- }
- }
+ shader->u.ps.input_reg_used = ~0u;
else
- {
- shader->u.ps.input_reg_used[reg->idx[0].offset] = TRUE;
- }
+ shader->u.ps.input_reg_used |= 1u << reg->idx[0].offset;
}
else
reg_maps->input_registers |= 1u << reg->idx[0].offset;
reg_maps->rt_mask |= (1u << reg->idx[0].offset);
break;
+ case WINED3DSPR_OUTCONTROLPOINT:
+ reg_maps->vocp = 1;
+ break;
+
default:
TRACE("Not recording register of type %#x and [%#x][%#x].\n",
reg->type, reg->idx[0].offset, reg->idx[1].offset);
if (!map->size)
{
- if (!(entries = HeapAlloc(GetProcessHeap(), 0, sizeof(*entries) * 4)))
+ if (!(entries = wined3d_calloc(4, sizeof(*entries))))
{
ERR("Failed to allocate sampler map entries.\n");
return;
}
}
+static HRESULT shader_reg_maps_add_tgsm(struct wined3d_shader_reg_maps *reg_maps,
+ unsigned int register_idx, unsigned int size, unsigned int stride)
+{
+ struct wined3d_shader_tgsm *tgsm;
+
+ if (register_idx >= MAX_TGSM_REGISTERS)
+ {
+ ERR("Invalid TGSM register index %u.\n", register_idx);
+ return S_OK;
+ }
+ if (reg_maps->shader_version.type != WINED3D_SHADER_TYPE_COMPUTE)
+ {
+ FIXME("TGSM declarations are allowed only in compute shaders.\n");
+ return S_OK;
+ }
+
+ if (!wined3d_array_reserve((void **)®_maps->tgsm, ®_maps->tgsm_capacity,
+ register_idx + 1, sizeof(*reg_maps->tgsm)))
+ return E_OUTOFMEMORY;
+
+ reg_maps->tgsm_count = max(register_idx + 1, reg_maps->tgsm_count);
+ tgsm = ®_maps->tgsm[register_idx];
+ tgsm->size = size;
+ tgsm->stride = stride;
+ return S_OK;
+}
+
+static HRESULT shader_record_shader_phase(struct wined3d_shader *shader,
+ struct wined3d_shader_phase **current_phase, const struct wined3d_shader_instruction *ins,
+ const DWORD *current_instruction_ptr, const DWORD *previous_instruction_ptr)
+{
+ struct wined3d_shader_phase *phase;
+
+ if ((phase = *current_phase))
+ {
+ phase->end = previous_instruction_ptr;
+ *current_phase = NULL;
+ }
+
+ if (shader->reg_maps.shader_version.type != WINED3D_SHADER_TYPE_HULL)
+ {
+ ERR("Unexpected shader type %#x.\n", shader->reg_maps.shader_version.type);
+ return E_FAIL;
+ }
+
+ switch (ins->handler_idx)
+ {
+ case WINED3DSIH_HS_CONTROL_POINT_PHASE:
+ if (shader->u.hs.phases.control_point)
+ {
+ FIXME("Multiple control point phases.\n");
+ HeapFree(GetProcessHeap(), 0, shader->u.hs.phases.control_point);
+ }
+ if (!(shader->u.hs.phases.control_point = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY, sizeof(*shader->u.hs.phases.control_point))))
+ return E_OUTOFMEMORY;
+ phase = shader->u.hs.phases.control_point;
+ break;
+ case WINED3DSIH_HS_FORK_PHASE:
+ if (!wined3d_array_reserve((void **)&shader->u.hs.phases.fork,
+ &shader->u.hs.phases.fork_size, shader->u.hs.phases.fork_count + 1,
+ sizeof(*shader->u.hs.phases.fork)))
+ return E_OUTOFMEMORY;
+ phase = &shader->u.hs.phases.fork[shader->u.hs.phases.fork_count++];
+ break;
+ case WINED3DSIH_HS_JOIN_PHASE:
+ if (!wined3d_array_reserve((void **)&shader->u.hs.phases.join,
+ &shader->u.hs.phases.join_size, shader->u.hs.phases.join_count + 1,
+ sizeof(*shader->u.hs.phases.join)))
+ return E_OUTOFMEMORY;
+ phase = &shader->u.hs.phases.join[shader->u.hs.phases.join_count++];
+ break;
+ default:
+ ERR("Unexpected opcode %s.\n", debug_d3dshaderinstructionhandler(ins->handler_idx));
+ return E_FAIL;
+ }
+
+ phase->start = current_instruction_ptr;
+ *current_phase = phase;
+
+ return WINED3D_OK;
+}
+
/* Note that this does not count the loop register as an address register. */
static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const struct wined3d_shader_frontend *fe,
struct wined3d_shader_reg_maps *reg_maps, struct wined3d_shader_signature *input_signature,
- struct wined3d_shader_signature *output_signature, const DWORD *byte_code, DWORD constf_size)
+ struct wined3d_shader_signature *output_signature, DWORD constf_size)
{
struct wined3d_shader_signature_element input_signature_elements[max(MAX_ATTRIBS, MAX_REG_INPUT)];
struct wined3d_shader_signature_element output_signature_elements[MAX_REG_OUTPUT];
unsigned int cur_loop_depth = 0, max_loop_depth = 0;
- void *fe_data = shader->frontend_data;
struct wined3d_shader_version shader_version;
- const DWORD *ptr = byte_code;
+ struct wined3d_shader_phase *phase = NULL;
+ const DWORD *ptr, *prev_ins, *current_ins;
+ void *fe_data = shader->frontend_data;
unsigned int i;
+ HRESULT hr;
memset(reg_maps, 0, sizeof(*reg_maps));
memset(input_signature_elements, 0, sizeof(input_signature_elements));
memset(output_signature_elements, 0, sizeof(output_signature_elements));
reg_maps->min_rel_offset = ~0U;
+ list_init(®_maps->indexable_temps);
fe->shader_read_header(fe_data, &ptr, &shader_version);
+ prev_ins = current_ins = ptr;
reg_maps->shader_version = shader_version;
shader_set_limits(shader);
- reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof(*reg_maps->constf) * ((min(shader->limits->constant_float, constf_size) + 31) / 32));
- if (!reg_maps->constf)
+ if (!(reg_maps->constf = wined3d_calloc(((min(shader->limits->constant_float, constf_size) + 31) / 32),
+ sizeof(*reg_maps->constf))))
{
ERR("Failed to allocate constant map memory.\n");
return E_OUTOFMEMORY;
{
struct wined3d_shader_instruction ins;
+ current_ins = ptr;
/* Fetch opcode. */
fe->shader_read_instruction(fe_data, &ptr, &ins);
/* Unhandled opcode, and its parameters. */
if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
{
- TRACE("Skipping unrecognized instruction.\n");
- continue;
+ WARN("Encountered unrecognised or invalid instruction.\n");
+ return WINED3DERR_INVALIDCALL;
}
/* Handle declarations. */
- if (ins.handler_idx == WINED3DSIH_DCL)
+ if (ins.handler_idx == WINED3DSIH_DCL
+ || ins.handler_idx == WINED3DSIH_DCL_UAV_TYPED)
{
struct wined3d_shader_semantic *semantic = &ins.declaration.semantic;
unsigned int reg_idx = semantic->reg.reg.idx[0].offset;
reg_maps->resource_info[reg_idx].data_type = semantic->resource_data_type;
break;
+ case WINED3DSPR_UAV:
+ if (reg_idx >= ARRAY_SIZE(reg_maps->uav_resource_info))
+ {
+ ERR("Invalid UAV resource index %u.\n", reg_idx);
+ break;
+ }
+ reg_maps->uav_resource_info[reg_idx].type = semantic->resource_type;
+ reg_maps->uav_resource_info[reg_idx].data_type = semantic->resource_data_type;
+ if (ins.flags)
+ FIXME("Ignoring typed UAV flags %#x.\n", ins.flags);
+ break;
+
default:
TRACE("Not recording DCL register type %#x.\n", semantic->reg.reg.type);
break;
else
reg_maps->cb_sizes[reg->idx[0].offset] = reg->idx[1].offset;
}
+ else if (ins.handler_idx == WINED3DSIH_DCL_GS_INSTANCES)
+ {
+ if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
+ shader->u.gs.instance_count = ins.declaration.count;
+ else
+ FIXME("Invalid instruction %#x for shader type %#x.\n",
+ ins.handler_idx, shader_version.type);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
+ || ins.handler_idx == WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT)
+ {
+ if (phase)
+ phase->instance_count = ins.declaration.count;
+ else
+ FIXME("Instruction %s outside of shader phase.\n",
+ debug_d3dshaderinstructionhandler(ins.handler_idx));
+ }
else if (ins.handler_idx == WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER)
{
if (reg_maps->icb)
FIXME("Multiple immediate constant buffers.\n");
reg_maps->icb = ins.declaration.icb;
}
+ else if (ins.handler_idx == WINED3DSIH_DCL_INDEXABLE_TEMP)
+ {
+ if (phase)
+ {
+ FIXME("Indexable temporary registers not supported.\n");
+ }
+ else
+ {
+ struct wined3d_shader_indexable_temp *reg;
+
+ if (!(reg = HeapAlloc(GetProcessHeap(), 0, sizeof(*reg))))
+ return E_OUTOFMEMORY;
+
+ *reg = ins.declaration.indexable_temp;
+ list_add_tail(®_maps->indexable_temps, ®->entry);
+ }
+ }
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PRIMITIVE)
{
if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
- shader->u.gs.input_type = ins.declaration.primitive_type;
+ shader->u.gs.input_type = ins.declaration.primitive_type.type;
else
FIXME("Invalid instruction %#x for shader type %#x.\n",
ins.handler_idx, shader_version.type);
}
+ else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT)
+ {
+ if (shader_version.type == WINED3D_SHADER_TYPE_HULL)
+ shader->u.hs.output_vertex_count = ins.declaration.count;
+ else
+ FIXME("Invalid instruction %#x for shader type %#x.\n", ins.handler_idx, shader_version.type);
+ }
else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT_TOPOLOGY)
{
if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
- shader->u.gs.output_type = ins.declaration.primitive_type;
+ shader->u.gs.output_type = ins.declaration.primitive_type.type;
+ else
+ FIXME("Invalid instruction %#x for shader type %#x.\n",
+ ins.handler_idx, shader_version.type);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_RESOURCE_RAW)
+ {
+ unsigned int reg_idx = ins.declaration.dst.reg.idx[0].offset;
+ if (reg_idx >= ARRAY_SIZE(reg_maps->resource_info))
+ {
+ ERR("Invalid resource index %u.\n", reg_idx);
+ break;
+ }
+ reg_maps->resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER;
+ reg_maps->resource_info[reg_idx].data_type = WINED3D_DATA_UINT;
+ reg_maps->resource_info[reg_idx].flags = WINED3D_VIEW_BUFFER_RAW;
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_RESOURCE_STRUCTURED)
+ {
+ unsigned int reg_idx = ins.declaration.structured_resource.reg.reg.idx[0].offset;
+ if (reg_idx >= ARRAY_SIZE(reg_maps->resource_info))
+ {
+ ERR("Invalid resource index %u.\n", reg_idx);
+ break;
+ }
+ reg_maps->resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER;
+ reg_maps->resource_info[reg_idx].data_type = WINED3D_DATA_UINT;
+ reg_maps->resource_info[reg_idx].flags = 0;
+ reg_maps->resource_info[reg_idx].stride = ins.declaration.structured_resource.byte_stride / 4;
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_SAMPLER)
+ {
+ if (ins.flags & WINED3DSI_SAMPLER_COMPARISON_MODE)
+ reg_maps->sampler_comparison_mode |= (1u << ins.declaration.dst.reg.idx[0].offset);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_TEMPS)
+ {
+ if (phase)
+ phase->temporary_count = ins.declaration.count;
+ else
+ reg_maps->temporary_count = ins.declaration.count;
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_TESSELLATOR_DOMAIN)
+ {
+ if (shader_version.type == WINED3D_SHADER_TYPE_DOMAIN)
+ shader->u.ds.tessellator_domain = ins.declaration.tessellator_domain;
+ else if (shader_version.type != WINED3D_SHADER_TYPE_HULL)
+ FIXME("Invalid instruction %#x for shader type %#x.\n", ins.handler_idx, shader_version.type);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE)
+ {
+ if (shader_version.type == WINED3D_SHADER_TYPE_HULL)
+ shader->u.hs.tessellator_output_primitive = ins.declaration.tessellator_output_primitive;
+ else
+ FIXME("Invalid instruction %#x for shader type %#x.\n", ins.handler_idx, shader_version.type);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_TESSELLATOR_PARTITIONING)
+ {
+ if (shader_version.type == WINED3D_SHADER_TYPE_HULL)
+ shader->u.hs.tessellator_partitioning = ins.declaration.tessellator_partitioning;
+ else
+ FIXME("Invalid instruction %#x for shader type %#x.\n", ins.handler_idx, shader_version.type);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_TGSM_RAW)
+ {
+ if (FAILED(hr = shader_reg_maps_add_tgsm(reg_maps, ins.declaration.tgsm_raw.reg.reg.idx[0].offset,
+ ins.declaration.tgsm_raw.byte_count / 4, 0)))
+ return hr;
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_TGSM_STRUCTURED)
+ {
+ unsigned int stride = ins.declaration.tgsm_structured.byte_stride / 4;
+ unsigned int size = stride * ins.declaration.tgsm_structured.structure_count;
+ if (FAILED(hr = shader_reg_maps_add_tgsm(reg_maps,
+ ins.declaration.tgsm_structured.reg.reg.idx[0].offset, size, stride)))
+ return hr;
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_THREAD_GROUP)
+ {
+ if (shader_version.type == WINED3D_SHADER_TYPE_COMPUTE)
+ {
+ shader->u.cs.thread_group_size = ins.declaration.thread_group_size;
+ }
else
+ {
FIXME("Invalid instruction %#x for shader type %#x.\n",
ins.handler_idx, shader_version.type);
+ }
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_UAV_RAW)
+ {
+ unsigned int reg_idx = ins.declaration.dst.reg.idx[0].offset;
+ if (reg_idx >= ARRAY_SIZE(reg_maps->uav_resource_info))
+ {
+ ERR("Invalid UAV resource index %u.\n", reg_idx);
+ break;
+ }
+ if (ins.flags)
+ FIXME("Ignoring raw UAV flags %#x.\n", ins.flags);
+ reg_maps->uav_resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER;
+ reg_maps->uav_resource_info[reg_idx].data_type = WINED3D_DATA_UINT;
+ reg_maps->uav_resource_info[reg_idx].flags = WINED3D_VIEW_BUFFER_RAW;
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_UAV_STRUCTURED)
+ {
+ unsigned int reg_idx = ins.declaration.structured_resource.reg.reg.idx[0].offset;
+ if (reg_idx >= ARRAY_SIZE(reg_maps->uav_resource_info))
+ {
+ ERR("Invalid UAV resource index %u.\n", reg_idx);
+ break;
+ }
+ if (ins.flags)
+ FIXME("Ignoring structured UAV flags %#x.\n", ins.flags);
+ reg_maps->uav_resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER;
+ reg_maps->uav_resource_info[reg_idx].data_type = WINED3D_DATA_UINT;
+ reg_maps->uav_resource_info[reg_idx].flags = 0;
+ reg_maps->uav_resource_info[reg_idx].stride = ins.declaration.structured_resource.byte_stride / 4;
}
else if (ins.handler_idx == WINED3DSIH_DCL_VERTICES_OUT)
{
if (!lconst) return E_OUTOFMEMORY;
lconst->idx = ins.dst[0].reg.idx[0].offset;
- memcpy(lconst->value, ins.src[0].reg.immconst_data, 4 * sizeof(DWORD));
+ memcpy(lconst->value, ins.src[0].reg.u.immconst_data, 4 * sizeof(DWORD));
value = (float *)lconst->value;
/* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
if (!lconst) return E_OUTOFMEMORY;
lconst->idx = ins.dst[0].reg.idx[0].offset;
- memcpy(lconst->value, ins.src[0].reg.immconst_data, 4 * sizeof(DWORD));
+ memcpy(lconst->value, ins.src[0].reg.u.immconst_data, 4 * sizeof(DWORD));
list_add_head(&shader->constantsI, &lconst->entry);
reg_maps->local_int_consts |= (1u << lconst->idx);
if (!lconst) return E_OUTOFMEMORY;
lconst->idx = ins.dst[0].reg.idx[0].offset;
- memcpy(lconst->value, ins.src[0].reg.immconst_data, sizeof(DWORD));
+ memcpy(lconst->value, ins.src[0].reg.u.immconst_data, sizeof(DWORD));
list_add_head(&shader->constantsB, &lconst->entry);
reg_maps->local_bool_consts |= (1u << lconst->idx);
}
+ /* Handle shader phases. */
+ else if (ins.handler_idx == WINED3DSIH_HS_CONTROL_POINT_PHASE
+ || ins.handler_idx == WINED3DSIH_HS_FORK_PHASE
+ || ins.handler_idx == WINED3DSIH_HS_JOIN_PHASE)
+ {
+ if (FAILED(hr = shader_record_shader_phase(shader, &phase, &ins, current_ins, prev_ins)))
+ return hr;
+ }
/* For subroutine prototypes. */
else if (ins.handler_idx == WINED3DSIH_LABEL)
{
}
break;
- case WINED3DSPR_TEXCRDOUT:
+ case WINED3DSPR_TEXCRDOUT: /* WINED3DSPR_OUTPUT */
if (shader_version.major >= 3)
{
+ if (idx >= ARRAY_SIZE(reg_maps->u.output_registers_mask))
+ {
+ WARN("Invalid output register index %u.\n", idx);
+ break;
+ }
reg_maps->u.output_registers_mask[idx] |= ins.dst[i].write_mask;
break;
}
+ if (idx >= ARRAY_SIZE(reg_maps->u.texcoord_mask))
+ {
+ WARN("Invalid texcoord index %u.\n", idx);
+ break;
+ }
reg_maps->u.texcoord_mask[idx] |= ins.dst[i].write_mask;
if (reg_maps->output_registers & (1u << idx))
{
{
unsigned int reg_idx = ins.dst[i].reg.idx[0].offset;
+ if (reg_idx >= ARRAY_SIZE(reg_maps->resource_info))
+ {
+ WARN("Invalid 1.x sampler index %u.\n", reg_idx);
+ continue;
+ }
+
TRACE("Setting fake 2D resource for 1.x pixelshader.\n");
reg_maps->resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_TEXTURE_2D;
reg_maps->resource_info[reg_idx].data_type = WINED3D_DATA_FLOAT;
}
}
- if (ins.handler_idx == WINED3DSIH_NRM) reg_maps->usesnrm = 1;
- else if (ins.handler_idx == WINED3DSIH_DSY) reg_maps->usesdsy = 1;
- else if (ins.handler_idx == WINED3DSIH_DSX) reg_maps->usesdsx = 1;
+ if (ins.handler_idx == WINED3DSIH_IMM_ATOMIC_ALLOC || ins.handler_idx == WINED3DSIH_IMM_ATOMIC_CONSUME)
+ {
+ unsigned int reg_idx = ins.src[0].reg.idx[0].offset;
+ if (reg_idx >= MAX_UNORDERED_ACCESS_VIEWS)
+ {
+ ERR("Invalid UAV index %u.\n", reg_idx);
+ break;
+ }
+ reg_maps->uav_counter_mask |= (1u << reg_idx);
+ }
+ else if ((WINED3DSIH_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_ATOMIC_XOR)
+ || (WINED3DSIH_IMM_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_IMM_ATOMIC_XOR)
+ || (ins.handler_idx == WINED3DSIH_BUFINFO && ins.src[0].reg.type == WINED3DSPR_UAV)
+ || ins.handler_idx == WINED3DSIH_LD_UAV_TYPED
+ || (ins.handler_idx == WINED3DSIH_LD_RAW && ins.src[1].reg.type == WINED3DSPR_UAV)
+ || (ins.handler_idx == WINED3DSIH_LD_STRUCTURED && ins.src[2].reg.type == WINED3DSPR_UAV))
+ {
+ unsigned int reg_idx;
+ if (ins.handler_idx == WINED3DSIH_LD_UAV_TYPED || ins.handler_idx == WINED3DSIH_LD_RAW)
+ reg_idx = ins.src[1].reg.idx[0].offset;
+ else if (ins.handler_idx == WINED3DSIH_LD_STRUCTURED)
+ reg_idx = ins.src[2].reg.idx[0].offset;
+ else if (WINED3DSIH_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_ATOMIC_XOR)
+ reg_idx = ins.dst[0].reg.idx[0].offset;
+ else if (ins.handler_idx == WINED3DSIH_BUFINFO)
+ reg_idx = ins.src[0].reg.idx[0].offset;
+ else
+ reg_idx = ins.dst[1].reg.idx[0].offset;
+ if (reg_idx >= MAX_UNORDERED_ACCESS_VIEWS)
+ {
+ ERR("Invalid UAV index %u.\n", reg_idx);
+ break;
+ }
+ reg_maps->uav_read_mask |= (1u << reg_idx);
+ }
+ else if (ins.handler_idx == WINED3DSIH_NRM)
+ {
+ reg_maps->usesnrm = 1;
+ }
+ else if (ins.handler_idx == WINED3DSIH_DSY
+ || ins.handler_idx == WINED3DSIH_DSY_COARSE
+ || ins.handler_idx == WINED3DSIH_DSY_FINE)
+ {
+ reg_maps->usesdsy = 1;
+ }
+ else if (ins.handler_idx == WINED3DSIH_DSX
+ || ins.handler_idx == WINED3DSIH_DSX_COARSE
+ || ins.handler_idx == WINED3DSIH_DSX_FINE)
+ {
+ reg_maps->usesdsx = 1;
+ }
else if (ins.handler_idx == WINED3DSIH_TEXLDD) reg_maps->usestexldd = 1;
else if (ins.handler_idx == WINED3DSIH_TEXLDL) reg_maps->usestexldl = 1;
else if (ins.handler_idx == WINED3DSIH_MOVA) reg_maps->usesmova = 1;
{
--cur_loop_depth;
}
- else if (ins.handler_idx == WINED3DSIH_SAMPLE
+ else if (ins.handler_idx == WINED3DSIH_GATHER4
+ || ins.handler_idx == WINED3DSIH_GATHER4_C
+ || ins.handler_idx == WINED3DSIH_SAMPLE
|| ins.handler_idx == WINED3DSIH_SAMPLE_B
+ || ins.handler_idx == WINED3DSIH_SAMPLE_C
|| ins.handler_idx == WINED3DSIH_SAMPLE_C_LZ
|| ins.handler_idx == WINED3DSIH_SAMPLE_GRAD
|| ins.handler_idx == WINED3DSIH_SAMPLE_LOD)
shader_record_sample(reg_maps, ins.src[1].reg.idx[0].offset,
ins.src[2].reg.idx[0].offset, reg_maps->sampler_map.count);
}
+ else if (ins.handler_idx == WINED3DSIH_GATHER4_PO
+ || ins.handler_idx == WINED3DSIH_GATHER4_PO_C)
+ {
+ shader_record_sample(reg_maps, ins.src[2].reg.idx[0].offset,
+ ins.src[3].reg.idx[0].offset, reg_maps->sampler_map.count);
+ }
+ else if (ins.handler_idx == WINED3DSIH_BUFINFO && ins.src[0].reg.type == WINED3DSPR_RESOURCE)
+ {
+ shader_record_sample(reg_maps, ins.src[0].reg.idx[0].offset,
+ WINED3D_SAMPLER_DEFAULT, reg_maps->sampler_map.count);
+ }
else if (ins.handler_idx == WINED3DSIH_LD
- || ins.handler_idx == WINED3DSIH_RESINFO)
+ || (ins.handler_idx == WINED3DSIH_LD_RAW && ins.src[1].reg.type == WINED3DSPR_RESOURCE)
+ || (ins.handler_idx == WINED3DSIH_RESINFO && ins.src[1].reg.type == WINED3DSPR_RESOURCE))
{
shader_record_sample(reg_maps, ins.src[1].reg.idx[0].offset,
WINED3D_SAMPLER_DEFAULT, reg_maps->sampler_map.count);
}
+ else if (ins.handler_idx == WINED3DSIH_LD_STRUCTURED
+ && ins.src[2].reg.type == WINED3DSPR_RESOURCE)
+ {
+ shader_record_sample(reg_maps, ins.src[2].reg.idx[0].offset,
+ WINED3D_SAMPLER_DEFAULT, reg_maps->sampler_map.count);
+ }
if (ins.predicate)
if (!shader_record_register_usage(shader, reg_maps, &ins.predicate->reg,
}
}
}
+
+ prev_ins = current_ins;
}
reg_maps->loop_depth = max_loop_depth;
+ if (phase)
+ {
+ phase->end = prev_ins;
+ phase = NULL;
+ }
+
/* PS before 2.0 don't have explicit color outputs. Instead the value of
* R0 is written to the render target. */
if (shader_version.major < 2 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
reg_maps->rt_mask |= (1u << 0);
- shader->functionLength = ((const char *)ptr - (const char *)byte_code);
-
if (input_signature->elements)
{
for (i = 0; i < input_signature->element_count; ++i)
{
reg_maps->input_registers |= 1u << input_signature->elements[i].register_idx;
- if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL
- && input_signature->elements[i].sysval_semantic == WINED3D_SV_POSITION)
- reg_maps->vpos = 1;
+ if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
+ {
+ if (input_signature->elements[i].sysval_semantic == WINED3D_SV_POSITION)
+ reg_maps->vpos = 1;
+ else if (input_signature->elements[i].sysval_semantic == WINED3D_SV_IS_FRONT_FACE)
+ reg_maps->usesfacing = 1;
+ }
}
}
else if (!input_signature->elements && reg_maps->input_registers)
struct wined3d_shader_signature_element *e;
unsigned int i;
- if (!(input_signature->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*input_signature->elements) * count)))
+ if (!(input_signature->elements = wined3d_calloc(count, sizeof(*input_signature->elements))))
return E_OUTOFMEMORY;
input_signature->element_count = count;
unsigned int count = wined3d_popcount(reg_maps->output_registers);
struct wined3d_shader_signature_element *e;
- if (!(output_signature->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*output_signature->elements) * count)))
+ if (!(output_signature->elements = wined3d_calloc(count, sizeof(*output_signature->elements))))
return E_OUTOFMEMORY;
output_signature->element_count = count;
return WINED3D_OK;
}
+static void shader_cleanup_reg_maps(struct wined3d_shader_reg_maps *reg_maps)
+{
+ struct wined3d_shader_indexable_temp *reg, *reg_next;
+
+ HeapFree(GetProcessHeap(), 0, reg_maps->constf);
+ HeapFree(GetProcessHeap(), 0, reg_maps->sampler_map.entries);
+
+ LIST_FOR_EACH_ENTRY_SAFE(reg, reg_next, ®_maps->indexable_temps, struct wined3d_shader_indexable_temp, entry)
+ HeapFree(GetProcessHeap(), 0, reg);
+ list_init(®_maps->indexable_temps);
+
+ HeapFree(GetProcessHeap(), 0, reg_maps->tgsm);
+}
+
unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps, unsigned int max)
{
DWORD map = 1u << max;
shader_addline(buffer, "unknown_flags(%#x)", global_flags);
}
-static void shader_dump_sysval_semantic(struct wined3d_string_buffer *buffer, enum wined3d_sysval_semantic semantic)
+static void shader_dump_sync_flags(struct wined3d_string_buffer *buffer, DWORD sync_flags)
+{
+ if (sync_flags & WINED3DSSF_GROUP_SHARED_MEMORY)
+ {
+ shader_addline(buffer, "_g");
+ sync_flags &= ~WINED3DSSF_GROUP_SHARED_MEMORY;
+ }
+ if (sync_flags & WINED3DSSF_THREAD_GROUP)
+ {
+ shader_addline(buffer, "_t");
+ sync_flags &= ~WINED3DSSF_THREAD_GROUP;
+ }
+
+ if (sync_flags)
+ shader_addline(buffer, "_unknown_flags(%#x)", sync_flags);
+}
+
+static void shader_dump_uav_flags(struct wined3d_string_buffer *buffer, DWORD uav_flags)
+{
+ if (uav_flags & WINED3DSUF_GLOBALLY_COHERENT)
+ {
+ shader_addline(buffer, "_glc");
+ uav_flags &= ~WINED3DSUF_GLOBALLY_COHERENT;
+ }
+ if (uav_flags & WINED3DSUF_ORDER_PRESERVING_COUNTER)
+ {
+ shader_addline(buffer, "_opc");
+ uav_flags &= ~WINED3DSUF_ORDER_PRESERVING_COUNTER;
+ }
+
+ if (uav_flags)
+ shader_addline(buffer, "_unknown_flags(%#x)", uav_flags);
+}
+
+static void shader_dump_tessellator_domain(struct wined3d_string_buffer *buffer,
+ enum wined3d_tessellator_domain domain)
+{
+ switch (domain)
+ {
+ case WINED3D_TESSELLATOR_DOMAIN_LINE:
+ shader_addline(buffer, "line");
+ break;
+ case WINED3D_TESSELLATOR_DOMAIN_TRIANGLE:
+ shader_addline(buffer, "triangle");
+ break;
+ case WINED3D_TESSELLATOR_DOMAIN_QUAD:
+ shader_addline(buffer, "quad");
+ break;
+ default:
+ shader_addline(buffer, "unknown_tessellator_domain(%#x)", domain);
+ break;
+ }
+}
+
+static void shader_dump_tessellator_output_primitive(struct wined3d_string_buffer *buffer,
+ enum wined3d_tessellator_output_primitive output_primitive)
+{
+ switch (output_primitive)
+ {
+ case WINED3D_TESSELLATOR_OUTPUT_POINT:
+ shader_addline(buffer, "point");
+ break;
+ case WINED3D_TESSELLATOR_OUTPUT_LINE:
+ shader_addline(buffer, "line");
+ break;
+ case WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW:
+ shader_addline(buffer, "triangle_cw");
+ break;
+ case WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW:
+ shader_addline(buffer, "triangle_ccw");
+ break;
+ default:
+ shader_addline(buffer, "unknown_tessellator_output_primitive(%#x)", output_primitive);
+ break;
+ }
+}
+
+static void shader_dump_tessellator_partitioning(struct wined3d_string_buffer *buffer,
+ enum wined3d_tessellator_partitioning partitioning)
+{
+ switch (partitioning)
+ {
+ case WINED3D_TESSELLATOR_PARTITIONING_INTEGER:
+ shader_addline(buffer, "integer");
+ break;
+ case WINED3D_TESSELLATOR_PARTITIONING_POW2:
+ shader_addline(buffer, "pow2");
+ break;
+ case WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD:
+ shader_addline(buffer, "fractional_odd");
+ break;
+ case WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN:
+ shader_addline(buffer, "fractional_even");
+ break;
+ default:
+ shader_addline(buffer, "unknown_tessellator_partitioning(%#x)", partitioning);
+ break;
+ }
+}
+
+static void shader_dump_shader_input_sysval_semantic(struct wined3d_string_buffer *buffer,
+ enum wined3d_shader_input_sysval_semantic semantic)
{
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(sysval_semantic_names); ++i)
+ for (i = 0; i < ARRAY_SIZE(shader_input_sysval_semantic_names); ++i)
{
- if (sysval_semantic_names[i].sysval_semantic == semantic)
+ if (shader_input_sysval_semantic_names[i].sysval_semantic == semantic)
{
- shader_addline(buffer, "%s", sysval_semantic_names[i].sysval_name);
+ shader_addline(buffer, "%s", shader_input_sysval_semantic_names[i].sysval_name);
return;
}
}
- shader_addline(buffer, "unknown_sysval_semantic(%#x)", semantic);
+ shader_addline(buffer, "unknown_shader_input_sysval_semantic(%#x)", semantic);
}
static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer,
- const struct wined3d_shader_semantic *semantic, const struct wined3d_shader_version *shader_version)
+ const struct wined3d_shader_semantic *semantic, unsigned int flags,
+ const struct wined3d_shader_version *shader_version)
{
shader_addline(buffer, "dcl");
break;
}
}
- else if (semantic->reg.reg.type == WINED3DSPR_RESOURCE)
+ else if (semantic->reg.reg.type == WINED3DSPR_RESOURCE || semantic->reg.reg.type == WINED3DSPR_UAV)
{
- shader_addline(buffer, "_resource_");
+ if (semantic->reg.reg.type == WINED3DSPR_RESOURCE)
+ shader_addline(buffer, "_resource_");
+ else
+ shader_addline(buffer, "_uav_");
switch (semantic->resource_type)
{
case WINED3D_SHADER_RESOURCE_BUFFER:
shader_addline(buffer, "texture2dmsarray");
break;
+ case WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY:
+ shader_addline(buffer, "texturecubearray");
+ break;
+
default:
shader_addline(buffer, "unknown");
break;
}
+ if (semantic->reg.reg.type == WINED3DSPR_UAV)
+ shader_dump_uav_flags(buffer, flags);
switch (semantic->resource_data_type)
{
case WINED3D_DATA_FLOAT:
default:
shader_addline(buffer, "<unknown_semantic(%#x)>", semantic->usage);
- FIXME("unknown_semantics(0x%08x)", semantic->usage);
+ FIXME("Unrecognised semantic usage %#x.\n", semantic->usage);
}
}
}
shader_addline(buffer, "t");
break;
- default:
- shader_addline(buffer, "<unhandled_rtype(%#x)>", reg->type);
+ case WINED3DSPR_UAV:
+ shader_addline(buffer, "u");
break;
- }
- if (reg->type == WINED3DSPR_IMMCONST)
- {
- shader_addline(buffer, "(");
- switch (reg->immconst_type)
- {
- case WINED3D_IMMCONST_SCALAR:
- switch (reg->data_type)
- {
- case WINED3D_DATA_FLOAT:
- shader_addline(buffer, "%.8e", *(const float *)reg->immconst_data);
+ case WINED3DSPR_OUTPOINTID:
+ shader_addline(buffer, "vOutputControlPointID");
+ break;
+
+ case WINED3DSPR_FORKINSTID:
+ shader_addline(buffer, "vForkInstanceId");
+ break;
+
+ case WINED3DSPR_JOININSTID:
+ shader_addline(buffer, "vJoinInstanceId");
+ break;
+
+ case WINED3DSPR_INCONTROLPOINT:
+ shader_addline(buffer, "vicp");
+ break;
+
+ case WINED3DSPR_OUTCONTROLPOINT:
+ shader_addline(buffer, "vocp");
+ break;
+
+ case WINED3DSPR_PATCHCONST:
+ shader_addline(buffer, "vpc");
+ break;
+
+ case WINED3DSPR_TESSCOORD:
+ shader_addline(buffer, "vDomainLocation");
+ break;
+
+ case WINED3DSPR_GROUPSHAREDMEM:
+ shader_addline(buffer, "g");
+ break;
+
+ case WINED3DSPR_THREADID:
+ shader_addline(buffer, "vThreadID");
+ break;
+
+ case WINED3DSPR_THREADGROUPID:
+ shader_addline(buffer, "vThreadGroupID");
+ break;
+
+ case WINED3DSPR_LOCALTHREADID:
+ shader_addline(buffer, "vThreadIDInGroup");
+ break;
+
+ case WINED3DSPR_LOCALTHREADINDEX:
+ shader_addline(buffer, "vThreadIDInGroupFlattened");
+ break;
+
+ case WINED3DSPR_IDXTEMP:
+ shader_addline(buffer, "x");
+ break;
+
+ case WINED3DSPR_STREAM:
+ shader_addline(buffer, "m");
+ break;
+
+ case WINED3DSPR_FUNCTIONBODY:
+ shader_addline(buffer, "fb");
+ break;
+
+ case WINED3DSPR_FUNCTIONPOINTER:
+ shader_addline(buffer, "fp");
+ break;
+
+ case WINED3DSPR_COVERAGE:
+ shader_addline(buffer, "vCoverage");
+ break;
+
+ case WINED3DSPR_SAMPLEMASK:
+ shader_addline(buffer, "oMask");
+ break;
+
+ case WINED3DSPR_GSINSTID:
+ shader_addline(buffer, "vGSInstanceID");
+ break;
+
+ default:
+ shader_addline(buffer, "<unhandled_rtype(%#x)>", reg->type);
+ break;
+ }
+
+ if (reg->type == WINED3DSPR_IMMCONST)
+ {
+ shader_addline(buffer, "(");
+ switch (reg->immconst_type)
+ {
+ case WINED3D_IMMCONST_SCALAR:
+ switch (reg->data_type)
+ {
+ case WINED3D_DATA_FLOAT:
+ shader_addline(buffer, "%.8e", *(const float *)reg->u.immconst_data);
break;
case WINED3D_DATA_INT:
- shader_addline(buffer, "%d", reg->immconst_data[0]);
+ shader_addline(buffer, "%d", reg->u.immconst_data[0]);
break;
case WINED3D_DATA_RESOURCE:
case WINED3D_DATA_SAMPLER:
case WINED3D_DATA_UINT:
- shader_addline(buffer, "%u", reg->immconst_data[0]);
+ shader_addline(buffer, "%u", reg->u.immconst_data[0]);
break;
default:
shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
{
case WINED3D_DATA_FLOAT:
shader_addline(buffer, "%.8e, %.8e, %.8e, %.8e",
- *(const float *)®->immconst_data[0], *(const float *)®->immconst_data[1],
- *(const float *)®->immconst_data[2], *(const float *)®->immconst_data[3]);
+ *(const float *)®->u.immconst_data[0], *(const float *)®->u.immconst_data[1],
+ *(const float *)®->u.immconst_data[2], *(const float *)®->u.immconst_data[3]);
break;
case WINED3D_DATA_INT:
shader_addline(buffer, "%d, %d, %d, %d",
- reg->immconst_data[0], reg->immconst_data[1],
- reg->immconst_data[2], reg->immconst_data[3]);
+ reg->u.immconst_data[0], reg->u.immconst_data[1],
+ reg->u.immconst_data[2], reg->u.immconst_data[3]);
break;
case WINED3D_DATA_RESOURCE:
case WINED3D_DATA_SAMPLER:
case WINED3D_DATA_UINT:
shader_addline(buffer, "%u, %u, %u, %u",
- reg->immconst_data[0], reg->immconst_data[1],
- reg->immconst_data[2], reg->immconst_data[3]);
+ reg->u.immconst_data[0], reg->u.immconst_data[1],
+ reg->u.immconst_data[2], reg->u.immconst_data[3]);
break;
default:
shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
shader_addline(buffer, "%u]", reg->idx[1].offset);
}
}
+
+ if (reg->type == WINED3DSPR_FUNCTIONPOINTER)
+ shader_addline(buffer, "[%u]", reg->u.fp_body_idx);
}
}
}
}
-/* Shared code in order to generate the bulk of the shader string.
- * NOTE: A description of how to parse tokens can be found on MSDN. */
-void shader_generate_main(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer,
- const struct wined3d_shader_reg_maps *reg_maps, const DWORD *byte_code, void *backend_ctx)
+/* Shared code in order to generate the bulk of the shader string. */
+HRESULT shader_generate_code(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer,
+ const struct wined3d_shader_reg_maps *reg_maps, void *backend_ctx,
+ const DWORD *start, const DWORD *end)
{
struct wined3d_device *device = shader->device;
const struct wined3d_shader_frontend *fe = shader->frontend;
void *fe_data = shader->frontend_data;
struct wined3d_shader_version shader_version;
- struct wined3d_shader_loop_state loop_state;
+ struct wined3d_shader_parser_state state;
struct wined3d_shader_instruction ins;
struct wined3d_shader_tex_mx tex_mx;
struct wined3d_shader_context ctx;
- const DWORD *ptr = byte_code;
+ const DWORD *ptr;
/* Initialize current parsing state. */
tex_mx.current_row = 0;
- loop_state.current_depth = 0;
- loop_state.current_reg = 0;
+ state.current_loop_depth = 0;
+ state.current_loop_reg = 0;
+ state.in_subroutine = FALSE;
ctx.shader = shader;
ctx.gl_info = &device->adapter->gl_info;
ctx.reg_maps = reg_maps;
ctx.buffer = buffer;
ctx.tex_mx = &tex_mx;
- ctx.loop_state = &loop_state;
+ ctx.state = &state;
ctx.backend_data = backend_ctx;
ins.ctx = &ctx;
fe->shader_read_header(fe_data, &ptr, &shader_version);
+ if (start)
+ ptr = start;
- while (!fe->shader_is_end(fe_data, &ptr))
+ while (!fe->shader_is_end(fe_data, &ptr) && ptr != end)
{
/* Read opcode. */
fe->shader_read_instruction(fe_data, &ptr, &ins);
/* Unknown opcode and its parameters. */
if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
{
- TRACE("Skipping unrecognized instruction.\n");
- continue;
+ WARN("Encountered unrecognised or invalid instruction.\n");
+ return WINED3DERR_INVALIDCALL;
}
if (ins.predicate)
/* Call appropriate function for output target */
device->shader_backend->shader_handle_instruction(&ins);
}
+
+ return WINED3D_OK;
}
static void shader_dump_ins_modifiers(struct wined3d_string_buffer *buffer,
if (mmask & WINED3DSPDM_MSAMPCENTROID) shader_addline(buffer, "_centroid");
mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID);
- if (mmask) FIXME("_unrecognized_modifier(%#x)", mmask);
+ if (mmask) FIXME("Unrecognised modifier %#x.\n", mmask);
}
static void shader_dump_primitive_type(struct wined3d_string_buffer *buffer,
- enum wined3d_primitive_type primitive_type)
+ const struct wined3d_shader_primitive_type *primitive_type)
{
- switch (primitive_type)
+ switch (primitive_type->type)
{
case WINED3D_PT_UNDEFINED:
shader_addline(buffer, "undefined");
case WINED3D_PT_TRIANGLESTRIP_ADJ:
shader_addline(buffer, "trianglestrip_adj");
break;
+ case WINED3D_PT_PATCH:
+ shader_addline(buffer, "patch%u", primitive_type->patch_vertex_count);
+ break;
default:
- shader_addline(buffer, "<unrecognized_primitive_type %#x>", primitive_type);
+ shader_addline(buffer, "<unrecognized_primitive_type %#x>", primitive_type->type);
break;
}
}
}
}
-static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *byte_code)
+static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data)
{
struct wined3d_shader_version shader_version;
struct wined3d_string_buffer buffer;
- const DWORD *ptr = byte_code;
const char *type_prefix;
const char *p, *q;
+ const DWORD *ptr;
DWORD i;
if (!string_buffer_init(&buffer))
return;
}
- TRACE("Parsing %p.\n", byte_code);
-
fe->shader_read_header(fe_data, &ptr, &shader_version);
+ TRACE("Parsing %p.\n", ptr);
+
switch (shader_version.type)
{
case WINED3D_SHADER_TYPE_VERTEX:
type_prefix = "vs";
break;
+ case WINED3D_SHADER_TYPE_HULL:
+ type_prefix = "hs";
+ break;
+
+ case WINED3D_SHADER_TYPE_DOMAIN:
+ type_prefix = "ds";
+ break;
+
case WINED3D_SHADER_TYPE_GEOMETRY:
type_prefix = "gs";
break;
type_prefix = "ps";
break;
+ case WINED3D_SHADER_TYPE_COMPUTE:
+ type_prefix = "cs";
+ break;
+
default:
FIXME("Unhandled shader type %#x.\n", shader_version.type);
type_prefix = "unknown";
continue;
}
- if (ins.handler_idx == WINED3DSIH_DCL)
+ if (ins.handler_idx == WINED3DSIH_DCL || ins.handler_idx == WINED3DSIH_DCL_UAV_TYPED)
{
- shader_dump_decl_usage(&buffer, &ins.declaration.semantic, &shader_version);
+ shader_dump_decl_usage(&buffer, &ins.declaration.semantic, ins.flags, &shader_version);
shader_dump_ins_modifiers(&buffer, &ins.declaration.semantic.reg);
shader_addline(&buffer, " ");
shader_dump_dst_param(&buffer, &ins.declaration.semantic.reg, &shader_version);
shader_addline(&buffer, ", %s",
ins.flags & WINED3DSI_INDEXED_DYNAMIC ? "dynamicIndexed" : "immediateIndexed");
}
+ else if (ins.handler_idx == WINED3DSIH_DCL_FUNCTION_BODY)
+ {
+ shader_addline(&buffer, "%s fb%u",
+ shader_opcode_names[ins.handler_idx], ins.declaration.index);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_FUNCTION_TABLE)
+ {
+ shader_addline(&buffer, "%s ft%u = {...}",
+ shader_opcode_names[ins.handler_idx], ins.declaration.index);
+ }
else if (ins.handler_idx == WINED3DSIH_DCL_GLOBAL_FLAGS)
{
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
shader_dump_global_flags(&buffer, ins.flags);
}
+ else if (ins.handler_idx == WINED3DSIH_DCL_HS_MAX_TESSFACTOR)
+ {
+ shader_addline(&buffer, "%s %.8e", shader_opcode_names[ins.handler_idx],
+ ins.declaration.max_tessellation_factor);
+ }
else if (ins.handler_idx == WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER)
{
shader_addline(&buffer, "%s {\n", shader_opcode_names[ins.handler_idx]);
- for (i = 0; i < ins.declaration.icb->element_count / 4; ++i)
+ for (i = 0; i < ins.declaration.icb->vec4_count; ++i)
{
shader_addline(&buffer, " {0x%08x, 0x%08x, 0x%08x, 0x%08x},\n",
ins.declaration.icb->data[4 * i + 0],
}
shader_addline(&buffer, "}");
}
+ else if (ins.handler_idx == WINED3DSIH_DCL_INDEX_RANGE)
+ {
+ shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
+ shader_dump_dst_param(&buffer, &ins.declaration.index_range.first_register, &shader_version);
+ shader_addline(&buffer, " %u", ins.declaration.index_range.last_register);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_INDEXABLE_TEMP)
+ {
+ shader_addline(&buffer, "%s x[%u][%u], %u", shader_opcode_names[ins.handler_idx],
+ ins.declaration.indexable_temp.register_idx,
+ ins.declaration.indexable_temp.register_size,
+ ins.declaration.indexable_temp.component_count);
+ }
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PS)
{
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
shader_dump_dst_param(&buffer, &ins.declaration.register_semantic.reg, &shader_version);
shader_addline(&buffer, ", ");
- shader_dump_sysval_semantic(&buffer, ins.declaration.register_semantic.sysval_semantic);
+ shader_dump_shader_input_sysval_semantic(&buffer, ins.declaration.register_semantic.sysval_semantic);
}
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PS_SIV)
{
shader_addline(&buffer, " ");
shader_dump_dst_param(&buffer, &ins.declaration.register_semantic.reg, &shader_version);
shader_addline(&buffer, ", ");
- shader_dump_sysval_semantic(&buffer, ins.declaration.register_semantic.sysval_semantic);
+ shader_dump_shader_input_sysval_semantic(&buffer, ins.declaration.register_semantic.sysval_semantic);
}
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT
|| ins.handler_idx == WINED3DSIH_DCL_OUTPUT)
|| ins.handler_idx == WINED3DSIH_DCL_OUTPUT_TOPOLOGY)
{
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
- shader_dump_primitive_type(&buffer, ins.declaration.primitive_type);
+ shader_dump_primitive_type(&buffer, &ins.declaration.primitive_type);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_INTERFACE)
+ {
+ shader_addline(&buffer, "%s fp[%u][%u][%u] = {...}",
+ shader_opcode_names[ins.handler_idx], ins.declaration.fp.index,
+ ins.declaration.fp.array_size, ins.declaration.fp.body_count);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_RESOURCE_RAW)
+ {
+ shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
+ shader_dump_dst_param(&buffer, &ins.declaration.dst, &shader_version);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_RESOURCE_STRUCTURED)
+ {
+ shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
+ shader_dump_dst_param(&buffer, &ins.declaration.structured_resource.reg, &shader_version);
+ shader_addline(&buffer, ", %u", ins.declaration.structured_resource.byte_stride);
}
else if (ins.handler_idx == WINED3DSIH_DCL_SAMPLER)
{
shader_addline(&buffer, ", comparisonMode");
}
else if (ins.handler_idx == WINED3DSIH_DCL_TEMPS
+ || ins.handler_idx == WINED3DSIH_DCL_GS_INSTANCES
+ || ins.handler_idx == WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
+ || ins.handler_idx == WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT
+ || ins.handler_idx == WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT
+ || ins.handler_idx == WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT
|| ins.handler_idx == WINED3DSIH_DCL_VERTICES_OUT)
{
shader_addline(&buffer, "%s %u", shader_opcode_names[ins.handler_idx], ins.declaration.count);
}
+ else if (ins.handler_idx == WINED3DSIH_DCL_TESSELLATOR_DOMAIN)
+ {
+ shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
+ shader_dump_tessellator_domain(&buffer, ins.declaration.tessellator_domain);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE)
+ {
+ shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
+ shader_dump_tessellator_output_primitive(&buffer, ins.declaration.tessellator_output_primitive);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_TESSELLATOR_PARTITIONING)
+ {
+ shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
+ shader_dump_tessellator_partitioning(&buffer, ins.declaration.tessellator_partitioning);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_TGSM_RAW)
+ {
+ shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
+ shader_dump_dst_param(&buffer, &ins.declaration.tgsm_raw.reg, &shader_version);
+ shader_addline(&buffer, ", %u", ins.declaration.tgsm_raw.byte_count);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_TGSM_STRUCTURED)
+ {
+ shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
+ shader_dump_dst_param(&buffer, &ins.declaration.tgsm_structured.reg, &shader_version);
+ shader_addline(&buffer, ", %u, %u", ins.declaration.tgsm_structured.byte_stride,
+ ins.declaration.tgsm_structured.structure_count);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_THREAD_GROUP)
+ {
+ shader_addline(&buffer, "%s %u, %u, %u", shader_opcode_names[ins.handler_idx],
+ ins.declaration.thread_group_size.x,
+ ins.declaration.thread_group_size.y,
+ ins.declaration.thread_group_size.z);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_UAV_RAW)
+ {
+ shader_addline(&buffer, "%s", shader_opcode_names[ins.handler_idx]);
+ shader_dump_uav_flags(&buffer, ins.flags);
+ shader_addline(&buffer, " ");
+ shader_dump_dst_param(&buffer, &ins.declaration.dst, &shader_version);
+ }
+ else if (ins.handler_idx == WINED3DSIH_DCL_UAV_STRUCTURED)
+ {
+ shader_addline(&buffer, "%s", shader_opcode_names[ins.handler_idx]);
+ shader_dump_uav_flags(&buffer, ins.flags);
+ shader_addline(&buffer, " ");
+ shader_dump_dst_param(&buffer, &ins.declaration.structured_resource.reg, &shader_version);
+ shader_addline(&buffer, ", %u", ins.declaration.structured_resource.byte_stride);
+ }
else if (ins.handler_idx == WINED3DSIH_DEF)
{
shader_addline(&buffer, "def c%u = %.8e, %.8e, %.8e, %.8e", shader_get_float_offset(ins.dst[0].reg.type,
ins.dst[0].reg.idx[0].offset),
- *(const float *)&ins.src[0].reg.immconst_data[0],
- *(const float *)&ins.src[0].reg.immconst_data[1],
- *(const float *)&ins.src[0].reg.immconst_data[2],
- *(const float *)&ins.src[0].reg.immconst_data[3]);
+ *(const float *)&ins.src[0].reg.u.immconst_data[0],
+ *(const float *)&ins.src[0].reg.u.immconst_data[1],
+ *(const float *)&ins.src[0].reg.u.immconst_data[2],
+ *(const float *)&ins.src[0].reg.u.immconst_data[3]);
}
else if (ins.handler_idx == WINED3DSIH_DEFI)
{
shader_addline(&buffer, "defi i%u = %d, %d, %d, %d", ins.dst[0].reg.idx[0].offset,
- ins.src[0].reg.immconst_data[0],
- ins.src[0].reg.immconst_data[1],
- ins.src[0].reg.immconst_data[2],
- ins.src[0].reg.immconst_data[3]);
+ ins.src[0].reg.u.immconst_data[0],
+ ins.src[0].reg.u.immconst_data[1],
+ ins.src[0].reg.u.immconst_data[2],
+ ins.src[0].reg.u.immconst_data[3]);
}
else if (ins.handler_idx == WINED3DSIH_DEFB)
{
shader_addline(&buffer, "defb b%u = %s",
- ins.dst[0].reg.idx[0].offset, ins.src[0].reg.immconst_data[0] ? "true" : "false");
+ ins.dst[0].reg.idx[0].offset, ins.src[0].reg.u.immconst_data[0] ? "true" : "false");
}
else
{
shader_addline(&buffer, "%s", shader_opcode_names[ins.handler_idx]);
- if (ins.handler_idx == WINED3DSIH_IFC
+ if (ins.handler_idx == WINED3DSIH_BREAKP
+ || ins.handler_idx == WINED3DSIH_CONTINUEP
+ || ins.handler_idx == WINED3DSIH_IF
+ || ins.handler_idx == WINED3DSIH_RETP)
+ {
+ switch (ins.flags)
+ {
+ case WINED3D_SHADER_CONDITIONAL_OP_NZ: shader_addline(&buffer, "_nz"); break;
+ case WINED3D_SHADER_CONDITIONAL_OP_Z: shader_addline(&buffer, "_z"); break;
+ default: shader_addline(&buffer, "_unrecognized(%#x)", ins.flags); break;
+ }
+ }
+ else if (ins.handler_idx == WINED3DSIH_IFC
|| ins.handler_idx == WINED3DSIH_BREAKC)
{
switch (ins.flags)
{
shader_addline(&buffer, "p");
}
- else if (ins.handler_idx == WINED3DSIH_RESINFO
- && ins.flags)
+ else if (ins.handler_idx == WINED3DSIH_RESINFO && ins.flags)
{
switch (ins.flags)
{
default: shader_addline(&buffer, "_unrecognized(%#x)", ins.flags);
}
}
+ else if (ins.handler_idx == WINED3DSIH_SAMPLE_INFO && ins.flags)
+ {
+ switch (ins.flags)
+ {
+ case WINED3DSI_SAMPLE_INFO_UINT: shader_addline(&buffer, "_uint"); break;
+ default: shader_addline(&buffer, "_unrecognized(%#x)", ins.flags);
+ }
+ }
+ else if (ins.handler_idx == WINED3DSIH_SYNC)
+ {
+ shader_dump_sync_flags(&buffer, ins.flags);
+ }
+
+ if (wined3d_shader_instruction_has_texel_offset(&ins))
+ shader_addline(&buffer, "(%d,%d,%d)", ins.texel_offset.u, ins.texel_offset.v, ins.texel_offset.w);
for (i = 0; i < ins.dst_count; ++i)
{
string_buffer_free(&buffer);
}
-#if defined(STAGING_CSMT)
-void shader_cleanup(struct wined3d_shader *shader)
-#else /* STAGING_CSMT */
static void shader_cleanup(struct wined3d_shader *shader)
-#endif /* STAGING_CSMT */
{
+ if (shader->reg_maps.shader_version.type == WINED3D_SHADER_TYPE_HULL)
+ {
+ HeapFree(GetProcessHeap(), 0, shader->u.hs.phases.control_point);
+ HeapFree(GetProcessHeap(), 0, shader->u.hs.phases.fork);
+ HeapFree(GetProcessHeap(), 0, shader->u.hs.phases.join);
+ }
+ else if (shader->reg_maps.shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
+ {
+ HeapFree(GetProcessHeap(), 0, shader->u.gs.so_desc.elements);
+ }
+
+ HeapFree(GetProcessHeap(), 0, shader->patch_constant_signature.elements);
HeapFree(GetProcessHeap(), 0, shader->output_signature.elements);
HeapFree(GetProcessHeap(), 0, shader->input_signature.elements);
HeapFree(GetProcessHeap(), 0, shader->signature_strings);
shader->device->shader_backend->shader_destroy(shader);
- HeapFree(GetProcessHeap(), 0, shader->reg_maps.constf);
- HeapFree(GetProcessHeap(), 0, shader->reg_maps.sampler_map.entries);
+ shader_cleanup_reg_maps(&shader->reg_maps);
HeapFree(GetProcessHeap(), 0, shader->function);
shader_delete_constant_list(&shader->constantsF);
shader_delete_constant_list(&shader->constantsB);
};
static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {}
-static void shader_none_select_depth_blt(void *shader_priv, const struct wined3d_gl_info *gl_info,
- enum wined3d_gl_resource_type tex_type, const SIZE *ds_mask_size) {}
-static void shader_none_deselect_depth_blt(void *shader_priv, const struct wined3d_gl_info *gl_info) {}
+static void shader_none_precompile(void *shader_priv, struct wined3d_shader *shader) {}
+static void shader_none_select_compute(void *shader_priv, struct wined3d_context *context,
+ const struct wined3d_state *state) {}
static void shader_none_update_float_vertex_constants(struct wined3d_device *device, UINT start, UINT count) {}
static void shader_none_update_float_pixel_constants(struct wined3d_device *device, UINT start, UINT count) {}
static void shader_none_load_constants(void *shader_priv, struct wined3d_context *context,
context->shader_update_mask = (1u << WINED3D_SHADER_TYPE_PIXEL)
| (1u << WINED3D_SHADER_TYPE_VERTEX)
- | (1u << WINED3D_SHADER_TYPE_GEOMETRY);
+ | (1u << WINED3D_SHADER_TYPE_GEOMETRY)
+ | (1u << WINED3D_SHADER_TYPE_HULL)
+ | (1u << WINED3D_SHADER_TYPE_DOMAIN)
+ | (1u << WINED3D_SHADER_TYPE_COMPUTE);
}
static HRESULT shader_none_alloc(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
{
/* Set the shader caps to 0 for the none shader backend */
caps->vs_version = 0;
+ caps->hs_version = 0;
+ caps->ds_version = 0;
caps->gs_version = 0;
caps->ps_version = 0;
+ caps->cs_version = 0;
caps->vs_uniform_count = 0;
caps->ps_uniform_count = 0;
caps->ps_1x_max_value = 0.0f;
const struct wined3d_shader_backend_ops none_shader_backend =
{
shader_none_handle_instruction,
+ shader_none_precompile,
shader_none_select,
+ shader_none_select_compute,
shader_none_disable,
- shader_none_select_depth_blt,
- shader_none_deselect_depth_blt,
shader_none_update_float_vertex_constants,
shader_none_update_float_pixel_constants,
shader_none_load_constants,
shader_none_has_ffp_proj_control,
};
-static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *byte_code,
- const struct wined3d_shader_signature *output_signature, DWORD float_const_count,
+static HRESULT shader_set_function(struct wined3d_shader *shader, DWORD float_const_count,
enum wined3d_shader_type type, unsigned int max_version)
{
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
unsigned int backend_version;
const struct wined3d_d3d_info *d3d_info = &shader->device->adapter->d3d_info;
- TRACE("shader %p, byte_code %p, output_signature %p, float_const_count %u, type %#x, max_version %u.\n",
- shader, byte_code, output_signature, float_const_count, type, max_version);
+ TRACE("shader %p, float_const_count %u, type %#x, max_version %u.\n",
+ shader, float_const_count, type, max_version);
- list_init(&shader->constantsF);
- list_init(&shader->constantsB);
- list_init(&shader->constantsI);
- shader->lconst_inf_or_nan = FALSE;
-
- fe = shader_select_frontend(*byte_code);
- if (!fe)
- {
- FIXME("Unable to find frontend for shader.\n");
- return WINED3DERR_INVALIDCALL;
- }
- shader->frontend = fe;
- shader->frontend_data = fe->shader_init(byte_code, output_signature);
- if (!shader->frontend_data)
+ fe = shader->frontend;
+ if (!(shader->frontend_data = fe->shader_init(shader->function,
+ shader->functionLength, &shader->output_signature)))
{
FIXME("Failed to initialize frontend.\n");
return WINED3DERR_INVALIDCALL;
/* First pass: trace shader. */
if (TRACE_ON(d3d_shader))
- shader_trace_init(fe, shader->frontend_data, byte_code);
+ shader_trace_init(fe, shader->frontend_data);
/* Second pass: figure out which registers are used, what the semantics are, etc. */
if (FAILED(hr = shader_get_registers_used(shader, fe, reg_maps, &shader->input_signature,
- &shader->output_signature, byte_code, float_const_count)))
+ &shader->output_signature, float_const_count)))
return hr;
if (reg_maps->shader_version.type != type)
case WINED3D_SHADER_TYPE_VERTEX:
backend_version = d3d_info->limits.vs_version;
break;
+ case WINED3D_SHADER_TYPE_HULL:
+ backend_version = d3d_info->limits.hs_version;
+ break;
+ case WINED3D_SHADER_TYPE_DOMAIN:
+ backend_version = d3d_info->limits.ds_version;
+ break;
case WINED3D_SHADER_TYPE_GEOMETRY:
backend_version = d3d_info->limits.gs_version;
break;
case WINED3D_SHADER_TYPE_PIXEL:
backend_version = d3d_info->limits.ps_version;
break;
+ case WINED3D_SHADER_TYPE_COMPUTE:
+ backend_version = d3d_info->limits.cs_version;
+ break;
default:
- FIXME("No backend version-checking for this shader type\n");
+ FIXME("No backend version-checking for this shader type.\n");
backend_version = 0;
}
if (reg_maps->shader_version.major > backend_version)
return WINED3DERR_INVALIDCALL;
}
- shader->function = HeapAlloc(GetProcessHeap(), 0, shader->functionLength);
- if (!shader->function)
- return E_OUTOFMEMORY;
- memcpy(shader->function, byte_code, shader->functionLength);
-
return WINED3D_OK;
}
return refcount;
}
+static void wined3d_shader_init_object(void *object)
+{
+ struct wined3d_shader *shader = object;
+ struct wined3d_device *device = shader->device;
+
+ list_add_head(&device->shaders, &shader->shader_list_entry);
+
+ device->shader_backend->shader_precompile(device->shader_priv, shader);
+}
+
+static void wined3d_shader_destroy_object(void *object)
+{
+ shader_cleanup(object);
+ HeapFree(GetProcessHeap(), 0, object);
+}
+
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
{
ULONG refcount = InterlockedDecrement(&shader->ref);
if (!refcount)
{
-#if defined(STAGING_CSMT)
- const struct wined3d_device *device = shader->device;
-
shader->parent_ops->wined3d_object_destroyed(shader->parent);
- wined3d_cs_emit_shader_cleanup(device->cs, shader);
-#else /* STAGING_CSMT */
- shader_cleanup(shader);
- shader->parent_ops->wined3d_object_destroyed(shader->parent);
- HeapFree(GetProcessHeap(), 0, shader);
-#endif /* STAGING_CSMT */
+ wined3d_cs_destroy_object(shader->device->cs, wined3d_shader_destroy_object, shader);
}
return refcount;
&& state->render_states[WINED3D_RS_CLIPPLANEENABLE];
args->point_size = state->gl_primitive_type == GL_POINTS;
args->per_vertex_point_size = shader->reg_maps.point_size;
+ args->next_shader_type = state->shader[WINED3D_SHADER_TYPE_HULL] ? WINED3D_SHADER_TYPE_HULL
+ : state->shader[WINED3D_SHADER_TYPE_GEOMETRY] ? WINED3D_SHADER_TYPE_GEOMETRY
+ : WINED3D_SHADER_TYPE_PIXEL;
+ if (shader->reg_maps.shader_version.major >= 4)
+ args->next_shader_input_count = state->shader[WINED3D_SHADER_TYPE_HULL]
+ ? state->shader[WINED3D_SHADER_TYPE_HULL]->limits->packed_input
+ : state->shader[WINED3D_SHADER_TYPE_GEOMETRY]
+ ? state->shader[WINED3D_SHADER_TYPE_GEOMETRY]->limits->packed_input
+ : state->shader[WINED3D_SHADER_TYPE_PIXEL]
+ ? state->shader[WINED3D_SHADER_TYPE_PIXEL]->limits->packed_input : 0;
+ else
+ args->next_shader_input_count = 0;
args->swizzle_map = swizzle_map;
if (d3d_info->emulated_flatshading)
args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
else
- args->flatshading = FALSE;
+ args->flatshading = 0;
}
static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_idx2)
return FALSE;
}
+static HRESULT shader_signature_calculate_strings_length(const struct wined3d_shader_signature *signature,
+ SIZE_T *total)
+{
+ struct wined3d_shader_signature_element *e;
+ unsigned int i;
+ SIZE_T len;
+
+ for (i = 0; i < signature->element_count; ++i)
+ {
+ e = &signature->elements[i];
+ len = strlen(e->semantic_name);
+ if (len >= ~(SIZE_T)0 - *total)
+ return E_OUTOFMEMORY;
+
+ *total += len + 1;
+ }
+ return WINED3D_OK;
+}
+
static HRESULT shader_signature_copy(struct wined3d_shader_signature *dst,
const struct wined3d_shader_signature *src, char **signature_strings)
{
SIZE_T len;
char *ptr;
+ if (!src->element_count)
+ return WINED3D_OK;
+
ptr = *signature_strings;
dst->element_count = src->element_count;
- if (!(dst->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*dst->elements) * dst->element_count)))
+ if (!(dst->elements = wined3d_calloc(dst->element_count, sizeof(*dst->elements))))
return E_OUTOFMEMORY;
for (i = 0; i < src->element_count; ++i)
const struct wined3d_shader_desc *desc, DWORD float_const_count, enum wined3d_shader_type type,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
- struct wined3d_shader_signature_element *e;
- SIZE_T total, len;
- unsigned int i;
+ size_t byte_code_size;
+ SIZE_T total;
HRESULT hr;
char *ptr;
+ TRACE("byte_code %p, byte_code_size %#lx, format %#x, max_version %#x.\n",
+ desc->byte_code, (long)desc->byte_code_size, desc->format, desc->max_version);
+
if (!desc->byte_code)
return WINED3DERR_INVALIDCALL;
+ if (!(shader->frontend = shader_select_frontend(desc->format)))
+ {
+ FIXME("Unable to find frontend for shader.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
shader->ref = 1;
shader->device = device;
shader->parent = parent;
shader->parent_ops = parent_ops;
total = 0;
- if (desc->input_signature)
- {
- for (i = 0; i < desc->input_signature->element_count; ++i)
- {
- e = &desc->input_signature->elements[i];
- len = strlen(e->semantic_name);
- if (len >= ~(SIZE_T)0 - total)
- return E_OUTOFMEMORY;
-
- total += len + 1;
- }
- }
- if (desc->output_signature)
- {
- for (i = 0; i < desc->output_signature->element_count; ++i)
- {
- e = &desc->output_signature->elements[i];
- len = strlen(e->semantic_name);
- if (len >= ~(SIZE_T)0 - total)
- return E_OUTOFMEMORY;
-
- total += len + 1;
- }
- }
- if (!(shader->signature_strings = HeapAlloc(GetProcessHeap(), 0, total)))
+ if (FAILED(hr = shader_signature_calculate_strings_length(&desc->input_signature, &total)))
+ return hr;
+ if (FAILED(hr = shader_signature_calculate_strings_length(&desc->output_signature, &total)))
+ return hr;
+ if (FAILED(hr = shader_signature_calculate_strings_length(&desc->patch_constant_signature, &total)))
+ return hr;
+ if (total && !(shader->signature_strings = HeapAlloc(GetProcessHeap(), 0, total)))
return E_OUTOFMEMORY;
ptr = shader->signature_strings;
- if (desc->input_signature && FAILED(hr = shader_signature_copy(&shader->input_signature,
- desc->input_signature, &ptr)))
+ if (FAILED(hr = shader_signature_copy(&shader->input_signature, &desc->input_signature, &ptr)))
{
HeapFree(GetProcessHeap(), 0, shader->signature_strings);
return hr;
}
- if (desc->output_signature && FAILED(hr = shader_signature_copy(&shader->output_signature,
- desc->output_signature, &ptr)))
+ if (FAILED(hr = shader_signature_copy(&shader->output_signature, &desc->output_signature, &ptr)))
{
HeapFree(GetProcessHeap(), 0, shader->input_signature.elements);
HeapFree(GetProcessHeap(), 0, shader->signature_strings);
return hr;
}
+ if (FAILED(hr = shader_signature_copy(&shader->patch_constant_signature, &desc->patch_constant_signature, &ptr)))
+ {
+ HeapFree(GetProcessHeap(), 0, shader->output_signature.elements);
+ HeapFree(GetProcessHeap(), 0, shader->input_signature.elements);
+ HeapFree(GetProcessHeap(), 0, shader->signature_strings);
+ return hr;
+ }
list_init(&shader->linked_programs);
- list_add_head(&device->shaders, &shader->shader_list_entry);
+ list_init(&shader->constantsF);
+ list_init(&shader->constantsB);
+ list_init(&shader->constantsI);
+ shader->lconst_inf_or_nan = FALSE;
+ list_init(&shader->reg_maps.indexable_temps);
+ list_init(&shader->shader_list_entry);
+
+ byte_code_size = desc->byte_code_size;
+ if (byte_code_size == ~(size_t)0)
+ {
+ const struct wined3d_shader_frontend *fe = shader->frontend;
+ struct wined3d_shader_version shader_version;
+ struct wined3d_shader_instruction ins;
+ const DWORD *ptr;
+ void *fe_data;
+
+ if (!(fe_data = fe->shader_init(desc->byte_code, byte_code_size, &shader->output_signature)))
+ {
+ WARN("Failed to initialise frontend data.\n");
+ shader_cleanup(shader);
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ fe->shader_read_header(fe_data, &ptr, &shader_version);
+ while (!fe->shader_is_end(fe_data, &ptr))
+ fe->shader_read_instruction(fe_data, &ptr, &ins);
+
+ fe->shader_free(fe_data);
- if (FAILED(hr = shader_set_function(shader, desc->byte_code, desc->output_signature,
- float_const_count, type, desc->max_version)))
+ byte_code_size = (ptr - desc->byte_code) * sizeof(*ptr);
+ }
+
+ if (!(shader->function = HeapAlloc(GetProcessHeap(), 0, byte_code_size)))
+ {
+ shader_cleanup(shader);
+ return E_OUTOFMEMORY;
+ }
+ memcpy(shader->function, desc->byte_code, byte_code_size);
+ shader->functionLength = byte_code_size;
+
+ if (FAILED(hr = shader_set_function(shader, float_const_count, type, desc->max_version)))
{
WARN("Failed to set function, hr %#x.\n", hr);
shader_cleanup(shader);
+ return hr;
}
+ shader->load_local_constsF = shader->lconst_inf_or_nan;
+
+ wined3d_cs_init_object(shader->device->cs, wined3d_shader_init_object, shader);
+
return hr;
}
-static HRESULT vertexshader_init(struct wined3d_shader *shader, struct wined3d_device *device,
+static HRESULT vertex_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
{
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
shader->u.vs.attributes[input->register_idx].usage_idx = input->semantic_idx;
}
- shader->load_local_constsF = (reg_maps->usesrelconstF && !list_empty(&shader->constantsF)) ||
- shader->lconst_inf_or_nan;
+ if (reg_maps->usesrelconstF && !list_empty(&shader->constantsF))
+ shader->load_local_constsF = TRUE;
return WINED3D_OK;
}
-static HRESULT geometryshader_init(struct wined3d_shader *shader, struct wined3d_device *device,
+static HRESULT domain_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
{
+ return shader_init(shader, device, desc, 0, WINED3D_SHADER_TYPE_DOMAIN, parent, parent_ops);
+}
+
+static HRESULT hull_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
+ const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
+{
+ return shader_init(shader, device, desc, 0, WINED3D_SHADER_TYPE_HULL, parent, parent_ops);
+}
+
+static HRESULT geometry_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
+ const struct wined3d_shader_desc *desc, const struct wined3d_stream_output_desc *so_desc,
+ void *parent, const struct wined3d_parent_ops *parent_ops)
+{
+ struct wined3d_stream_output_element *elements = NULL;
HRESULT hr;
- if (FAILED(hr = shader_init(shader, device, desc, 0,
- WINED3D_SHADER_TYPE_GEOMETRY, parent, parent_ops)))
+ if (so_desc && !(elements = wined3d_calloc(so_desc->element_count, sizeof(*elements))))
+ return E_OUTOFMEMORY;
+
+ if (FAILED(hr = shader_init(shader, device, desc, 0, WINED3D_SHADER_TYPE_GEOMETRY, parent, parent_ops)))
+ {
+ HeapFree(GetProcessHeap(), 0, elements);
return hr;
+ }
- shader->load_local_constsF = shader->lconst_inf_or_nan;
+ if (so_desc)
+ {
+ shader->u.gs.so_desc = *so_desc;
+ shader->u.gs.so_desc.elements = elements;
+ memcpy(elements, so_desc->elements, so_desc->element_count * sizeof(*elements));
+ }
return WINED3D_OK;
}
+void find_ds_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
+ struct ds_compile_args *args, const struct wined3d_context *context)
+{
+ const struct wined3d_shader *hull_shader = state->shader[WINED3D_SHADER_TYPE_HULL];
+
+ args->tessellator_output_primitive = hull_shader->u.hs.tessellator_output_primitive;
+ args->tessellator_partitioning = hull_shader->u.hs.tessellator_partitioning;
+
+ args->output_count = state->shader[WINED3D_SHADER_TYPE_GEOMETRY] ?
+ state->shader[WINED3D_SHADER_TYPE_GEOMETRY]->limits->packed_input :
+ state->shader[WINED3D_SHADER_TYPE_PIXEL] ? state->shader[WINED3D_SHADER_TYPE_PIXEL]->limits->packed_input
+ : shader->limits->packed_output;
+ args->next_shader_type = state->shader[WINED3D_SHADER_TYPE_GEOMETRY] ? WINED3D_SHADER_TYPE_GEOMETRY
+ : WINED3D_SHADER_TYPE_PIXEL;
+
+ args->render_offscreen = context->render_offscreen;
+
+ args->padding = 0;
+}
+
+void find_gs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
+ struct gs_compile_args *args)
+{
+ args->output_count = state->shader[WINED3D_SHADER_TYPE_PIXEL]
+ ? state->shader[WINED3D_SHADER_TYPE_PIXEL]->limits->packed_input : shader->limits->packed_output;
+}
+
void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
BOOL position_transformed, struct ps_compile_args *args, const struct wined3d_context *context)
{
- const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
+ const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_texture *texture;
- UINT i;
+ unsigned int i;
memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */
-#if defined(STAGING_CSMT)
- if (!gl_info->supported[ARB_FRAMEBUFFER_SRGB] && needs_srgb_write(context, state, &state->fb))
-#else /* STAGING_CSMT */
if (!gl_info->supported[ARB_FRAMEBUFFER_SRGB] && needs_srgb_write(context, state, state->fb))
-#endif /* STAGING_CSMT */
{
static unsigned int warned = 0;
}
}
- for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
+ if (shader->reg_maps.shader_version.major >= 4)
{
- if (!shader->reg_maps.resource_info[i].type)
- continue;
-
- texture = state->textures[i];
- if (!texture)
- {
+ /* In SM4+ we use dcl_sampler in order to determine if we should use shadow sampler. */
+ args->shadow = 0;
+ for (i = 0 ; i < MAX_FRAGMENT_SAMPLERS; ++i)
args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
- continue;
- }
- args->color_fixup[i] = texture->resource.format->color_fixup;
+ args->np2_fixup = 0;
+ }
+ else
+ {
+ for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
+ {
+ if (!shader->reg_maps.resource_info[i].type)
+ continue;
+
+ texture = state->textures[i];
+ if (!texture)
+ {
+ args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
+ continue;
+ }
+ if (can_use_texture_swizzle(gl_info, texture->resource.format))
+ args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
+ else
+ args->color_fixup[i] = texture->resource.format->color_fixup;
- if (texture->resource.format_flags & WINED3DFMT_FLAG_SHADOW)
- args->shadow |= 1u << i;
+ if (texture->resource.format_flags & WINED3DFMT_FLAG_SHADOW)
+ args->shadow |= 1u << i;
- /* Flag samplers that need NP2 texcoord fixup. */
- if (!(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT))
- args->np2_fixup |= (1u << i);
+ /* Flag samplers that need NP2 texcoord fixup. */
+ if (!(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT))
+ args->np2_fixup |= (1u << i);
+ }
}
+
if (shader->reg_maps.shader_version.major >= 3)
{
if (position_transformed)
args->pointsprite = state->render_states[WINED3D_RS_POINTSPRITEENABLE]
&& state->gl_primitive_type == GL_POINTS;
+ if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
+ args->alpha_test_func = WINED3D_CMP_ALWAYS - 1;
+ else
+ args->alpha_test_func = (state->render_states[WINED3D_RS_ALPHATESTENABLE]
+ ? wined3d_sanitize_cmp_func(state->render_states[WINED3D_RS_ALPHAFUNC])
+ : WINED3D_CMP_ALWAYS) - 1;
+
if (d3d_info->emulated_flatshading)
args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
+
+ args->render_offscreen = shader->reg_maps.vpos && gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]
+ ? context->render_offscreen : 0;
}
-static HRESULT pixelshader_init(struct wined3d_shader *shader, struct wined3d_device *device,
+static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
for (i = 0; i < MAX_REG_INPUT; ++i)
{
- if (shader->u.ps.input_reg_used[i])
+ if (shader->u.ps.input_reg_used & (1u << i))
{
++num_regs_used;
highest_reg_used = i;
/* Don't do any register mapping magic if it is not needed, or if we can't
* achieve anything anyway */
if (highest_reg_used < (gl_info->limits.glsl_varyings / 4)
- || num_regs_used > (gl_info->limits.glsl_varyings / 4))
+ || num_regs_used > (gl_info->limits.glsl_varyings / 4)
+ || shader->reg_maps.shader_version.major >= 4)
{
if (num_regs_used > (gl_info->limits.glsl_varyings / 4))
{
shader->u.ps.declared_in_count = 0;
for (i = 0; i < MAX_REG_INPUT; ++i)
{
- if (shader->u.ps.input_reg_used[i])
+ if (shader->u.ps.input_reg_used & (1u << i))
shader->u.ps.input_reg_map[i] = shader->u.ps.declared_in_count++;
else shader->u.ps.input_reg_map[i] = ~0U;
}
}
- shader->load_local_constsF = shader->lconst_inf_or_nan;
-
return WINED3D_OK;
}
}
}
-HRESULT CDECL wined3d_shader_create_gs(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
+static HRESULT compute_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
+ const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
+{
+ return shader_init(shader, device, desc, 0, WINED3D_SHADER_TYPE_COMPUTE, parent, parent_ops);
+}
+
+HRESULT CDECL wined3d_shader_create_cs(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
{
struct wined3d_shader *object;
TRACE("device %p, desc %p, parent %p, parent_ops %p, shader %p.\n",
device, desc, parent, parent_ops, shader);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
+ return E_OUTOFMEMORY;
+
+ if (FAILED(hr = compute_shader_init(object, device, desc, parent, parent_ops)))
+ {
+ WARN("Failed to initialize compute shader, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created compute shader %p.\n", object);
+ *shader = object;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_shader_create_ds(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
+ void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
+{
+ struct wined3d_shader *object;
+ HRESULT hr;
+
+ TRACE("device %p, desc %p, parent %p, parent_ops %p, shader %p.\n",
+ device, desc, parent, parent_ops, shader);
+
+ if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
- if (FAILED(hr = geometryshader_init(object, device, desc, parent, parent_ops)))
+ if (FAILED(hr = domain_shader_init(object, device, desc, parent, parent_ops)))
+ {
+ WARN("Failed to initialize domain shader, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created domain shader %p.\n", object);
+ *shader = object;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_shader_create_gs(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
+ const struct wined3d_stream_output_desc *so_desc, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
+{
+ struct wined3d_shader *object;
+ HRESULT hr;
+
+ TRACE("device %p, desc %p, so_desc %p, parent %p, parent_ops %p, shader %p.\n",
+ device, desc, so_desc, parent, parent_ops, shader);
+
+ if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
+ return E_OUTOFMEMORY;
+
+ if (FAILED(hr = geometry_shader_init(object, device, desc, so_desc, parent, parent_ops)))
{
WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return WINED3D_OK;
}
+HRESULT CDECL wined3d_shader_create_hs(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
+ void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
+{
+ struct wined3d_shader *object;
+ HRESULT hr;
+
+ TRACE("device %p, desc %p, parent %p, parent_ops %p, shader %p.\n",
+ device, desc, parent, parent_ops, shader);
+
+ if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
+ return E_OUTOFMEMORY;
+
+ if (FAILED(hr = hull_shader_init(object, device, desc, parent, parent_ops)))
+ {
+ WARN("Failed to initialize hull shader, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created hull shader %p.\n", object);
+ *shader = object;
+
+ return WINED3D_OK;
+}
+
HRESULT CDECL wined3d_shader_create_ps(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
{
if (!object)
return E_OUTOFMEMORY;
- if (FAILED(hr = pixelshader_init(object, device, desc, parent, parent_ops)))
+ if (FAILED(hr = pixel_shader_init(object, device, desc, parent, parent_ops)))
{
WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
if (!object)
return E_OUTOFMEMORY;
- if (FAILED(hr = vertexshader_init(object, device, desc, parent, parent_ops)))
+ if (FAILED(hr = vertex_shader_init(object, device, desc, parent, parent_ops)))
{
WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);