2009-12-30 19:33:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2002-2003 Jason Edmeades
|
|
|
|
* Copyright 2002-2003 Raphael Junqueira
|
|
|
|
* Copyright 2004 Christian Costa
|
|
|
|
* Copyright 2005 Oliver Stieber
|
|
|
|
* Copyright 2006 Ivan Gyurdiev
|
2013-05-14 17:38:18 +02:00
|
|
|
* Copyright 2007-2008, 2013 Stefan Dösinger for CodeWeavers
|
2011-03-30 20:49:24 +02:00
|
|
|
* Copyright 2009-2011 Henri Verbeet for CodeWeavers
|
2009-12-30 19:33:39 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2012-06-01 16:56:21 +02:00
|
|
|
#include "wine/port.h"
|
2009-12-30 19:33:39 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2010-01-17 21:31:32 +01:00
|
|
|
#include <string.h>
|
2009-12-30 19:33:39 +01:00
|
|
|
|
|
|
|
#include "wined3d_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2013-09-05 10:42:12 +02:00
|
|
|
/* pow, mul_high, sub_high, mul_low */
|
|
|
|
const float wined3d_srgb_const0[] = {0.41666f, 1.055f, 0.055f, 12.92f};
|
|
|
|
/* cmp */
|
|
|
|
const float wined3d_srgb_const1[] = {0.0031308f, 0.0f, 0.0f, 0.0f};
|
|
|
|
|
2010-08-04 11:10:27 +02:00
|
|
|
static const char * const shader_opcode_names[] =
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_ABS */ "abs",
|
|
|
|
/* WINED3DSIH_ADD */ "add",
|
|
|
|
/* WINED3DSIH_AND */ "and",
|
2016-12-05 12:04:32 +01:00
|
|
|
/* WINED3DSIH_ATOMIC_AND */ "atomic_and",
|
2016-12-05 12:04:36 +01:00
|
|
|
/* WINED3DSIH_ATOMIC_CMP_STORE */ "atomic_cmp_store",
|
2016-11-23 14:36:08 +01:00
|
|
|
/* WINED3DSIH_ATOMIC_IADD */ "atomic_iadd",
|
2016-12-09 11:30:52 +01:00
|
|
|
/* WINED3DSIH_ATOMIC_IMAX */ "atomic_imax",
|
2016-12-09 11:30:53 +01:00
|
|
|
/* WINED3DSIH_ATOMIC_IMIN */ "atomic_imin",
|
2016-12-05 12:04:30 +01:00
|
|
|
/* WINED3DSIH_ATOMIC_OR */ "atomic_or",
|
2016-12-05 12:04:37 +01:00
|
|
|
/* WINED3DSIH_ATOMIC_UMAX */ "atomic_umax",
|
2016-12-05 12:04:38 +01:00
|
|
|
/* WINED3DSIH_ATOMIC_UMIN */ "atomic_umin",
|
2016-12-05 12:04:28 +01:00
|
|
|
/* WINED3DSIH_ATOMIC_XOR */ "atomic_xor",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_BEM */ "bem",
|
2016-06-13 10:39:34 +02:00
|
|
|
/* WINED3DSIH_BFI */ "bfi",
|
2016-07-07 12:22:33 +02:00
|
|
|
/* WINED3DSIH_BFREV */ "bfrev",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_BREAK */ "break",
|
|
|
|
/* WINED3DSIH_BREAKC */ "breakc",
|
|
|
|
/* WINED3DSIH_BREAKP */ "breakp",
|
2016-06-13 10:39:36 +02:00
|
|
|
/* WINED3DSIH_BUFINFO */ "bufinfo",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_CALL */ "call",
|
|
|
|
/* WINED3DSIH_CALLNZ */ "callnz",
|
2016-06-03 11:33:04 +02:00
|
|
|
/* WINED3DSIH_CASE */ "case",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_CMP */ "cmp",
|
|
|
|
/* WINED3DSIH_CND */ "cnd",
|
2016-07-05 11:46:53 +02:00
|
|
|
/* WINED3DSIH_CONTINUE */ "continue",
|
2017-05-14 18:54:34 +02:00
|
|
|
/* WINED3DSIH_CONTINUEP */ "continuec",
|
2017-01-28 17:14:10 +01:00
|
|
|
/* WINED3DSIH_COUNTBITS */ "countbits",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_CRS */ "crs",
|
|
|
|
/* WINED3DSIH_CUT */ "cut",
|
2016-07-05 11:46:51 +02:00
|
|
|
/* WINED3DSIH_CUT_STREAM */ "cut_stream",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_DCL */ "dcl",
|
|
|
|
/* WINED3DSIH_DCL_CONSTANT_BUFFER */ "dcl_constantBuffer",
|
2016-12-07 12:43:03 +01:00
|
|
|
/* WINED3DSIH_DCL_FUNCTION_BODY */ "dcl_function_body",
|
|
|
|
/* WINED3DSIH_DCL_FUNCTION_TABLE */ "dcl_function_table",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_DCL_GLOBAL_FLAGS */ "dcl_globalFlags",
|
2017-04-21 10:59:52 +02:00
|
|
|
/* WINED3DSIH_DCL_GS_INSTANCES */ "dcl_gs_instances",
|
2016-03-31 10:54:40 +02:00
|
|
|
/* WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT */ "dcl_hs_fork_phase_instance_count",
|
2017-03-02 15:11:47 +01:00
|
|
|
/* WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT */ "dcl_hs_join_phase_instance_count",
|
2016-03-31 10:54:42 +02:00
|
|
|
/* WINED3DSIH_DCL_HS_MAX_TESSFACTOR */ "dcl_hs_max_tessfactor",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER */ "dcl_immediateConstantBuffer",
|
2017-03-10 09:10:57 +01:00
|
|
|
/* WINED3DSIH_DCL_INDEX_RANGE */ "dcl_index_range",
|
2016-06-23 12:08:00 +02:00
|
|
|
/* WINED3DSIH_DCL_INDEXABLE_TEMP */ "dcl_indexableTemp",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* 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",
|
2016-12-07 12:43:03 +01:00
|
|
|
/* WINED3DSIH_DCL_INTERFACE */ "dcl_interface",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* 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",
|
2017-01-29 13:37:23 +01:00
|
|
|
/* WINED3DSIH_DCL_RESOURCE_RAW */ "dcl_resource_raw",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_DCL_RESOURCE_STRUCTURED */ "dcl_resource_structured",
|
|
|
|
/* WINED3DSIH_DCL_SAMPLER */ "dcl_sampler",
|
2016-07-04 12:26:29 +02:00
|
|
|
/* WINED3DSIH_DCL_STREAM */ "dcl_stream",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_DCL_TEMPS */ "dcl_temps",
|
2016-04-01 11:21:37 +02:00
|
|
|
/* WINED3DSIH_DCL_TESSELLATOR_DOMAIN */ "dcl_tessellator_domain",
|
2016-04-01 11:21:38 +02:00
|
|
|
/* WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE */ "dcl_tessellator_output_primitive",
|
2016-04-01 11:21:39 +02:00
|
|
|
/* WINED3DSIH_DCL_TESSELLATOR_PARTITIONING */ "dcl_tessellator_partitioning",
|
2016-06-22 11:37:30 +02:00
|
|
|
/* WINED3DSIH_DCL_TGSM_RAW */ "dcl_tgsm_raw",
|
2016-06-22 11:37:31 +02:00
|
|
|
/* WINED3DSIH_DCL_TGSM_STRUCTURED */ "dcl_tgsm_structured",
|
2016-06-21 13:10:02 +02:00
|
|
|
/* WINED3DSIH_DCL_THREAD_GROUP */ "dcl_thread_group",
|
2016-11-30 12:47:31 +01:00
|
|
|
/* WINED3DSIH_DCL_UAV_RAW */ "dcl_uav_raw",
|
2016-11-30 12:47:32 +01:00
|
|
|
/* WINED3DSIH_DCL_UAV_STRUCTURED */ "dcl_uav_structured",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_DCL_UAV_TYPED */ "dcl_uav_typed",
|
|
|
|
/* WINED3DSIH_DCL_VERTICES_OUT */ "dcl_maxOutputVertexCount",
|
|
|
|
/* WINED3DSIH_DEF */ "def",
|
2016-06-03 11:33:05 +02:00
|
|
|
/* WINED3DSIH_DEFAULT */ "default",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* 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",
|
2016-07-04 12:26:28 +02:00
|
|
|
/* WINED3DSIH_EMIT_STREAM */ "emit_stream",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_ENDIF */ "endif",
|
|
|
|
/* WINED3DSIH_ENDLOOP */ "endloop",
|
|
|
|
/* WINED3DSIH_ENDREP */ "endrep",
|
2016-06-03 11:33:06 +02:00
|
|
|
/* WINED3DSIH_ENDSWITCH */ "endswitch",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_EQ */ "eq",
|
2018-05-29 12:22:32 +02:00
|
|
|
/* WINED3DSIH_EVAL_SAMPLE_INDEX */ "eval_sample_index",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_EXP */ "exp",
|
|
|
|
/* WINED3DSIH_EXPP */ "expp",
|
2017-01-28 17:14:01 +01:00
|
|
|
/* WINED3DSIH_F16TOF32 */ "f16tof32",
|
2017-01-28 17:14:02 +01:00
|
|
|
/* WINED3DSIH_F32TOF16 */ "f32tof16",
|
2016-12-07 12:43:03 +01:00
|
|
|
/* WINED3DSIH_FCALL */ "fcall",
|
2017-01-28 17:14:11 +01:00
|
|
|
/* WINED3DSIH_FIRSTBIT_HI */ "firstbit_hi",
|
|
|
|
/* WINED3DSIH_FIRSTBIT_LO */ "firstbit_lo",
|
|
|
|
/* WINED3DSIH_FIRSTBIT_SHI */ "firstbit_shi",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_FRC */ "frc",
|
|
|
|
/* WINED3DSIH_FTOI */ "ftoi",
|
|
|
|
/* WINED3DSIH_FTOU */ "ftou",
|
2016-06-10 12:07:04 +02:00
|
|
|
/* WINED3DSIH_GATHER4 */ "gather4",
|
2016-06-10 12:07:05 +02:00
|
|
|
/* WINED3DSIH_GATHER4_C */ "gather4_c",
|
2017-04-11 13:30:34 +02:00
|
|
|
/* WINED3DSIH_GATHER4_PO */ "gather4_po",
|
2017-05-22 19:15:02 +02:00
|
|
|
/* WINED3DSIH_GATHER4_PO_C */ "gather4_po_c",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_GE */ "ge",
|
2016-04-04 11:26:34 +02:00
|
|
|
/* WINED3DSIH_HS_CONTROL_POINT_PHASE */ "hs_control_point_phase",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_HS_DECLS */ "hs_decls",
|
|
|
|
/* WINED3DSIH_HS_FORK_PHASE */ "hs_fork_phase",
|
2016-04-04 11:26:35 +02:00
|
|
|
/* WINED3DSIH_HS_JOIN_PHASE */ "hs_join_phase",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_IADD */ "iadd",
|
2017-04-04 12:35:53 +02:00
|
|
|
/* WINED3DSIH_IBFE */ "ibfe",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_IEQ */ "ieq",
|
|
|
|
/* WINED3DSIH_IF */ "if",
|
|
|
|
/* WINED3DSIH_IFC */ "ifc",
|
|
|
|
/* WINED3DSIH_IGE */ "ige",
|
|
|
|
/* WINED3DSIH_ILT */ "ilt",
|
|
|
|
/* WINED3DSIH_IMAD */ "imad",
|
|
|
|
/* WINED3DSIH_IMAX */ "imax",
|
|
|
|
/* WINED3DSIH_IMIN */ "imin",
|
2016-06-17 10:41:48 +02:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_ALLOC */ "imm_atomic_alloc",
|
2016-12-05 12:04:33 +01:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_AND */ "imm_atomic_and",
|
2016-12-05 12:04:35 +01:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_CMP_EXCH */ "imm_atomic_cmp_exch",
|
2016-06-13 10:39:33 +02:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_CONSUME */ "imm_atomic_consume",
|
2016-12-05 12:04:34 +01:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_EXCH */ "imm_atomic_exch",
|
2017-02-06 14:12:13 +01:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_IADD */ "imm_atomic_iadd",
|
2017-02-16 13:02:19 +01:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_IMAX */ "imm_atomic_imax",
|
2017-02-16 13:02:20 +01:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_IMIN */ "imm_atomic_imin",
|
2016-12-05 12:04:31 +01:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_OR */ "imm_atomic_or",
|
2016-12-05 12:04:39 +01:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_UMAX */ "imm_atomic_umax",
|
2016-12-05 12:04:40 +01:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_UMIN */ "imm_atomic_umin",
|
2016-12-05 12:04:29 +01:00
|
|
|
/* WINED3DSIH_IMM_ATOMIC_XOR */ "imm_atomic_xor",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_IMUL */ "imul",
|
|
|
|
/* WINED3DSIH_INE */ "ine",
|
|
|
|
/* WINED3DSIH_INEG */ "ineg",
|
|
|
|
/* WINED3DSIH_ISHL */ "ishl",
|
2016-06-02 12:46:54 +02:00
|
|
|
/* WINED3DSIH_ISHR */ "ishr",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_ITOF */ "itof",
|
|
|
|
/* WINED3DSIH_LABEL */ "label",
|
|
|
|
/* WINED3DSIH_LD */ "ld",
|
|
|
|
/* WINED3DSIH_LD2DMS */ "ld2dms",
|
2016-06-13 10:39:32 +02:00
|
|
|
/* WINED3DSIH_LD_RAW */ "ld_raw",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_LD_STRUCTURED */ "ld_structured",
|
2016-06-17 10:41:49 +02:00
|
|
|
/* WINED3DSIH_LD_UAV_TYPED */ "ld_uav_typed",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_LIT */ "lit",
|
2016-07-15 11:16:20 +02:00
|
|
|
/* WINED3DSIH_LOD */ "lod",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* 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",
|
2017-04-11 13:30:35 +02:00
|
|
|
/* WINED3DSIH_RETP */ "retp",
|
2016-05-13 13:55:30 +02:00
|
|
|
/* WINED3DSIH_ROUND_NE */ "round_ne",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* 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",
|
2016-07-15 11:16:22 +02:00
|
|
|
/* WINED3DSIH_SAMPLE_INFO */ "sample_info",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_SAMPLE_LOD */ "sample_l",
|
2016-07-15 11:16:21 +02:00
|
|
|
/* WINED3DSIH_SAMPLE_POS */ "sample_pos",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_SETP */ "setp",
|
|
|
|
/* WINED3DSIH_SGE */ "sge",
|
|
|
|
/* WINED3DSIH_SGN */ "sgn",
|
|
|
|
/* WINED3DSIH_SINCOS */ "sincos",
|
|
|
|
/* WINED3DSIH_SLT */ "slt",
|
|
|
|
/* WINED3DSIH_SQRT */ "sqrt",
|
2016-06-13 10:39:31 +02:00
|
|
|
/* WINED3DSIH_STORE_RAW */ "store_raw",
|
2016-06-13 10:39:35 +02:00
|
|
|
/* WINED3DSIH_STORE_STRUCTURED */ "store_structured",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_STORE_UAV_TYPED */ "store_uav_typed",
|
|
|
|
/* WINED3DSIH_SUB */ "sub",
|
2016-07-05 11:46:52 +02:00
|
|
|
/* WINED3DSIH_SWAPC */ "swapc",
|
2016-06-03 11:33:03 +02:00
|
|
|
/* WINED3DSIH_SWITCH */ "switch",
|
2016-11-30 12:47:30 +01:00
|
|
|
/* WINED3DSIH_SYNC */ "sync",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* 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",
|
2016-07-15 11:16:23 +02:00
|
|
|
/* WINED3DSIH_UBFE */ "ubfe",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_UDIV */ "udiv",
|
|
|
|
/* WINED3DSIH_UGE */ "uge",
|
2016-04-04 11:26:36 +02:00
|
|
|
/* WINED3DSIH_ULT */ "ult",
|
2016-06-03 11:33:02 +02:00
|
|
|
/* WINED3DSIH_UMAX */ "umax",
|
2016-07-15 11:16:19 +02:00
|
|
|
/* WINED3DSIH_UMIN */ "umin",
|
2017-03-10 09:10:55 +01:00
|
|
|
/* WINED3DSIH_UMUL */ "umul",
|
2016-03-29 12:14:58 +02:00
|
|
|
/* WINED3DSIH_USHR */ "ushr",
|
|
|
|
/* WINED3DSIH_UTOF */ "utof",
|
|
|
|
/* WINED3DSIH_XOR */ "xor",
|
2010-01-17 21:31:32 +01:00
|
|
|
};
|
|
|
|
|
2010-08-04 11:10:27 +02:00
|
|
|
static const char * const semantic_names[] =
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2012-01-18 21:46:22 +01:00
|
|
|
/* WINED3D_DECL_USAGE_POSITION */ "SV_POSITION",
|
|
|
|
/* WINED3D_DECL_USAGE_BLEND_WEIGHT */ "BLENDWEIGHT",
|
|
|
|
/* WINED3D_DECL_USAGE_BLEND_INDICES */ "BLENDINDICES",
|
|
|
|
/* WINED3D_DECL_USAGE_NORMAL */ "NORMAL",
|
|
|
|
/* WINED3D_DECL_USAGE_PSIZE */ "PSIZE",
|
|
|
|
/* WINED3D_DECL_USAGE_TEXCOORD */ "TEXCOORD",
|
|
|
|
/* WINED3D_DECL_USAGE_TANGENT */ "TANGENT",
|
|
|
|
/* WINED3D_DECL_USAGE_BINORMAL */ "BINORMAL",
|
|
|
|
/* WINED3D_DECL_USAGE_TESS_FACTOR */ "TESSFACTOR",
|
|
|
|
/* WINED3D_DECL_USAGE_POSITIONT */ "POSITIONT",
|
|
|
|
/* WINED3D_DECL_USAGE_COLOR */ "COLOR",
|
|
|
|
/* WINED3D_DECL_USAGE_FOG */ "FOG",
|
|
|
|
/* WINED3D_DECL_USAGE_DEPTH */ "DEPTH",
|
|
|
|
/* WINED3D_DECL_USAGE_SAMPLE */ "SAMPLE",
|
2010-01-17 21:31:32 +01:00
|
|
|
};
|
|
|
|
|
2016-02-02 11:32:29 +01:00
|
|
|
static const struct
|
|
|
|
{
|
2017-05-20 13:46:01 +02:00
|
|
|
enum wined3d_shader_input_sysval_semantic sysval_semantic;
|
2016-02-02 11:32:29 +01:00
|
|
|
const char *sysval_name;
|
|
|
|
}
|
2017-05-20 13:46:01 +02:00
|
|
|
shader_input_sysval_semantic_names[] =
|
2016-02-02 11:32:29 +01:00
|
|
|
{
|
2017-05-20 13:46:01 +02:00
|
|
|
{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"},
|
2016-02-02 11:32:29 +01:00
|
|
|
};
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
static void shader_dump_src_param(struct wined3d_string_buffer *buffer,
|
|
|
|
const struct wined3d_shader_src_param *param, const struct wined3d_shader_version *shader_version);
|
|
|
|
|
2016-01-01 18:08:05 +01:00
|
|
|
const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx)
|
|
|
|
{
|
2016-05-20 11:47:30 +02:00
|
|
|
if (handler_idx >= ARRAY_SIZE(shader_opcode_names))
|
2016-01-01 18:08:05 +01:00
|
|
|
return wine_dbg_sprintf("UNRECOGNIZED(%#x)", handler_idx);
|
|
|
|
|
|
|
|
return shader_opcode_names[handler_idx];
|
|
|
|
}
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
static const char *shader_semantic_name_from_usage(enum wined3d_decl_usage usage)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2016-05-20 11:47:30 +02:00
|
|
|
if (usage >= ARRAY_SIZE(semantic_names))
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
FIXME("Unrecognized usage %#x.\n", usage);
|
|
|
|
return "UNRECOGNIZED";
|
|
|
|
}
|
|
|
|
|
|
|
|
return semantic_names[usage];
|
|
|
|
}
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
static enum wined3d_decl_usage shader_usage_from_semantic_name(const char *name)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2016-05-20 11:47:30 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(semantic_names); ++i)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2016-05-20 11:47:30 +02:00
|
|
|
if (!strcmp(name, semantic_names[i]))
|
|
|
|
return i;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ~0U;
|
|
|
|
}
|
|
|
|
|
2016-05-20 11:47:30 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
BOOL shader_match_semantic(const char *semantic_name, enum wined3d_decl_usage usage)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
return !strcmp(semantic_name, shader_semantic_name_from_usage(usage));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e,
|
|
|
|
const struct wined3d_shader_semantic *s)
|
|
|
|
{
|
|
|
|
e->semantic_name = shader_semantic_name_from_usage(s->usage);
|
|
|
|
e->semantic_idx = s->usage_idx;
|
2017-04-06 11:47:46 +02:00
|
|
|
e->stream_idx = 0;
|
2016-05-20 11:47:30 +02:00
|
|
|
e->sysval_semantic = shader_sysval_semantic_from_usage(s->usage);
|
2016-05-31 23:29:50 +02:00
|
|
|
e->component_type = WINED3D_TYPE_FLOAT;
|
2012-10-14 18:40:36 +02:00
|
|
|
e->register_idx = s->reg.reg.idx[0].offset;
|
2010-01-17 21:31:32 +01:00
|
|
|
e->mask = s->reg.write_mask;
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:56:53 +02:00
|
|
|
static void shader_signature_from_usage(struct wined3d_shader_signature_element *e,
|
2012-01-18 21:46:22 +01:00
|
|
|
enum wined3d_decl_usage usage, UINT usage_idx, UINT reg_idx, DWORD write_mask)
|
2010-07-29 12:56:53 +02:00
|
|
|
{
|
|
|
|
e->semantic_name = shader_semantic_name_from_usage(usage);
|
|
|
|
e->semantic_idx = usage_idx;
|
2017-04-06 11:47:46 +02:00
|
|
|
e->stream_idx = 0;
|
2016-05-20 11:47:30 +02:00
|
|
|
e->sysval_semantic = shader_sysval_semantic_from_usage(usage);
|
2016-05-31 23:29:50 +02:00
|
|
|
e->component_type = WINED3D_TYPE_FLOAT;
|
2010-07-29 12:56:53 +02:00
|
|
|
e->register_idx = reg_idx;
|
|
|
|
e->mask = write_mask;
|
|
|
|
}
|
|
|
|
|
2017-02-21 00:40:05 +01:00
|
|
|
static const struct wined3d_shader_frontend *shader_select_frontend(enum wined3d_shader_byte_code_format format)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2017-02-21 00:40:05 +01:00
|
|
|
switch (format)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2017-02-21 00:40:05 +01:00
|
|
|
case WINED3D_SHADER_BYTE_CODE_FORMAT_SM1:
|
2010-01-17 21:31:32 +01:00
|
|
|
return &sm1_shader_frontend;
|
|
|
|
|
2017-02-21 00:40:05 +01:00
|
|
|
case WINED3D_SHADER_BYTE_CODE_FORMAT_SM4:
|
2010-01-17 21:31:32 +01:00
|
|
|
return &sm4_shader_frontend;
|
|
|
|
|
|
|
|
default:
|
2017-02-21 00:40:05 +01:00
|
|
|
WARN("Invalid byte code format %#x specified.\n", format);
|
2010-01-17 21:31:32 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-24 22:25:41 +02:00
|
|
|
void string_buffer_clear(struct wined3d_string_buffer *buffer)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
buffer->buffer[0] = '\0';
|
2013-02-25 21:49:29 +01:00
|
|
|
buffer->content_size = 0;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2015-04-24 22:25:41 +02:00
|
|
|
BOOL string_buffer_init(struct wined3d_string_buffer *buffer)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2015-04-24 22:25:42 +02:00
|
|
|
buffer->buffer_size = 32;
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(buffer->buffer = heap_alloc(buffer->buffer_size)))
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to allocate shader buffer memory.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-04-24 22:25:41 +02:00
|
|
|
string_buffer_clear(buffer);
|
2010-01-17 21:31:32 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-04-24 22:25:41 +02:00
|
|
|
void string_buffer_free(struct wined3d_string_buffer *buffer)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(buffer->buffer);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2015-04-29 23:34:28 +02:00
|
|
|
BOOL string_buffer_resize(struct wined3d_string_buffer *buffer, int rc)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2013-02-25 21:49:38 +01:00
|
|
|
char *new_buffer;
|
2015-04-29 23:34:28 +02:00
|
|
|
unsigned int new_buffer_size = buffer->buffer_size * 2;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2015-04-29 23:34:28 +02:00
|
|
|
while (rc > 0 && (unsigned int)rc >= new_buffer_size - buffer->content_size)
|
|
|
|
new_buffer_size *= 2;
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(new_buffer = heap_realloc(buffer->buffer, new_buffer_size)))
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2015-04-29 23:34:28 +02:00
|
|
|
ERR("Failed to grow buffer.\n");
|
|
|
|
buffer->buffer[buffer->content_size] = '\0';
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
buffer->buffer = new_buffer;
|
|
|
|
buffer->buffer_size = new_buffer_size;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2015-04-23 20:23:23 +02:00
|
|
|
|
2015-04-29 23:34:28 +02:00
|
|
|
int shader_vaddline(struct wined3d_string_buffer *buffer, const char *format, va_list args)
|
|
|
|
{
|
|
|
|
unsigned int rem;
|
|
|
|
int rc;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2015-04-29 23:34:28 +02:00
|
|
|
rem = buffer->buffer_size - buffer->content_size;
|
|
|
|
rc = vsnprintf(&buffer->buffer[buffer->content_size], rem, format, args);
|
|
|
|
if (rc < 0 /* C89 */ || (unsigned int)rc >= rem /* C99 */)
|
|
|
|
return rc;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2015-04-29 23:34:28 +02:00
|
|
|
buffer->content_size += rc;
|
2010-01-17 21:31:32 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-24 22:25:41 +02:00
|
|
|
int shader_addline(struct wined3d_string_buffer *buffer, const char *format, ...)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
int ret;
|
|
|
|
|
2015-04-29 23:34:28 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
va_start(args, format);
|
|
|
|
ret = shader_vaddline(buffer, format, args);
|
|
|
|
va_end(args);
|
|
|
|
if (!ret)
|
|
|
|
return ret;
|
|
|
|
if (!string_buffer_resize(buffer, ret))
|
|
|
|
return -1;
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2015-04-24 22:25:43 +02:00
|
|
|
struct wined3d_string_buffer *string_buffer_get(struct wined3d_string_buffer_list *list)
|
|
|
|
{
|
|
|
|
struct wined3d_string_buffer *buffer;
|
|
|
|
|
|
|
|
if (list_empty(&list->list))
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
buffer = heap_alloc(sizeof(*buffer));
|
2015-04-24 22:25:43 +02:00
|
|
|
if (!buffer || !string_buffer_init(buffer))
|
|
|
|
{
|
|
|
|
ERR("Couldn't allocate buffer for temporary string.\n");
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(buffer);
|
2015-04-24 22:25:43 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buffer = LIST_ENTRY(list_head(&list->list), struct wined3d_string_buffer, entry);
|
|
|
|
list_remove(&buffer->entry);
|
|
|
|
}
|
|
|
|
string_buffer_clear(buffer);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2015-04-29 23:34:28 +02:00
|
|
|
static int string_buffer_vsprintf(struct wined3d_string_buffer *buffer, const char *format, va_list args)
|
2015-04-24 22:25:43 +02:00
|
|
|
{
|
|
|
|
if (!buffer)
|
2015-04-29 23:34:28 +02:00
|
|
|
return 0;
|
2015-04-24 22:25:43 +02:00
|
|
|
string_buffer_clear(buffer);
|
2015-04-29 23:34:28 +02:00
|
|
|
return shader_vaddline(buffer, format, args);
|
2015-04-24 22:25:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void string_buffer_sprintf(struct wined3d_string_buffer *buffer, const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
2015-04-29 23:34:28 +02:00
|
|
|
int ret;
|
2015-04-24 22:25:43 +02:00
|
|
|
|
2015-04-29 23:34:28 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
va_start(args, format);
|
|
|
|
ret = string_buffer_vsprintf(buffer, format, args);
|
|
|
|
va_end(args);
|
|
|
|
if (!ret)
|
|
|
|
return;
|
|
|
|
if (!string_buffer_resize(buffer, ret))
|
|
|
|
return;
|
|
|
|
}
|
2015-04-24 22:25:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void string_buffer_release(struct wined3d_string_buffer_list *list, struct wined3d_string_buffer *buffer)
|
|
|
|
{
|
|
|
|
if (!buffer)
|
|
|
|
return;
|
|
|
|
list_add_head(&list->list, &buffer->entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
void string_buffer_list_init(struct wined3d_string_buffer_list *list)
|
|
|
|
{
|
|
|
|
list_init(&list->list);
|
|
|
|
}
|
|
|
|
|
|
|
|
void string_buffer_list_cleanup(struct wined3d_string_buffer_list *list)
|
|
|
|
{
|
|
|
|
struct wined3d_string_buffer *buffer, *buffer_next;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(buffer, buffer_next, &list->list, struct wined3d_string_buffer, entry)
|
|
|
|
{
|
|
|
|
string_buffer_free(buffer);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(buffer);
|
2015-04-24 22:25:43 +02:00
|
|
|
}
|
|
|
|
list_init(&list->list);
|
|
|
|
}
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
/* Convert floating point offset relative to a register file to an absolute
|
|
|
|
* offset for float constants. */
|
2011-11-13 19:52:27 +01:00
|
|
|
static unsigned int shader_get_float_offset(enum wined3d_shader_register_type register_type, UINT register_idx)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
switch (register_type)
|
|
|
|
{
|
|
|
|
case WINED3DSPR_CONST: return register_idx;
|
|
|
|
case WINED3DSPR_CONST2: return 2048 + register_idx;
|
|
|
|
case WINED3DSPR_CONST3: return 4096 + register_idx;
|
|
|
|
case WINED3DSPR_CONST4: return 6144 + register_idx;
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported register type: %u.\n", register_type);
|
|
|
|
return register_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shader_delete_constant_list(struct list *clist)
|
|
|
|
{
|
2015-07-02 17:41:32 +02:00
|
|
|
struct wined3d_shader_lconst *constant, *constant_next;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2015-07-02 17:41:32 +02:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(constant, constant_next, clist, struct wined3d_shader_lconst, entry)
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(constant);
|
2010-01-17 21:31:32 +01:00
|
|
|
list_init(clist);
|
|
|
|
}
|
|
|
|
|
2014-10-16 01:32:20 +02:00
|
|
|
static void shader_set_limits(struct wined3d_shader *shader)
|
2014-10-09 18:00:57 +02:00
|
|
|
{
|
2014-10-16 01:32:20 +02:00
|
|
|
static const struct limits_entry
|
|
|
|
{
|
|
|
|
unsigned int min_version;
|
|
|
|
unsigned int max_version;
|
|
|
|
struct wined3d_shader_limits limits;
|
|
|
|
}
|
|
|
|
vs_limits[] =
|
|
|
|
{
|
|
|
|
/* min_version, max_version, sampler, constant_int, constant_float, constant_bool, packed_output, packed_input */
|
|
|
|
{WINED3D_SHADER_VERSION(1, 0), WINED3D_SHADER_VERSION(1, 1), { 0, 0, 256, 0, 12, 0}},
|
|
|
|
{WINED3D_SHADER_VERSION(2, 0), WINED3D_SHADER_VERSION(2, 1), { 0, 16, 256, 16, 12, 0}},
|
|
|
|
/* DX10 cards on Windows advertise a D3D9 constant limit of 256
|
|
|
|
* even though they are capable of supporting much more (GL
|
|
|
|
* drivers advertise 1024). d3d9.dll and d3d8.dll clamp the
|
|
|
|
* wined3d-advertised maximum. Clamp the constant limit for <= 3.0
|
|
|
|
* 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}},
|
2016-04-14 12:20:26 +02:00
|
|
|
{WINED3D_SHADER_VERSION(4, 1), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 32, 0}},
|
2014-10-16 01:32:20 +02:00
|
|
|
{0}
|
|
|
|
},
|
2016-03-29 12:14:53 +02:00
|
|
|
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}},
|
|
|
|
},
|
2016-04-01 11:21:41 +02:00
|
|
|
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}},
|
|
|
|
},
|
2014-10-16 01:32:20 +02:00
|
|
|
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}},
|
2016-04-14 12:20:26 +02:00
|
|
|
{WINED3D_SHADER_VERSION(4, 1), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 32, 32}},
|
2014-10-16 01:32:20 +02:00
|
|
|
{0}
|
|
|
|
},
|
|
|
|
ps_limits[] =
|
|
|
|
{
|
|
|
|
/* min_version, max_version, sampler, constant_int, constant_float, constant_bool, packed_output, packed_input */
|
|
|
|
{WINED3D_SHADER_VERSION(1, 0), WINED3D_SHADER_VERSION(1, 3), { 4, 0, 8, 0, 0, 0}},
|
|
|
|
{WINED3D_SHADER_VERSION(1, 4), WINED3D_SHADER_VERSION(1, 4), { 6, 0, 8, 0, 0, 0}},
|
2014-10-16 01:32:21 +02:00
|
|
|
{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}},
|
2016-09-27 00:04:13 +02:00
|
|
|
{WINED3D_SHADER_VERSION(3, 0), WINED3D_SHADER_VERSION(3, 0), {16, 16, 224, 16, 0, 10}},
|
2016-02-16 20:48:06 +01:00
|
|
|
{WINED3D_SHADER_VERSION(4, 0), WINED3D_SHADER_VERSION(5, 0), {16, 0, 0, 0, 0, 32}},
|
2014-10-16 01:32:20 +02:00
|
|
|
{0}
|
2016-06-21 13:09:56 +02:00
|
|
|
},
|
|
|
|
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}},
|
2014-10-16 01:32:20 +02:00
|
|
|
};
|
|
|
|
const struct limits_entry *limits_array;
|
2014-10-09 18:00:57 +02:00
|
|
|
DWORD shader_version = WINED3D_SHADER_VERSION(shader->reg_maps.shader_version.major,
|
|
|
|
shader->reg_maps.shader_version.minor);
|
2014-10-16 01:32:20 +02:00
|
|
|
int i = 0;
|
2014-10-09 18:00:57 +02:00
|
|
|
|
2014-10-16 01:32:20 +02:00
|
|
|
switch (shader->reg_maps.shader_version.type)
|
2014-10-09 18:00:57 +02:00
|
|
|
{
|
2014-10-16 01:32:20 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unexpected shader type %u found.\n", shader->reg_maps.shader_version.type);
|
|
|
|
/* Fall-through. */
|
|
|
|
case WINED3D_SHADER_TYPE_VERTEX:
|
|
|
|
limits_array = vs_limits;
|
2014-10-09 18:00:57 +02:00
|
|
|
break;
|
2016-03-29 12:14:53 +02:00
|
|
|
case WINED3D_SHADER_TYPE_HULL:
|
|
|
|
limits_array = hs_limits;
|
|
|
|
break;
|
2016-04-01 11:21:41 +02:00
|
|
|
case WINED3D_SHADER_TYPE_DOMAIN:
|
|
|
|
limits_array = ds_limits;
|
|
|
|
break;
|
2014-10-16 01:32:20 +02:00
|
|
|
case WINED3D_SHADER_TYPE_GEOMETRY:
|
|
|
|
limits_array = gs_limits;
|
2014-10-09 18:00:57 +02:00
|
|
|
break;
|
2014-10-16 01:32:20 +02:00
|
|
|
case WINED3D_SHADER_TYPE_PIXEL:
|
|
|
|
limits_array = ps_limits;
|
2014-10-09 18:00:57 +02:00
|
|
|
break;
|
2016-06-21 13:09:56 +02:00
|
|
|
case WINED3D_SHADER_TYPE_COMPUTE:
|
|
|
|
limits_array = cs_limits;
|
|
|
|
break;
|
2014-10-09 18:00:57 +02:00
|
|
|
}
|
|
|
|
|
2014-10-16 01:32:20 +02:00
|
|
|
while (limits_array[i].min_version && limits_array[i].min_version <= shader_version)
|
2014-10-09 18:00:57 +02:00
|
|
|
{
|
2014-10-16 01:32:20 +02:00
|
|
|
if (shader_version <= limits_array[i].max_version)
|
|
|
|
{
|
|
|
|
shader->limits = &limits_array[i].limits;
|
2014-10-09 18:00:57 +02:00
|
|
|
break;
|
2014-10-16 01:32:20 +02:00
|
|
|
}
|
|
|
|
++i;
|
2014-10-09 18:00:57 +02:00
|
|
|
}
|
2014-10-16 01:32:20 +02:00
|
|
|
if (!shader->limits)
|
2014-10-09 18:00:57 +02:00
|
|
|
{
|
2014-10-16 01:32:20 +02:00
|
|
|
FIXME("Unexpected shader version \"%u.%u\".\n",
|
|
|
|
shader->reg_maps.shader_version.major,
|
|
|
|
shader->reg_maps.shader_version.minor);
|
|
|
|
shader->limits = &limits_array[max(0, i - 1)].limits;
|
2014-10-09 18:00:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL shader_record_register_usage(struct wined3d_shader *shader, struct wined3d_shader_reg_maps *reg_maps,
|
|
|
|
const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type, unsigned int constf_size)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
switch (reg->type)
|
|
|
|
{
|
|
|
|
case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */
|
2012-10-14 18:40:36 +02:00
|
|
|
if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->texcoord |= 1u << reg->idx[0].offset;
|
2012-10-14 18:40:36 +02:00
|
|
|
else
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->address |= 1u << reg->idx[0].offset;
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_TEMP:
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->temporary |= 1u << reg->idx[0].offset;
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_INPUT:
|
2017-12-07 12:14:18 +01:00
|
|
|
if (reg->idx[0].rel_addr)
|
|
|
|
reg_maps->input_rel_addressing = 1;
|
2010-01-17 21:31:32 +01:00
|
|
|
if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
|
|
|
|
{
|
2017-02-21 00:40:06 +01:00
|
|
|
/* 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. */
|
2012-10-14 18:40:36 +02:00
|
|
|
if (reg->idx[0].rel_addr)
|
2017-02-21 00:40:06 +01:00
|
|
|
shader->u.ps.input_reg_used = ~0u;
|
2010-01-17 21:31:32 +01:00
|
|
|
else
|
2017-02-21 00:40:06 +01:00
|
|
|
shader->u.ps.input_reg_used |= 1u << reg->idx[0].offset;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
2012-10-14 18:40:36 +02:00
|
|
|
else
|
2017-12-07 12:14:18 +01:00
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->input_registers |= 1u << reg->idx[0].offset;
|
2017-12-07 12:14:18 +01:00
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_RASTOUT:
|
2012-10-14 18:40:36 +02:00
|
|
|
if (reg->idx[0].offset == 1)
|
|
|
|
reg_maps->fog = 1;
|
2015-06-02 16:39:46 +02:00
|
|
|
if (reg->idx[0].offset == 2)
|
|
|
|
reg_maps->point_size = 1;
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_MISCTYPE:
|
|
|
|
if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
|
|
|
|
{
|
2012-10-14 18:40:36 +02:00
|
|
|
if (!reg->idx[0].offset)
|
|
|
|
reg_maps->vpos = 1;
|
|
|
|
else if (reg->idx[0].offset == 1)
|
|
|
|
reg_maps->usesfacing = 1;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_CONST:
|
2012-10-14 18:40:36 +02:00
|
|
|
if (reg->idx[0].rel_addr)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2012-10-14 18:40:36 +02:00
|
|
|
if (reg->idx[0].offset < reg_maps->min_rel_offset)
|
|
|
|
reg_maps->min_rel_offset = reg->idx[0].offset;
|
|
|
|
if (reg->idx[0].offset > reg_maps->max_rel_offset)
|
|
|
|
reg_maps->max_rel_offset = reg->idx[0].offset;
|
2010-01-17 21:31:32 +01:00
|
|
|
reg_maps->usesrelconstF = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-16 01:32:20 +02:00
|
|
|
if (reg->idx[0].offset >= min(shader->limits->constant_float, constf_size))
|
2014-10-09 18:00:57 +02:00
|
|
|
{
|
|
|
|
WARN("Shader using float constant %u which is not supported.\n", reg->idx[0].offset);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-06 10:55:24 +01:00
|
|
|
wined3d_insert_bits(reg_maps->constf, reg->idx[0].offset, 1, 0x1);
|
2014-10-09 18:00:57 +02:00
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_CONSTINT:
|
2014-10-16 01:32:20 +02:00
|
|
|
if (reg->idx[0].offset >= shader->limits->constant_int)
|
2014-10-09 18:00:57 +02:00
|
|
|
{
|
|
|
|
WARN("Shader using integer constant %u which is not supported.\n", reg->idx[0].offset);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->integer_constants |= (1u << reg->idx[0].offset);
|
2014-10-09 18:00:57 +02:00
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_CONSTBOOL:
|
2014-10-16 01:32:20 +02:00
|
|
|
if (reg->idx[0].offset >= shader->limits->constant_bool)
|
2014-10-09 18:00:57 +02:00
|
|
|
{
|
|
|
|
WARN("Shader using bool constant %u which is not supported.\n", reg->idx[0].offset);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->boolean_constants |= (1u << reg->idx[0].offset);
|
2014-10-09 18:00:57 +02:00
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_COLOROUT:
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->rt_mask |= (1u << reg->idx[0].offset);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2017-05-25 10:22:11 +02:00
|
|
|
case WINED3DSPR_OUTCONTROLPOINT:
|
|
|
|
reg_maps->vocp = 1;
|
|
|
|
break;
|
|
|
|
|
2018-05-17 13:17:37 +02:00
|
|
|
case WINED3DSPR_SAMPLEMASK:
|
|
|
|
reg_maps->sample_mask = 1;
|
|
|
|
break;
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
default:
|
2012-10-14 18:40:36 +02:00
|
|
|
TRACE("Not recording register of type %#x and [%#x][%#x].\n",
|
|
|
|
reg->type, reg->idx[0].offset, reg->idx[1].offset);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
}
|
2014-10-09 18:00:57 +02:00
|
|
|
return TRUE;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2015-01-19 13:44:08 +01:00
|
|
|
static void shader_record_sample(struct wined3d_shader_reg_maps *reg_maps,
|
|
|
|
unsigned int resource_idx, unsigned int sampler_idx, unsigned int bind_idx)
|
|
|
|
{
|
|
|
|
struct wined3d_shader_sampler_map_entry *entries, *entry;
|
|
|
|
struct wined3d_shader_sampler_map *map;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
map = ®_maps->sampler_map;
|
|
|
|
entries = map->entries;
|
|
|
|
for (i = 0; i < map->count; ++i)
|
|
|
|
{
|
|
|
|
if (entries[i].resource_idx == resource_idx && entries[i].sampler_idx == sampler_idx)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!map->size)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(entries = heap_calloc(4, sizeof(*entries))))
|
2015-01-19 13:44:08 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to allocate sampler map entries.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
map->size = 4;
|
|
|
|
map->entries = entries;
|
|
|
|
}
|
|
|
|
else if (map->count == map->size)
|
|
|
|
{
|
|
|
|
size_t new_size = map->size * 2;
|
|
|
|
|
|
|
|
if (sizeof(*entries) * new_size <= sizeof(*entries) * map->size
|
2018-02-14 07:39:59 +01:00
|
|
|
|| !(entries = heap_realloc(entries, sizeof(*entries) * new_size)))
|
2015-01-19 13:44:08 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to resize sampler map entries.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
map->size = new_size;
|
|
|
|
map->entries = entries;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = &entries[map->count++];
|
|
|
|
entry->resource_idx = resource_idx;
|
|
|
|
entry->sampler_idx = sampler_idx;
|
|
|
|
entry->bind_idx = bind_idx;
|
|
|
|
}
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param)
|
|
|
|
{
|
|
|
|
switch (instr)
|
|
|
|
{
|
|
|
|
case WINED3DSIH_M4x4:
|
|
|
|
case WINED3DSIH_M3x4:
|
|
|
|
return param == 1 ? 3 : 0;
|
|
|
|
|
|
|
|
case WINED3DSIH_M4x3:
|
|
|
|
case WINED3DSIH_M3x3:
|
|
|
|
return param == 1 ? 2 : 0;
|
|
|
|
|
|
|
|
case WINED3DSIH_M3x2:
|
|
|
|
return param == 1 ? 1 : 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-28 14:42:39 +01:00
|
|
|
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;
|
|
|
|
|
2017-03-07 09:50:23 +01:00
|
|
|
reg_maps->tgsm_count = max(register_idx + 1, reg_maps->tgsm_count);
|
2017-02-28 14:42:39 +01:00
|
|
|
tgsm = ®_maps->tgsm[register_idx];
|
|
|
|
tgsm->size = size;
|
|
|
|
tgsm->stride = stride;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-18 15:19:58 +02:00
|
|
|
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)
|
|
|
|
{
|
2018-10-03 12:32:17 +02:00
|
|
|
ERR("Unexpected shader type %s.\n", debug_shader_type(shader->reg_maps.shader_version.type));
|
2017-05-18 15:19:58 +02:00
|
|
|
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");
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(shader->u.hs.phases.control_point);
|
2017-05-18 15:19:58 +02:00
|
|
|
}
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(shader->u.hs.phases.control_point = heap_alloc_zero(sizeof(*shader->u.hs.phases.control_point))))
|
2017-05-18 15:19:58 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-12-05 00:26:29 +01:00
|
|
|
static HRESULT shader_calculate_clip_or_cull_distance_mask(
|
2018-02-08 15:22:47 +01:00
|
|
|
const struct wined3d_shader_signature_element *e, unsigned int *mask)
|
2017-12-05 00:26:29 +01:00
|
|
|
{
|
2018-02-08 15:22:47 +01:00
|
|
|
/* Clip and cull distances are packed in 4 component registers. 0 and 1 are
|
2017-12-05 00:26:29 +01:00
|
|
|
* the only allowed semantic indices.
|
|
|
|
*/
|
|
|
|
if (e->semantic_idx >= MAX_CLIP_DISTANCES / 4)
|
|
|
|
{
|
2018-02-08 15:22:47 +01:00
|
|
|
*mask = 0;
|
2017-12-05 00:26:29 +01:00
|
|
|
WARN("Invalid clip/cull distance index %u.\n", e->semantic_idx);
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
2018-02-08 15:22:47 +01:00
|
|
|
*mask = (e->mask & WINED3DSP_WRITEMASK_ALL) << (4 * e->semantic_idx);
|
2017-12-05 00:26:29 +01:00
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2017-10-18 00:25:09 +02:00
|
|
|
static void wined3d_insert_interpolation_mode(DWORD *packed_interpolation_mode,
|
|
|
|
unsigned int register_idx, enum wined3d_shader_interpolation_mode mode)
|
|
|
|
{
|
|
|
|
if (mode > WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE)
|
|
|
|
FIXME("Unexpected interpolation mode %#x.\n", mode);
|
|
|
|
|
|
|
|
wined3d_insert_bits(packed_interpolation_mode,
|
|
|
|
register_idx * WINED3D_PACKED_INTERPOLATION_BIT_COUNT, WINED3D_PACKED_INTERPOLATION_BIT_COUNT, mode);
|
|
|
|
}
|
|
|
|
|
2018-04-25 11:23:47 +02:00
|
|
|
static HRESULT shader_scan_output_signature(struct wined3d_shader *shader)
|
|
|
|
{
|
|
|
|
const struct wined3d_shader_signature *output_signature = &shader->output_signature;
|
|
|
|
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
|
|
|
|
unsigned int i;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
for (i = 0; i < output_signature->element_count; ++i)
|
|
|
|
{
|
|
|
|
const struct wined3d_shader_signature_element *e = &output_signature->elements[i];
|
|
|
|
unsigned int mask;
|
|
|
|
|
|
|
|
reg_maps->output_registers |= 1u << e->register_idx;
|
|
|
|
if (e->sysval_semantic == WINED3D_SV_CLIP_DISTANCE)
|
|
|
|
{
|
|
|
|
if (FAILED(hr = shader_calculate_clip_or_cull_distance_mask(e, &mask)))
|
|
|
|
return hr;
|
|
|
|
reg_maps->clip_distance_mask |= mask;
|
|
|
|
}
|
|
|
|
else if (e->sysval_semantic == WINED3D_SV_CULL_DISTANCE)
|
|
|
|
{
|
|
|
|
if (FAILED(hr = shader_calculate_clip_or_cull_distance_mask(e, &mask)))
|
|
|
|
return hr;
|
|
|
|
reg_maps->cull_distance_mask |= mask;
|
|
|
|
}
|
|
|
|
else if (e->sysval_semantic == WINED3D_SV_VIEWPORT_ARRAY_INDEX)
|
|
|
|
{
|
|
|
|
reg_maps->viewport_array = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
/* Note that this does not count the loop register as an address register. */
|
2018-04-25 11:23:48 +02:00
|
|
|
static HRESULT shader_get_registers_used(struct wined3d_shader *shader, DWORD constf_size)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2015-03-23 09:17:13 +01:00
|
|
|
struct wined3d_shader_signature_element input_signature_elements[max(MAX_ATTRIBS, MAX_REG_INPUT)];
|
2015-03-23 09:17:12 +01:00
|
|
|
struct wined3d_shader_signature_element output_signature_elements[MAX_REG_OUTPUT];
|
2018-04-25 11:23:48 +02:00
|
|
|
struct wined3d_shader_signature *output_signature = &shader->output_signature;
|
|
|
|
struct wined3d_shader_signature *input_signature = &shader->input_signature;
|
|
|
|
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
|
|
|
|
const struct wined3d_shader_frontend *fe = shader->frontend;
|
2010-01-17 21:31:32 +01:00
|
|
|
unsigned int cur_loop_depth = 0, max_loop_depth = 0;
|
|
|
|
struct wined3d_shader_version shader_version;
|
2017-05-18 15:19:58 +02:00
|
|
|
struct wined3d_shader_phase *phase = NULL;
|
|
|
|
const DWORD *ptr, *prev_ins, *current_ins;
|
|
|
|
void *fe_data = shader->frontend_data;
|
2015-03-23 09:17:12 +01:00
|
|
|
unsigned int i;
|
2017-02-28 14:42:39 +01:00
|
|
|
HRESULT hr;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
memset(reg_maps, 0, sizeof(*reg_maps));
|
2015-03-23 09:17:13 +01:00
|
|
|
memset(input_signature_elements, 0, sizeof(input_signature_elements));
|
2015-03-23 09:17:12 +01:00
|
|
|
memset(output_signature_elements, 0, sizeof(output_signature_elements));
|
2010-12-03 00:55:44 +01:00
|
|
|
reg_maps->min_rel_offset = ~0U;
|
2016-07-04 12:26:30 +02:00
|
|
|
list_init(®_maps->indexable_temps);
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
fe->shader_read_header(fe_data, &ptr, &shader_version);
|
2017-05-18 15:19:58 +02:00
|
|
|
prev_ins = current_ins = ptr;
|
2010-01-17 21:31:32 +01:00
|
|
|
reg_maps->shader_version = shader_version;
|
|
|
|
|
2014-10-16 01:32:20 +02:00
|
|
|
shader_set_limits(shader);
|
2014-10-09 18:00:57 +02:00
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(reg_maps->constf = heap_calloc(((min(shader->limits->constant_float, constf_size) + 31) / 32),
|
2016-05-23 18:06:27 +02:00
|
|
|
sizeof(*reg_maps->constf))))
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to allocate constant map memory.\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!fe->shader_is_end(fe_data, &ptr))
|
|
|
|
{
|
|
|
|
struct wined3d_shader_instruction ins;
|
|
|
|
|
2017-05-18 15:19:58 +02:00
|
|
|
current_ins = ptr;
|
2010-01-17 21:31:32 +01:00
|
|
|
/* Fetch opcode. */
|
2012-09-04 20:15:08 +02:00
|
|
|
fe->shader_read_instruction(fe_data, &ptr, &ins);
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
/* Unhandled opcode, and its parameters. */
|
|
|
|
if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
|
|
|
|
{
|
2017-03-08 10:53:06 +01:00
|
|
|
WARN("Encountered unrecognised or invalid instruction.\n");
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle declarations. */
|
2016-11-23 14:36:04 +01:00
|
|
|
if (ins.handler_idx == WINED3DSIH_DCL
|
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_UAV_TYPED)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2012-09-17 12:22:22 +02:00
|
|
|
struct wined3d_shader_semantic *semantic = &ins.declaration.semantic;
|
2014-12-03 10:28:08 +01:00
|
|
|
unsigned int reg_idx = semantic->reg.reg.idx[0].offset;
|
2012-09-17 12:22:22 +02:00
|
|
|
|
|
|
|
switch (semantic->reg.reg.type)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
/* Mark input registers used. */
|
|
|
|
case WINED3DSPR_INPUT:
|
2014-12-03 10:28:08 +01:00
|
|
|
if (reg_idx >= MAX_REG_INPUT)
|
|
|
|
{
|
|
|
|
ERR("Invalid input register index %u.\n", reg_idx);
|
|
|
|
break;
|
|
|
|
}
|
2015-02-06 15:25:34 +01:00
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL && shader_version.major == 3
|
|
|
|
&& semantic->usage == WINED3D_DECL_USAGE_POSITION && !semantic->usage_idx)
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->input_registers |= 1u << reg_idx;
|
2015-03-23 09:17:13 +01:00
|
|
|
shader_signature_from_semantic(&input_signature_elements[reg_idx], semantic);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Vertex shader: mark 3.0 output registers used, save token. */
|
|
|
|
case WINED3DSPR_OUTPUT:
|
2014-12-03 10:28:08 +01:00
|
|
|
if (reg_idx >= MAX_REG_OUTPUT)
|
|
|
|
{
|
|
|
|
ERR("Invalid output register index %u.\n", reg_idx);
|
|
|
|
break;
|
|
|
|
}
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->output_registers |= 1u << reg_idx;
|
2015-03-23 09:17:12 +01:00
|
|
|
shader_signature_from_semantic(&output_signature_elements[reg_idx], semantic);
|
2012-09-17 12:22:22 +02:00
|
|
|
if (semantic->usage == WINED3D_DECL_USAGE_FOG)
|
2012-01-18 21:46:22 +01:00
|
|
|
reg_maps->fog = 1;
|
2015-06-02 16:39:46 +02:00
|
|
|
if (semantic->usage == WINED3D_DECL_USAGE_PSIZE)
|
|
|
|
reg_maps->point_size = 1;
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_SAMPLER:
|
2015-01-19 13:44:08 +01:00
|
|
|
shader_record_sample(reg_maps, reg_idx, reg_idx, reg_idx);
|
2014-12-03 10:28:10 +01:00
|
|
|
case WINED3DSPR_RESOURCE:
|
2014-12-03 10:28:11 +01:00
|
|
|
if (reg_idx >= ARRAY_SIZE(reg_maps->resource_info))
|
2014-12-03 10:28:08 +01:00
|
|
|
{
|
2014-12-03 10:28:09 +01:00
|
|
|
ERR("Invalid resource index %u.\n", reg_idx);
|
2014-12-03 10:28:08 +01:00
|
|
|
break;
|
|
|
|
}
|
2014-12-03 10:28:11 +01:00
|
|
|
reg_maps->resource_info[reg_idx].type = semantic->resource_type;
|
|
|
|
reg_maps->resource_info[reg_idx].data_type = semantic->resource_data_type;
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2016-11-23 14:36:04 +01:00
|
|
|
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;
|
2017-03-08 12:07:19 +01:00
|
|
|
if (ins.flags)
|
|
|
|
FIXME("Ignoring typed UAV flags %#x.\n", ins.flags);
|
2016-11-23 14:36:04 +01:00
|
|
|
break;
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
default:
|
2012-09-17 12:22:22 +02:00
|
|
|
TRACE("Not recording DCL register type %#x.\n", semantic->reg.reg.type);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-10-02 22:15:40 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_CONSTANT_BUFFER)
|
|
|
|
{
|
|
|
|
struct wined3d_shader_register *reg = &ins.declaration.src.reg;
|
2012-10-14 18:40:36 +02:00
|
|
|
if (reg->idx[0].offset >= WINED3D_MAX_CBS)
|
|
|
|
ERR("Invalid CB index %u.\n", reg->idx[0].offset);
|
2012-10-02 22:15:40 +02:00
|
|
|
else
|
2012-10-14 18:40:36 +02:00
|
|
|
reg_maps->cb_sizes[reg->idx[0].offset] = reg->idx[1].offset;
|
2012-10-02 22:15:40 +02:00
|
|
|
}
|
2017-07-24 00:15:55 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_GLOBAL_FLAGS)
|
|
|
|
{
|
|
|
|
if (ins.flags & WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL)
|
|
|
|
{
|
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
|
|
|
|
shader->u.ps.force_early_depth_stencil = TRUE;
|
|
|
|
else
|
|
|
|
FIXME("Invalid instruction %#x for shader type %#x.\n",
|
|
|
|
ins.handler_idx, shader_version.type);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Ignoring global flags %#x.\n", ins.flags);
|
|
|
|
}
|
|
|
|
}
|
2017-04-21 10:59:52 +02:00
|
|
|
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);
|
|
|
|
}
|
2017-05-20 13:46:00 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
|
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT)
|
2017-05-20 13:45:59 +02:00
|
|
|
{
|
|
|
|
if (phase)
|
|
|
|
phase->instance_count = ins.declaration.count;
|
|
|
|
else
|
|
|
|
FIXME("Instruction %s outside of shader phase.\n",
|
|
|
|
debug_d3dshaderinstructionhandler(ins.handler_idx));
|
|
|
|
}
|
2016-02-01 00:14:36 +01:00
|
|
|
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;
|
|
|
|
}
|
2016-07-04 12:26:30 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_INDEXABLE_TEMP)
|
|
|
|
{
|
2017-05-20 13:46:03 +02:00
|
|
|
if (phase)
|
|
|
|
{
|
|
|
|
FIXME("Indexable temporary registers not supported.\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct wined3d_shader_indexable_temp *reg;
|
2016-07-04 12:26:30 +02:00
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(reg = heap_alloc(sizeof(*reg))))
|
2017-05-20 13:46:03 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2016-07-04 12:26:30 +02:00
|
|
|
|
2017-05-20 13:46:03 +02:00
|
|
|
*reg = ins.declaration.indexable_temp;
|
|
|
|
list_add_tail(®_maps->indexable_temps, ®->entry);
|
|
|
|
}
|
2016-07-04 12:26:30 +02:00
|
|
|
}
|
2012-11-14 23:05:59 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PRIMITIVE)
|
|
|
|
{
|
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
|
2017-05-15 12:05:47 +02:00
|
|
|
shader->u.gs.input_type = ins.declaration.primitive_type.type;
|
2012-11-14 23:05:59 +01:00
|
|
|
else
|
|
|
|
FIXME("Invalid instruction %#x for shader type %#x.\n",
|
|
|
|
ins.handler_idx, shader_version.type);
|
|
|
|
}
|
2017-10-18 00:25:07 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PS)
|
|
|
|
{
|
|
|
|
unsigned int reg_idx = ins.declaration.dst.reg.idx[0].offset;
|
2017-10-18 00:25:09 +02:00
|
|
|
if (reg_idx >= MAX_REG_INPUT)
|
2017-10-18 00:25:07 +02:00
|
|
|
{
|
|
|
|
ERR("Invalid register index %u.\n", reg_idx);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
|
2017-10-18 00:25:09 +02:00
|
|
|
wined3d_insert_interpolation_mode(shader->u.ps.interpolation_mode, reg_idx, ins.flags);
|
2017-10-18 00:25:07 +02:00
|
|
|
else
|
|
|
|
FIXME("Invalid instruction %#x for shader type %#x.\n",
|
|
|
|
ins.handler_idx, shader_version.type);
|
|
|
|
}
|
2017-09-10 14:25:40 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT)
|
|
|
|
{
|
|
|
|
if (ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUT
|
|
|
|
|| ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUTGE
|
|
|
|
|| ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUTLE)
|
|
|
|
{
|
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
|
|
|
|
shader->u.ps.depth_output = ins.declaration.dst.reg.type;
|
|
|
|
else
|
|
|
|
FIXME("Invalid instruction %#x for shader type %#x.\n",
|
|
|
|
ins.handler_idx, shader_version.type);
|
|
|
|
}
|
|
|
|
}
|
2017-05-17 15:42:34 +02:00
|
|
|
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);
|
|
|
|
}
|
2012-11-14 23:05:59 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT_TOPOLOGY)
|
|
|
|
{
|
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
|
2017-05-15 12:05:47 +02:00
|
|
|
shader->u.gs.output_type = ins.declaration.primitive_type.type;
|
2012-11-14 23:05:59 +01:00
|
|
|
else
|
|
|
|
FIXME("Invalid instruction %#x for shader type %#x.\n",
|
|
|
|
ins.handler_idx, shader_version.type);
|
|
|
|
}
|
2017-02-15 14:27:35 +01:00
|
|
|
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;
|
|
|
|
}
|
2017-02-24 12:27:38 +01:00
|
|
|
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;
|
|
|
|
}
|
2016-03-23 13:42:53 +01:00
|
|
|
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);
|
|
|
|
}
|
2016-07-05 11:46:54 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_TEMPS)
|
|
|
|
{
|
2017-05-20 13:46:03 +02:00
|
|
|
if (phase)
|
|
|
|
phase->temporary_count = ins.declaration.count;
|
|
|
|
else
|
|
|
|
reg_maps->temporary_count = ins.declaration.count;
|
2016-07-05 11:46:54 +02:00
|
|
|
}
|
2017-05-16 15:00:24 +02:00
|
|
|
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);
|
|
|
|
}
|
2017-02-28 14:42:37 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_TGSM_RAW)
|
|
|
|
{
|
2017-02-28 14:42:39 +01:00
|
|
|
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;
|
2017-02-28 14:42:38 +01:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_TGSM_STRUCTURED)
|
|
|
|
{
|
2017-02-28 14:42:39 +01:00
|
|
|
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;
|
2017-02-28 14:42:37 +01:00
|
|
|
}
|
2017-02-09 12:00:34 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2017-02-14 13:15:09 +01:00
|
|
|
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;
|
|
|
|
}
|
2017-03-08 12:07:19 +01:00
|
|
|
if (ins.flags)
|
|
|
|
FIXME("Ignoring raw UAV flags %#x.\n", ins.flags);
|
2017-02-14 13:15:09 +01:00
|
|
|
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;
|
|
|
|
}
|
2017-02-23 15:00:54 +01:00
|
|
|
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;
|
|
|
|
}
|
2012-11-14 23:05:59 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_VERTICES_OUT)
|
|
|
|
{
|
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
|
|
|
|
shader->u.gs.vertices_out = ins.declaration.count;
|
|
|
|
else
|
|
|
|
FIXME("Invalid instruction %#x for shader type %#x.\n",
|
|
|
|
ins.handler_idx, shader_version.type);
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEF)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
struct wined3d_shader_lconst *lconst;
|
2013-04-02 14:54:01 +02:00
|
|
|
float *value;
|
2018-02-14 07:39:59 +01:00
|
|
|
|
|
|
|
if (!(lconst = heap_alloc(sizeof(*lconst))))
|
|
|
|
return E_OUTOFMEMORY;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2012-10-14 18:40:36 +02:00
|
|
|
lconst->idx = ins.dst[0].reg.idx[0].offset;
|
2016-12-07 12:43:03 +01:00
|
|
|
memcpy(lconst->value, ins.src[0].reg.u.immconst_data, 4 * sizeof(DWORD));
|
2013-04-02 14:54:01 +02:00
|
|
|
value = (float *)lconst->value;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
/* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
|
|
|
|
if (shader_version.major == 1 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
|
|
|
|
{
|
|
|
|
if (value[0] < -1.0f) value[0] = -1.0f;
|
|
|
|
else if (value[0] > 1.0f) value[0] = 1.0f;
|
|
|
|
if (value[1] < -1.0f) value[1] = -1.0f;
|
|
|
|
else if (value[1] > 1.0f) value[1] = 1.0f;
|
|
|
|
if (value[2] < -1.0f) value[2] = -1.0f;
|
|
|
|
else if (value[2] > 1.0f) value[2] = 1.0f;
|
|
|
|
if (value[3] < -1.0f) value[3] = -1.0f;
|
|
|
|
else if (value[3] > 1.0f) value[3] = 1.0f;
|
|
|
|
}
|
|
|
|
|
2011-03-30 20:49:24 +02:00
|
|
|
list_add_head(&shader->constantsF, &lconst->entry);
|
2013-04-02 14:54:01 +02:00
|
|
|
|
|
|
|
if (isinf(value[0]) || isnan(value[0]) || isinf(value[1]) || isnan(value[1])
|
|
|
|
|| isinf(value[2]) || isnan(value[2]) || isinf(value[3]) || isnan(value[3]))
|
|
|
|
{
|
|
|
|
shader->lconst_inf_or_nan = TRUE;
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEFI)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
struct wined3d_shader_lconst *lconst;
|
|
|
|
|
|
|
|
if (!(lconst = heap_alloc(sizeof(*lconst))))
|
|
|
|
return E_OUTOFMEMORY;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2012-10-14 18:40:36 +02:00
|
|
|
lconst->idx = ins.dst[0].reg.idx[0].offset;
|
2016-12-07 12:43:03 +01:00
|
|
|
memcpy(lconst->value, ins.src[0].reg.u.immconst_data, 4 * sizeof(DWORD));
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2011-03-30 20:49:24 +02:00
|
|
|
list_add_head(&shader->constantsI, &lconst->entry);
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->local_int_consts |= (1u << lconst->idx);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEFB)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
struct wined3d_shader_lconst *lconst;
|
|
|
|
|
|
|
|
if (!(lconst = heap_alloc(sizeof(*lconst))))
|
|
|
|
return E_OUTOFMEMORY;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2012-10-14 18:40:36 +02:00
|
|
|
lconst->idx = ins.dst[0].reg.idx[0].offset;
|
2016-12-07 12:43:03 +01:00
|
|
|
memcpy(lconst->value, ins.src[0].reg.u.immconst_data, sizeof(DWORD));
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2011-03-30 20:49:24 +02:00
|
|
|
list_add_head(&shader->constantsB, &lconst->entry);
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->local_bool_consts |= (1u << lconst->idx);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
2017-05-18 15:19:58 +02:00
|
|
|
/* 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;
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
/* For subroutine prototypes. */
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_LABEL)
|
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->labels |= 1u << ins.src[0].reg.idx[0].offset;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
/* Set texture, address, temporary registers. */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOOL color0_mov = FALSE;
|
2012-09-04 20:15:08 +02:00
|
|
|
unsigned int i;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
/* This will loop over all the registers and try to
|
|
|
|
* make a bitmask of the ones we're interested in.
|
|
|
|
*
|
|
|
|
* Relative addressing tokens are ignored, but that's
|
|
|
|
* okay, since we'll catch any address registers when
|
|
|
|
* they are initialized (required by spec). */
|
2010-10-08 13:12:14 +02:00
|
|
|
for (i = 0; i < ins.dst_count; ++i)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2014-10-09 18:00:57 +02:00
|
|
|
if (!shader_record_register_usage(shader, reg_maps, &ins.dst[i].reg,
|
|
|
|
shader_version.type, constf_size))
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2015-10-12 23:17:04 +02:00
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2012-10-14 18:40:36 +02:00
|
|
|
UINT idx = ins.dst[i].reg.idx[0].offset;
|
2010-07-29 12:56:53 +02:00
|
|
|
|
2012-09-04 20:15:08 +02:00
|
|
|
switch (ins.dst[i].reg.type)
|
2010-07-29 12:56:53 +02:00
|
|
|
{
|
|
|
|
case WINED3DSPR_RASTOUT:
|
2015-10-12 23:17:04 +02:00
|
|
|
if (shader_version.major >= 3)
|
|
|
|
break;
|
2010-07-29 12:56:53 +02:00
|
|
|
switch (idx)
|
|
|
|
{
|
|
|
|
case 0: /* oPos */
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->output_registers |= 1u << 10;
|
2015-03-23 09:17:12 +01:00
|
|
|
shader_signature_from_usage(&output_signature_elements[10],
|
2012-01-18 21:46:22 +01:00
|
|
|
WINED3D_DECL_USAGE_POSITION, 0, 10, WINED3DSP_WRITEMASK_ALL);
|
2010-07-29 12:56:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* oFog */
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->output_registers |= 1u << 11;
|
2015-03-23 09:17:12 +01:00
|
|
|
shader_signature_from_usage(&output_signature_elements[11],
|
2012-01-18 21:46:22 +01:00
|
|
|
WINED3D_DECL_USAGE_FOG, 0, 11, WINED3DSP_WRITEMASK_0);
|
2010-07-29 12:56:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* oPts */
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->output_registers |= 1u << 11;
|
2015-03-23 09:17:12 +01:00
|
|
|
shader_signature_from_usage(&output_signature_elements[11],
|
2012-01-18 21:46:22 +01:00
|
|
|
WINED3D_DECL_USAGE_PSIZE, 0, 11, WINED3DSP_WRITEMASK_1);
|
2010-07-29 12:56:53 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_ATTROUT:
|
2015-10-12 23:17:04 +02:00
|
|
|
if (shader_version.major >= 3)
|
|
|
|
break;
|
2010-07-29 12:56:53 +02:00
|
|
|
if (idx < 2)
|
|
|
|
{
|
|
|
|
idx += 8;
|
2015-08-26 12:46:47 +02:00
|
|
|
if (reg_maps->output_registers & (1u << idx))
|
2010-07-29 12:56:53 +02:00
|
|
|
{
|
2015-03-23 09:17:12 +01:00
|
|
|
output_signature_elements[idx].mask |= ins.dst[i].write_mask;
|
2010-07-29 12:56:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->output_registers |= 1u << idx;
|
2015-03-23 09:17:12 +01:00
|
|
|
shader_signature_from_usage(&output_signature_elements[idx],
|
2012-09-04 20:15:08 +02:00
|
|
|
WINED3D_DECL_USAGE_COLOR, idx - 8, idx, ins.dst[i].write_mask);
|
2010-07-29 12:56:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-05-20 13:46:04 +02:00
|
|
|
case WINED3DSPR_TEXCRDOUT: /* WINED3DSPR_OUTPUT */
|
2015-10-12 23:17:04 +02:00
|
|
|
if (shader_version.major >= 3)
|
|
|
|
{
|
2017-02-21 00:40:07 +01:00
|
|
|
if (idx >= ARRAY_SIZE(reg_maps->u.output_registers_mask))
|
|
|
|
{
|
|
|
|
WARN("Invalid output register index %u.\n", idx);
|
|
|
|
break;
|
|
|
|
}
|
2015-10-12 23:17:04 +02:00
|
|
|
reg_maps->u.output_registers_mask[idx] |= ins.dst[i].write_mask;
|
|
|
|
break;
|
|
|
|
}
|
2017-02-21 00:40:07 +01:00
|
|
|
if (idx >= ARRAY_SIZE(reg_maps->u.texcoord_mask))
|
|
|
|
{
|
|
|
|
WARN("Invalid texcoord index %u.\n", idx);
|
|
|
|
break;
|
|
|
|
}
|
2015-10-12 23:17:04 +02:00
|
|
|
reg_maps->u.texcoord_mask[idx] |= ins.dst[i].write_mask;
|
2015-08-26 12:46:47 +02:00
|
|
|
if (reg_maps->output_registers & (1u << idx))
|
2010-07-29 12:56:53 +02:00
|
|
|
{
|
2015-03-23 09:17:12 +01:00
|
|
|
output_signature_elements[idx].mask |= ins.dst[i].write_mask;
|
2010-07-29 12:56:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->output_registers |= 1u << idx;
|
2015-03-23 09:17:12 +01:00
|
|
|
shader_signature_from_usage(&output_signature_elements[idx],
|
2012-09-04 20:15:08 +02:00
|
|
|
WINED3D_DECL_USAGE_TEXCOORD, idx, idx, ins.dst[i].write_mask);
|
2010-07-29 12:56:53 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
|
|
|
|
{
|
2012-10-14 18:40:36 +02:00
|
|
|
if (ins.dst[i].reg.type == WINED3DSPR_COLOROUT && !ins.dst[i].reg.idx[0].offset)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2011-03-29 19:21:52 +02:00
|
|
|
/* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to
|
|
|
|
* COLOROUT 0. If we know this in advance, the ARB shader backend can skip
|
|
|
|
* the mov and perform the sRGB write correction from the source register.
|
|
|
|
*
|
|
|
|
* However, if the mov is only partial, we can't do this, and if the write
|
|
|
|
* comes from an instruction other than MOV it is hard to do as well. If
|
|
|
|
* COLOROUT 0 is overwritten partially later, the marker is dropped again. */
|
|
|
|
shader->u.ps.color0_mov = FALSE;
|
2010-07-20 21:29:54 +02:00
|
|
|
if (ins.handler_idx == WINED3DSIH_MOV
|
2012-09-04 20:15:08 +02:00
|
|
|
&& ins.dst[i].write_mask == WINED3DSP_WRITEMASK_ALL)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
/* Used later when the source register is read. */
|
|
|
|
color0_mov = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Also drop the MOV marker if the source register is overwritten prior to the shader
|
|
|
|
* end
|
|
|
|
*/
|
2012-09-04 20:15:08 +02:00
|
|
|
else if (ins.dst[i].reg.type == WINED3DSPR_TEMP
|
2012-10-14 18:40:36 +02:00
|
|
|
&& ins.dst[i].reg.idx[0].offset == shader->u.ps.color0_reg)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2011-03-29 19:21:52 +02:00
|
|
|
shader->u.ps.color0_mov = FALSE;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Declare 1.x samplers implicitly, based on the destination reg. number. */
|
|
|
|
if (shader_version.major == 1
|
|
|
|
&& (ins.handler_idx == WINED3DSIH_TEX
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXBEM
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXBEML
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXDP3TEX
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXM3x2TEX
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXM3x3SPEC
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXM3x3TEX
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXREG2AR
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXREG2GB
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXREG2RGB))
|
|
|
|
{
|
2014-12-03 10:28:11 +01:00
|
|
|
unsigned int reg_idx = ins.dst[i].reg.idx[0].offset;
|
|
|
|
|
2017-02-21 00:40:08 +01:00
|
|
|
if (reg_idx >= ARRAY_SIZE(reg_maps->resource_info))
|
|
|
|
{
|
|
|
|
WARN("Invalid 1.x sampler index %u.\n", reg_idx);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-12-03 10:28:09 +01:00
|
|
|
TRACE("Setting fake 2D resource for 1.x pixelshader.\n");
|
2014-12-03 10:28:11 +01:00
|
|
|
reg_maps->resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_TEXTURE_2D;
|
|
|
|
reg_maps->resource_info[reg_idx].data_type = WINED3D_DATA_FLOAT;
|
2015-01-19 13:44:08 +01:00
|
|
|
shader_record_sample(reg_maps, reg_idx, reg_idx, reg_idx);
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
/* texbem is only valid with < 1.4 pixel shaders */
|
|
|
|
if (ins.handler_idx == WINED3DSIH_TEXBEM
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXBEML)
|
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->bumpmat |= 1u << reg_idx;
|
2010-01-17 21:31:32 +01:00
|
|
|
if (ins.handler_idx == WINED3DSIH_TEXBEML)
|
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->luminanceparams |= 1u << reg_idx;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_BEM)
|
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->bumpmat |= 1u << ins.dst[i].reg.idx[0].offset;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-03 01:30:31 +01:00
|
|
|
if (ins.handler_idx == WINED3DSIH_IMM_ATOMIC_ALLOC || ins.handler_idx == WINED3DSIH_IMM_ATOMIC_CONSUME)
|
2017-03-03 01:30:30 +01:00
|
|
|
{
|
|
|
|
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)
|
2017-03-03 01:30:31 +01:00
|
|
|
|| (WINED3DSIH_IMM_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_IMM_ATOMIC_XOR)
|
2017-03-03 01:30:36 +01:00
|
|
|
|| (ins.handler_idx == WINED3DSIH_BUFINFO && ins.src[0].reg.type == WINED3DSPR_UAV)
|
2017-02-24 12:27:40 +01:00
|
|
|
|| 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))
|
2016-11-23 14:36:09 +01:00
|
|
|
{
|
2016-11-29 12:06:31 +01:00
|
|
|
unsigned int reg_idx;
|
2017-02-24 12:27:40 +01:00
|
|
|
if (ins.handler_idx == WINED3DSIH_LD_UAV_TYPED || ins.handler_idx == WINED3DSIH_LD_RAW)
|
2016-11-29 12:06:31 +01:00
|
|
|
reg_idx = ins.src[1].reg.idx[0].offset;
|
2017-02-24 12:27:40 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_LD_STRUCTURED)
|
|
|
|
reg_idx = ins.src[2].reg.idx[0].offset;
|
2017-02-15 14:27:38 +01:00
|
|
|
else if (WINED3DSIH_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_ATOMIC_XOR)
|
2017-02-14 13:15:12 +01:00
|
|
|
reg_idx = ins.dst[0].reg.idx[0].offset;
|
2017-03-03 01:30:36 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_BUFINFO)
|
|
|
|
reg_idx = ins.src[0].reg.idx[0].offset;
|
2017-02-15 14:27:38 +01:00
|
|
|
else
|
|
|
|
reg_idx = ins.dst[1].reg.idx[0].offset;
|
2016-11-23 14:36:09 +01:00
|
|
|
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;
|
|
|
|
}
|
2016-07-27 23:33:40 +02:00
|
|
|
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;
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
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;
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_IFC) reg_maps->usesifc = 1;
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_CALL) reg_maps->usescall = 1;
|
2011-05-04 19:08:39 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_POW) reg_maps->usespow = 1;
|
2011-11-23 08:51:41 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_LOOP
|
|
|
|
|| ins.handler_idx == WINED3DSIH_REP)
|
|
|
|
{
|
|
|
|
++cur_loop_depth;
|
|
|
|
if (cur_loop_depth > max_loop_depth)
|
|
|
|
max_loop_depth = cur_loop_depth;
|
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_ENDLOOP
|
|
|
|
|| ins.handler_idx == WINED3DSIH_ENDREP)
|
2015-01-19 13:44:08 +01:00
|
|
|
{
|
2011-11-23 08:51:41 +01:00
|
|
|
--cur_loop_depth;
|
2015-01-19 13:44:08 +01:00
|
|
|
}
|
2017-04-11 13:30:31 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_GATHER4
|
2017-04-11 13:30:32 +02:00
|
|
|
|| ins.handler_idx == WINED3DSIH_GATHER4_C
|
2017-04-11 13:30:31 +02:00
|
|
|
|| ins.handler_idx == WINED3DSIH_SAMPLE
|
2016-01-27 23:43:46 +01:00
|
|
|
|| ins.handler_idx == WINED3DSIH_SAMPLE_B
|
2016-12-01 13:56:32 +01:00
|
|
|
|| ins.handler_idx == WINED3DSIH_SAMPLE_C
|
2016-01-27 23:43:45 +01:00
|
|
|
|| ins.handler_idx == WINED3DSIH_SAMPLE_C_LZ
|
2015-01-19 13:44:08 +01:00
|
|
|
|| 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);
|
|
|
|
}
|
2017-05-22 19:15:02 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_GATHER4_PO
|
|
|
|
|| ins.handler_idx == WINED3DSIH_GATHER4_PO_C)
|
2017-04-11 13:30:34 +02:00
|
|
|
{
|
|
|
|
shader_record_sample(reg_maps, ins.src[2].reg.idx[0].offset,
|
|
|
|
ins.src[3].reg.idx[0].offset, reg_maps->sampler_map.count);
|
|
|
|
}
|
2018-05-15 10:51:44 +02:00
|
|
|
else if ((ins.handler_idx == WINED3DSIH_BUFINFO && ins.src[0].reg.type == WINED3DSPR_RESOURCE)
|
2018-05-15 10:51:48 +02:00
|
|
|
|| (ins.handler_idx == WINED3DSIH_SAMPLE_INFO && ins.src[0].reg.type == WINED3DSPR_RESOURCE))
|
2017-03-03 01:30:36 +01:00
|
|
|
{
|
|
|
|
shader_record_sample(reg_maps, ins.src[0].reg.idx[0].offset,
|
|
|
|
WINED3D_SAMPLER_DEFAULT, reg_maps->sampler_map.count);
|
|
|
|
}
|
2016-01-17 22:48:49 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_LD
|
2018-02-05 13:13:39 +01:00
|
|
|
|| ins.handler_idx == WINED3DSIH_LD2DMS
|
2017-02-15 14:27:36 +01:00
|
|
|
|| (ins.handler_idx == WINED3DSIH_LD_RAW && ins.src[1].reg.type == WINED3DSPR_RESOURCE)
|
2016-11-23 14:36:02 +01:00
|
|
|
|| (ins.handler_idx == WINED3DSIH_RESINFO && ins.src[1].reg.type == WINED3DSPR_RESOURCE))
|
2016-01-05 21:52:31 +01:00
|
|
|
{
|
|
|
|
shader_record_sample(reg_maps, ins.src[1].reg.idx[0].offset,
|
|
|
|
WINED3D_SAMPLER_DEFAULT, reg_maps->sampler_map.count);
|
|
|
|
}
|
2017-02-24 12:27:37 +01:00
|
|
|
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);
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2012-09-04 20:15:08 +02:00
|
|
|
if (ins.predicate)
|
2014-10-09 18:00:57 +02:00
|
|
|
if (!shader_record_register_usage(shader, reg_maps, &ins.predicate->reg,
|
|
|
|
shader_version.type, constf_size))
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2012-09-04 20:15:08 +02:00
|
|
|
for (i = 0; i < ins.src_count; ++i)
|
|
|
|
{
|
|
|
|
unsigned int count = get_instr_extra_regcount(ins.handler_idx, i);
|
|
|
|
struct wined3d_shader_register reg = ins.src[i].reg;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2014-10-09 18:00:57 +02:00
|
|
|
if (!shader_record_register_usage(shader, reg_maps, &ins.src[i].reg,
|
|
|
|
shader_version.type, constf_size))
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
2010-01-17 21:31:32 +01:00
|
|
|
while (count)
|
|
|
|
{
|
2012-10-14 18:40:36 +02:00
|
|
|
++reg.idx[0].offset;
|
2014-10-09 18:00:57 +02:00
|
|
|
if (!shader_record_register_usage(shader, reg_maps, ®,
|
|
|
|
shader_version.type, constf_size))
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
2010-01-17 21:31:32 +01:00
|
|
|
--count;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (color0_mov)
|
|
|
|
{
|
2012-09-04 20:15:08 +02:00
|
|
|
if (ins.src[i].reg.type == WINED3DSPR_TEMP
|
|
|
|
&& ins.src[i].swizzle == WINED3DSP_NOSWIZZLE)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2011-03-29 19:21:52 +02:00
|
|
|
shader->u.ps.color0_mov = TRUE;
|
2012-10-14 18:40:36 +02:00
|
|
|
shader->u.ps.color0_reg = ins.src[i].reg.idx[0].offset;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-18 15:19:58 +02:00
|
|
|
|
|
|
|
prev_ins = current_ins;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
reg_maps->loop_depth = max_loop_depth;
|
|
|
|
|
2017-05-18 15:19:58 +02:00
|
|
|
if (phase)
|
|
|
|
{
|
|
|
|
phase->end = prev_ins;
|
|
|
|
phase = NULL;
|
|
|
|
}
|
|
|
|
|
2011-05-24 22:24:12 +02:00
|
|
|
/* 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)
|
2015-08-26 12:46:47 +02:00
|
|
|
reg_maps->rt_mask |= (1u << 0);
|
2011-05-24 22:24:12 +02:00
|
|
|
|
2015-03-23 09:17:13 +01:00
|
|
|
if (input_signature->elements)
|
|
|
|
{
|
|
|
|
for (i = 0; i < input_signature->element_count; ++i)
|
|
|
|
{
|
2017-07-25 14:26:00 +02:00
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
|
|
|
|
{
|
|
|
|
if (input_signature->elements[i].register_idx >= ARRAY_SIZE(shader->u.vs.attributes))
|
|
|
|
{
|
|
|
|
WARN("Invalid input signature register index %u.\n", input_signature->elements[i].register_idx);
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
|
2016-07-27 23:33:43 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2017-07-25 14:26:00 +02:00
|
|
|
reg_maps->input_registers |= 1u << input_signature->elements[i].register_idx;
|
2015-03-23 09:17:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!input_signature->elements && reg_maps->input_registers)
|
|
|
|
{
|
2016-01-26 22:51:28 +01:00
|
|
|
unsigned int count = wined3d_popcount(reg_maps->input_registers);
|
2015-03-23 09:17:13 +01:00
|
|
|
struct wined3d_shader_signature_element *e;
|
|
|
|
unsigned int i;
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(input_signature->elements = heap_calloc(count, sizeof(*input_signature->elements))))
|
2015-03-23 09:17:13 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
input_signature->element_count = count;
|
|
|
|
|
|
|
|
e = input_signature->elements;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(input_signature_elements); ++i)
|
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
if (!(reg_maps->input_registers & (1u << i)))
|
2015-03-23 09:17:13 +01:00
|
|
|
continue;
|
|
|
|
input_signature_elements[i].register_idx = i;
|
|
|
|
*e++ = input_signature_elements[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-23 09:17:12 +01:00
|
|
|
if (output_signature->elements)
|
|
|
|
{
|
2018-04-25 11:23:47 +02:00
|
|
|
if (FAILED(hr = shader_scan_output_signature(shader)))
|
|
|
|
return hr;
|
2015-03-23 09:17:12 +01:00
|
|
|
}
|
|
|
|
else if (reg_maps->output_registers)
|
|
|
|
{
|
2016-01-26 22:51:28 +01:00
|
|
|
unsigned int count = wined3d_popcount(reg_maps->output_registers);
|
2015-03-23 09:17:12 +01:00
|
|
|
struct wined3d_shader_signature_element *e;
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(output_signature->elements = heap_calloc(count, sizeof(*output_signature->elements))))
|
2015-03-23 09:17:12 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
output_signature->element_count = count;
|
|
|
|
|
|
|
|
e = output_signature->elements;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(output_signature_elements); ++i)
|
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
if (!(reg_maps->output_registers & (1u << i)))
|
2015-03-23 09:17:12 +01:00
|
|
|
continue;
|
|
|
|
*e++ = output_signature_elements[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2016-07-04 12:26:30 +02:00
|
|
|
static void shader_cleanup_reg_maps(struct wined3d_shader_reg_maps *reg_maps)
|
|
|
|
{
|
|
|
|
struct wined3d_shader_indexable_temp *reg, *reg_next;
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(reg_maps->constf);
|
|
|
|
heap_free(reg_maps->sampler_map.entries);
|
2016-07-04 12:26:30 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(reg, reg_next, ®_maps->indexable_temps, struct wined3d_shader_indexable_temp, entry)
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(reg);
|
2016-07-04 12:26:30 +02:00
|
|
|
list_init(®_maps->indexable_temps);
|
2017-02-28 14:42:37 +01:00
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(reg_maps->tgsm);
|
2016-07-04 12:26:30 +02:00
|
|
|
}
|
|
|
|
|
2010-12-06 20:33:02 +01:00
|
|
|
unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps, unsigned int max)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2015-08-26 12:46:47 +02:00
|
|
|
DWORD map = 1u << max;
|
2010-01-17 21:31:32 +01:00
|
|
|
map |= map - 1;
|
|
|
|
map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers;
|
|
|
|
|
|
|
|
return wined3d_log2i(map);
|
|
|
|
}
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
static void shader_dump_global_flags(struct wined3d_string_buffer *buffer, DWORD global_flags)
|
2016-02-02 11:32:34 +01:00
|
|
|
{
|
|
|
|
if (global_flags & WINED3DSGF_REFACTORING_ALLOWED)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "refactoringAllowed");
|
2016-02-02 11:32:34 +01:00
|
|
|
global_flags &= ~WINED3DSGF_REFACTORING_ALLOWED;
|
|
|
|
if (global_flags)
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, " | ");
|
2016-02-02 11:32:34 +01:00
|
|
|
}
|
|
|
|
|
2017-07-24 00:15:55 +02:00
|
|
|
if (global_flags & WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL)
|
|
|
|
{
|
|
|
|
shader_addline(buffer, "forceEarlyDepthStencil");
|
|
|
|
global_flags &= ~WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL;
|
|
|
|
if (global_flags)
|
|
|
|
shader_addline(buffer, " | ");
|
|
|
|
}
|
|
|
|
|
2016-02-02 11:32:34 +01:00
|
|
|
if (global_flags & WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "enableRawAndStructuredBuffers");
|
2016-02-02 11:32:34 +01:00
|
|
|
global_flags &= ~WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (global_flags)
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "unknown_flags(%#x)", global_flags);
|
2016-02-02 11:32:34 +01:00
|
|
|
}
|
|
|
|
|
2016-11-30 12:47:30 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-04-27 14:52:48 +02:00
|
|
|
static void shader_dump_precise_flags(struct wined3d_string_buffer *buffer, DWORD flags)
|
2018-04-26 14:53:20 +02:00
|
|
|
{
|
2018-04-27 14:52:48 +02:00
|
|
|
if (!(flags & WINED3DSI_PRECISE_XYZW))
|
2018-04-26 14:53:20 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
shader_addline(buffer, " [precise");
|
2018-04-27 14:52:48 +02:00
|
|
|
if (flags != WINED3DSI_PRECISE_XYZW)
|
2018-04-26 14:53:20 +02:00
|
|
|
{
|
|
|
|
shader_addline(buffer, "(%s%s%s%s)",
|
2018-04-27 14:52:48 +02:00
|
|
|
flags & WINED3DSI_PRECISE_X ? "x" : "",
|
|
|
|
flags & WINED3DSI_PRECISE_Y ? "y" : "",
|
|
|
|
flags & WINED3DSI_PRECISE_Z ? "z" : "",
|
|
|
|
flags & WINED3DSI_PRECISE_W ? "w" : "");
|
2018-04-26 14:53:20 +02:00
|
|
|
}
|
|
|
|
shader_addline(buffer, "]");
|
|
|
|
}
|
|
|
|
|
2016-11-30 12:47:31 +01:00
|
|
|
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;
|
|
|
|
}
|
2016-11-30 12:47:32 +01:00
|
|
|
if (uav_flags & WINED3DSUF_ORDER_PRESERVING_COUNTER)
|
|
|
|
{
|
|
|
|
shader_addline(buffer, "_opc");
|
|
|
|
uav_flags &= ~WINED3DSUF_ORDER_PRESERVING_COUNTER;
|
|
|
|
}
|
2016-11-30 12:47:31 +01:00
|
|
|
|
|
|
|
if (uav_flags)
|
|
|
|
shader_addline(buffer, "_unknown_flags(%#x)", uav_flags);
|
|
|
|
}
|
|
|
|
|
2016-04-01 11:21:37 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-01 11:21:38 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-01 11:21:39 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-20 13:46:01 +02:00
|
|
|
static void shader_dump_shader_input_sysval_semantic(struct wined3d_string_buffer *buffer,
|
|
|
|
enum wined3d_shader_input_sysval_semantic semantic)
|
2016-02-02 11:32:29 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2017-05-20 13:46:01 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(shader_input_sysval_semantic_names); ++i)
|
2016-02-02 11:32:29 +01:00
|
|
|
{
|
2017-05-20 13:46:01 +02:00
|
|
|
if (shader_input_sysval_semantic_names[i].sysval_semantic == semantic)
|
2016-02-02 11:32:29 +01:00
|
|
|
{
|
2017-05-20 13:46:01 +02:00
|
|
|
shader_addline(buffer, "%s", shader_input_sysval_semantic_names[i].sysval_name);
|
2016-02-02 11:32:29 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-20 13:46:01 +02:00
|
|
|
shader_addline(buffer, "unknown_shader_input_sysval_semantic(%#x)", semantic);
|
2016-02-02 11:32:29 +01:00
|
|
|
}
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer,
|
2017-03-08 12:07:19 +01:00
|
|
|
const struct wined3d_shader_semantic *semantic, unsigned int flags,
|
|
|
|
const struct wined3d_shader_version *shader_version)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "dcl");
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
if (semantic->reg.reg.type == WINED3DSPR_SAMPLER)
|
|
|
|
{
|
2014-12-03 10:28:09 +01:00
|
|
|
switch (semantic->resource_type)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2014-12-03 10:28:09 +01:00
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_2D:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "_2d");
|
2014-12-03 10:28:09 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_3D:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "_3d");
|
2014-12-03 10:28:09 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "_cube");
|
2014-12-03 10:28:09 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "_unknown_resource_type(%#x)", semantic->resource_type);
|
2014-12-03 10:28:10 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-03-25 19:53:38 +01:00
|
|
|
else if (semantic->reg.reg.type == WINED3DSPR_RESOURCE || semantic->reg.reg.type == WINED3DSPR_UAV)
|
2014-12-03 10:28:10 +01:00
|
|
|
{
|
2016-03-25 19:53:38 +01:00
|
|
|
if (semantic->reg.reg.type == WINED3DSPR_RESOURCE)
|
|
|
|
shader_addline(buffer, "_resource_");
|
|
|
|
else
|
|
|
|
shader_addline(buffer, "_uav_");
|
2014-12-03 10:28:10 +01:00
|
|
|
switch (semantic->resource_type)
|
|
|
|
{
|
|
|
|
case WINED3D_SHADER_RESOURCE_BUFFER:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "buffer");
|
2014-12-03 10:28:10 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_1D:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "texture1d");
|
2014-12-03 10:28:10 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_2D:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "texture2d");
|
2014-12-03 10:28:10 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_2DMS:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "texture2dms");
|
2014-12-03 10:28:10 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_3D:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "texture3d");
|
2014-12-03 10:28:10 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "texturecube");
|
2014-12-03 10:28:10 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "texture1darray");
|
2014-12-03 10:28:10 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "texture2darray");
|
2014-12-03 10:28:10 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "texture2dmsarray");
|
2014-12-03 10:28:10 +01:00
|
|
|
break;
|
|
|
|
|
2017-02-10 12:26:53 +01:00
|
|
|
case WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY:
|
|
|
|
shader_addline(buffer, "texturecubearray");
|
|
|
|
break;
|
|
|
|
|
2014-12-03 10:28:10 +01:00
|
|
|
default:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "unknown");
|
2014-12-03 10:28:09 +01:00
|
|
|
break;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
2017-03-08 12:07:19 +01:00
|
|
|
if (semantic->reg.reg.type == WINED3DSPR_UAV)
|
|
|
|
shader_dump_uav_flags(buffer, flags);
|
2014-12-03 10:28:11 +01:00
|
|
|
switch (semantic->resource_data_type)
|
|
|
|
{
|
|
|
|
case WINED3D_DATA_FLOAT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, " (float)");
|
2014-12-03 10:28:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_DATA_INT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, " (int)");
|
2014-12-03 10:28:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_DATA_UINT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, " (uint)");
|
2014-12-03 10:28:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_DATA_UNORM:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, " (unorm)");
|
2014-12-03 10:28:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_DATA_SNORM:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, " (snorm)");
|
2014-12-03 10:28:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, " (unknown)");
|
2014-12-03 10:28:11 +01:00
|
|
|
break;
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Pixel shaders 3.0 don't have usage semantics. */
|
2016-02-12 18:52:21 +01:00
|
|
|
if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
shader_addline(buffer, "_");
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
switch (semantic->usage)
|
|
|
|
{
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_POSITION:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "position%u", semantic->usage_idx);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_BLEND_INDICES:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "blend");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_BLEND_WEIGHT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "weight");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_NORMAL:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "normal%u", semantic->usage_idx);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_PSIZE:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "psize");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_COLOR:
|
2016-02-12 18:52:21 +01:00
|
|
|
if (!semantic->usage_idx)
|
|
|
|
shader_addline(buffer, "color");
|
|
|
|
else
|
|
|
|
shader_addline(buffer, "specular%u", (semantic->usage_idx - 1));
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_TEXCOORD:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "texture%u", semantic->usage_idx);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_TANGENT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "tangent");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_BINORMAL:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "binormal");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_TESS_FACTOR:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "tessfactor");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_POSITIONT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "positionT%u", semantic->usage_idx);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_FOG:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "fog");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_DEPTH:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "depth");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
case WINED3D_DECL_USAGE_SAMPLE:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "sample");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "<unknown_semantic(%#x)>", semantic->usage);
|
2016-10-07 16:01:22 +02:00
|
|
|
FIXME("Unrecognised semantic usage %#x.\n", semantic->usage);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
static void shader_dump_register(struct wined3d_string_buffer *buffer,
|
|
|
|
const struct wined3d_shader_register *reg, const struct wined3d_shader_version *shader_version)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
|
|
|
|
static const char * const misctype_reg_names[] = {"vPos", "vFace"};
|
2012-10-14 18:40:36 +02:00
|
|
|
UINT offset = reg->idx[0].offset;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
switch (reg->type)
|
|
|
|
{
|
|
|
|
case WINED3DSPR_TEMP:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "r");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_INPUT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "v");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_CONST:
|
|
|
|
case WINED3DSPR_CONST2:
|
|
|
|
case WINED3DSPR_CONST3:
|
|
|
|
case WINED3DSPR_CONST4:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "c");
|
2012-10-14 18:40:36 +02:00
|
|
|
offset = shader_get_float_offset(reg->type, offset);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a');
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_RASTOUT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "%s", rastout_reg_names[offset]);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_COLOROUT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "oC");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_DEPTHOUT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "oDepth");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2017-09-10 14:25:39 +02:00
|
|
|
case WINED3DSPR_DEPTHOUTGE:
|
|
|
|
shader_addline(buffer, "oDepthGE");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_DEPTHOUTLE:
|
|
|
|
shader_addline(buffer, "oDepthLE");
|
|
|
|
break;
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
case WINED3DSPR_ATTROUT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "oD");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_TEXCRDOUT:
|
|
|
|
/* Vertex shaders >= 3.0 use general purpose output registers
|
|
|
|
* (WINED3DSPR_OUTPUT), which can include an address token. */
|
2016-02-12 18:52:21 +01:00
|
|
|
if (shader_version->major >= 3)
|
|
|
|
shader_addline(buffer, "o");
|
|
|
|
else
|
|
|
|
shader_addline(buffer, "oT");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_CONSTINT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "i");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_CONSTBOOL:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "b");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_LABEL:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "l");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_LOOP:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "aL");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_SAMPLER:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "s");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_MISCTYPE:
|
2012-10-14 18:40:36 +02:00
|
|
|
if (offset > 1)
|
2016-02-12 18:52:21 +01:00
|
|
|
{
|
2012-10-14 18:40:36 +02:00
|
|
|
FIXME("Unhandled misctype register %u.\n", offset);
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "<unhandled misctype %#x>", offset);
|
|
|
|
}
|
2012-10-14 18:40:36 +02:00
|
|
|
else
|
2016-02-12 18:52:21 +01:00
|
|
|
{
|
|
|
|
shader_addline(buffer, "%s", misctype_reg_names[offset]);
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_PREDICATE:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "p");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_IMMCONST:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "l");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_CONSTBUFFER:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "cb");
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2016-01-29 09:44:44 +01:00
|
|
|
case WINED3DSPR_IMMCONSTBUFFER:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "icb");
|
2016-01-29 09:44:44 +01:00
|
|
|
break;
|
|
|
|
|
2012-10-15 22:26:19 +02:00
|
|
|
case WINED3DSPR_PRIMID:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "primID");
|
2012-10-15 22:26:19 +02:00
|
|
|
break;
|
|
|
|
|
2010-10-08 13:12:15 +02:00
|
|
|
case WINED3DSPR_NULL:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "null");
|
2010-10-08 13:12:15 +02:00
|
|
|
break;
|
|
|
|
|
2018-05-15 10:51:48 +02:00
|
|
|
case WINED3DSPR_RASTERIZER:
|
|
|
|
shader_addline(buffer, "rasterizer");
|
|
|
|
break;
|
|
|
|
|
2010-10-12 13:40:03 +02:00
|
|
|
case WINED3DSPR_RESOURCE:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "t");
|
2010-10-12 13:40:03 +02:00
|
|
|
break;
|
|
|
|
|
2016-03-25 19:53:38 +01:00
|
|
|
case WINED3DSPR_UAV:
|
|
|
|
shader_addline(buffer, "u");
|
|
|
|
break;
|
|
|
|
|
2016-04-04 11:26:32 +02:00
|
|
|
case WINED3DSPR_OUTPOINTID:
|
|
|
|
shader_addline(buffer, "vOutputControlPointID");
|
|
|
|
break;
|
|
|
|
|
2016-03-31 10:54:43 +02:00
|
|
|
case WINED3DSPR_FORKINSTID:
|
|
|
|
shader_addline(buffer, "vForkInstanceId");
|
|
|
|
break;
|
|
|
|
|
2017-03-02 15:11:48 +01:00
|
|
|
case WINED3DSPR_JOININSTID:
|
|
|
|
shader_addline(buffer, "vJoinInstanceId");
|
|
|
|
break;
|
|
|
|
|
2016-04-04 11:26:31 +02:00
|
|
|
case WINED3DSPR_INCONTROLPOINT:
|
|
|
|
shader_addline(buffer, "vicp");
|
|
|
|
break;
|
|
|
|
|
2016-07-15 11:16:18 +02:00
|
|
|
case WINED3DSPR_OUTCONTROLPOINT:
|
|
|
|
shader_addline(buffer, "vocp");
|
|
|
|
break;
|
|
|
|
|
2016-04-04 11:26:33 +02:00
|
|
|
case WINED3DSPR_PATCHCONST:
|
|
|
|
shader_addline(buffer, "vpc");
|
|
|
|
break;
|
|
|
|
|
2016-04-04 11:26:30 +02:00
|
|
|
case WINED3DSPR_TESSCOORD:
|
|
|
|
shader_addline(buffer, "vDomainLocation");
|
|
|
|
break;
|
|
|
|
|
2016-06-13 10:39:30 +02:00
|
|
|
case WINED3DSPR_GROUPSHAREDMEM:
|
|
|
|
shader_addline(buffer, "g");
|
|
|
|
break;
|
|
|
|
|
2016-06-22 11:37:29 +02:00
|
|
|
case WINED3DSPR_THREADID:
|
|
|
|
shader_addline(buffer, "vThreadID");
|
|
|
|
break;
|
|
|
|
|
2016-06-21 13:10:00 +02:00
|
|
|
case WINED3DSPR_THREADGROUPID:
|
|
|
|
shader_addline(buffer, "vThreadGroupID");
|
|
|
|
break;
|
|
|
|
|
2016-06-21 13:10:01 +02:00
|
|
|
case WINED3DSPR_LOCALTHREADID:
|
|
|
|
shader_addline(buffer, "vThreadIDInGroup");
|
|
|
|
break;
|
|
|
|
|
2016-06-21 13:09:59 +02:00
|
|
|
case WINED3DSPR_LOCALTHREADINDEX:
|
|
|
|
shader_addline(buffer, "vThreadIDInGroupFlattened");
|
|
|
|
break;
|
|
|
|
|
2016-06-23 12:07:59 +02:00
|
|
|
case WINED3DSPR_IDXTEMP:
|
|
|
|
shader_addline(buffer, "x");
|
|
|
|
break;
|
|
|
|
|
2016-07-04 12:26:28 +02:00
|
|
|
case WINED3DSPR_STREAM:
|
|
|
|
shader_addline(buffer, "m");
|
|
|
|
break;
|
|
|
|
|
2016-12-07 12:43:03 +01:00
|
|
|
case WINED3DSPR_FUNCTIONBODY:
|
|
|
|
shader_addline(buffer, "fb");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_FUNCTIONPOINTER:
|
|
|
|
shader_addline(buffer, "fp");
|
|
|
|
break;
|
|
|
|
|
2016-12-09 11:30:50 +01:00
|
|
|
case WINED3DSPR_COVERAGE:
|
|
|
|
shader_addline(buffer, "vCoverage");
|
|
|
|
break;
|
|
|
|
|
2016-12-09 11:30:51 +01:00
|
|
|
case WINED3DSPR_SAMPLEMASK:
|
|
|
|
shader_addline(buffer, "oMask");
|
|
|
|
break;
|
|
|
|
|
2017-04-21 10:59:51 +02:00
|
|
|
case WINED3DSPR_GSINSTID:
|
|
|
|
shader_addline(buffer, "vGSInstanceID");
|
|
|
|
break;
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
default:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "<unhandled_rtype(%#x)>", reg->type);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reg->type == WINED3DSPR_IMMCONST)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "(");
|
2010-01-17 21:31:32 +01:00
|
|
|
switch (reg->immconst_type)
|
|
|
|
{
|
2010-10-08 13:12:18 +02:00
|
|
|
case WINED3D_IMMCONST_SCALAR:
|
2012-09-04 20:15:09 +02:00
|
|
|
switch (reg->data_type)
|
|
|
|
{
|
|
|
|
case WINED3D_DATA_FLOAT:
|
2016-12-07 12:43:03 +01:00
|
|
|
shader_addline(buffer, "%.8e", *(const float *)reg->u.immconst_data);
|
2012-09-04 20:15:09 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_DATA_INT:
|
2016-12-07 12:43:03 +01:00
|
|
|
shader_addline(buffer, "%d", reg->u.immconst_data[0]);
|
2012-09-04 20:15:09 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_DATA_RESOURCE:
|
|
|
|
case WINED3D_DATA_SAMPLER:
|
|
|
|
case WINED3D_DATA_UINT:
|
2016-12-07 12:43:03 +01:00
|
|
|
shader_addline(buffer, "%u", reg->u.immconst_data[0]);
|
2012-09-04 20:15:09 +02:00
|
|
|
break;
|
|
|
|
default:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
|
2012-09-04 20:15:09 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
2010-10-08 13:12:18 +02:00
|
|
|
case WINED3D_IMMCONST_VEC4:
|
2012-09-04 20:15:09 +02:00
|
|
|
switch (reg->data_type)
|
|
|
|
{
|
|
|
|
case WINED3D_DATA_FLOAT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "%.8e, %.8e, %.8e, %.8e",
|
2016-12-07 12:43:03 +01:00
|
|
|
*(const float *)®->u.immconst_data[0], *(const float *)®->u.immconst_data[1],
|
|
|
|
*(const float *)®->u.immconst_data[2], *(const float *)®->u.immconst_data[3]);
|
2012-09-04 20:15:09 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_DATA_INT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "%d, %d, %d, %d",
|
2016-12-07 12:43:03 +01:00
|
|
|
reg->u.immconst_data[0], reg->u.immconst_data[1],
|
|
|
|
reg->u.immconst_data[2], reg->u.immconst_data[3]);
|
2012-09-04 20:15:09 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_DATA_RESOURCE:
|
|
|
|
case WINED3D_DATA_SAMPLER:
|
|
|
|
case WINED3D_DATA_UINT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "%u, %u, %u, %u",
|
2016-12-07 12:43:03 +01:00
|
|
|
reg->u.immconst_data[0], reg->u.immconst_data[1],
|
|
|
|
reg->u.immconst_data[2], reg->u.immconst_data[3]);
|
2012-09-04 20:15:09 +02:00
|
|
|
break;
|
|
|
|
default:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
|
2012-09-04 20:15:09 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "<unhandled immconst_type %#x>", reg->immconst_type);
|
2010-01-17 21:31:32 +01:00
|
|
|
break;
|
|
|
|
}
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, ")");
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
2010-10-08 13:12:15 +02:00
|
|
|
else if (reg->type != WINED3DSPR_RASTOUT
|
|
|
|
&& reg->type != WINED3DSPR_MISCTYPE
|
|
|
|
&& reg->type != WINED3DSPR_NULL)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
if (offset != ~0u)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "[");
|
2012-10-14 18:40:36 +02:00
|
|
|
if (reg->idx[0].rel_addr)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_dump_src_param(buffer, reg->idx[0].rel_addr, shader_version);
|
|
|
|
shader_addline(buffer, " + ");
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "%u]", offset);
|
2012-10-12 13:03:58 +02:00
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
if (reg->idx[1].offset != ~0u)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "[");
|
2012-10-14 18:40:36 +02:00
|
|
|
if (reg->idx[1].rel_addr)
|
2012-10-12 13:03:58 +02:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_dump_src_param(buffer, reg->idx[1].rel_addr, shader_version);
|
|
|
|
shader_addline(buffer, " + ");
|
2012-10-12 13:03:58 +02:00
|
|
|
}
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "%u]", reg->idx[1].offset);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
}
|
2016-12-07 12:43:03 +01:00
|
|
|
|
|
|
|
if (reg->type == WINED3DSPR_FUNCTIONPOINTER)
|
|
|
|
shader_addline(buffer, "[%u]", reg->u.fp_body_idx);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
static void shader_dump_dst_param(struct wined3d_string_buffer *buffer,
|
|
|
|
const struct wined3d_shader_dst_param *param, const struct wined3d_shader_version *shader_version)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
DWORD write_mask = param->write_mask;
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_dump_register(buffer, ¶m->reg, shader_version);
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2010-10-08 13:12:15 +02:00
|
|
|
if (write_mask && write_mask != WINED3DSP_WRITEMASK_ALL)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2014-05-02 12:50:16 +02:00
|
|
|
static const char write_mask_chars[] = "xyzw";
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, ".");
|
|
|
|
if (write_mask & WINED3DSP_WRITEMASK_0)
|
|
|
|
shader_addline(buffer, "%c", write_mask_chars[0]);
|
|
|
|
if (write_mask & WINED3DSP_WRITEMASK_1)
|
|
|
|
shader_addline(buffer, "%c", write_mask_chars[1]);
|
|
|
|
if (write_mask & WINED3DSP_WRITEMASK_2)
|
|
|
|
shader_addline(buffer, "%c", write_mask_chars[2]);
|
|
|
|
if (write_mask & WINED3DSP_WRITEMASK_3)
|
|
|
|
shader_addline(buffer, "%c", write_mask_chars[3]);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
static void shader_dump_src_param(struct wined3d_string_buffer *buffer,
|
|
|
|
const struct wined3d_shader_src_param *param, const struct wined3d_shader_version *shader_version)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2011-11-14 21:11:42 +01:00
|
|
|
enum wined3d_shader_src_modifier src_modifier = param->modifiers;
|
2010-01-17 21:31:32 +01:00
|
|
|
DWORD swizzle = param->swizzle;
|
|
|
|
|
|
|
|
if (src_modifier == WINED3DSPSM_NEG
|
|
|
|
|| src_modifier == WINED3DSPSM_BIASNEG
|
|
|
|
|| src_modifier == WINED3DSPSM_SIGNNEG
|
|
|
|
|| src_modifier == WINED3DSPSM_X2NEG
|
|
|
|
|| src_modifier == WINED3DSPSM_ABSNEG)
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "-");
|
2010-01-17 21:31:32 +01:00
|
|
|
else if (src_modifier == WINED3DSPSM_COMP)
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "1-");
|
2010-01-17 21:31:32 +01:00
|
|
|
else if (src_modifier == WINED3DSPSM_NOT)
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "!");
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG)
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "abs(");
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_dump_register(buffer, ¶m->reg, shader_version);
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2015-06-02 01:46:37 +02:00
|
|
|
switch (src_modifier)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2015-06-02 01:46:37 +02:00
|
|
|
case WINED3DSPSM_NONE: break;
|
|
|
|
case WINED3DSPSM_NEG: break;
|
|
|
|
case WINED3DSPSM_NOT: break;
|
2016-02-12 18:52:21 +01:00
|
|
|
case WINED3DSPSM_BIAS: shader_addline(buffer, "_bias"); break;
|
|
|
|
case WINED3DSPSM_BIASNEG: shader_addline(buffer, "_bias"); break;
|
|
|
|
case WINED3DSPSM_SIGN: shader_addline(buffer, "_bx2"); break;
|
|
|
|
case WINED3DSPSM_SIGNNEG: shader_addline(buffer, "_bx2"); break;
|
2015-06-02 01:46:37 +02:00
|
|
|
case WINED3DSPSM_COMP: break;
|
2016-02-12 18:52:21 +01:00
|
|
|
case WINED3DSPSM_X2: shader_addline(buffer, "_x2"); break;
|
|
|
|
case WINED3DSPSM_X2NEG: shader_addline(buffer, "_x2"); break;
|
|
|
|
case WINED3DSPSM_DZ: shader_addline(buffer, "_dz"); break;
|
|
|
|
case WINED3DSPSM_DW: shader_addline(buffer, "_dw"); break;
|
|
|
|
case WINED3DSPSM_ABSNEG: shader_addline(buffer, ")"); break;
|
|
|
|
case WINED3DSPSM_ABS: shader_addline(buffer, ")"); break;
|
|
|
|
default: shader_addline(buffer, "_unknown_modifier(%#x)", src_modifier);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (swizzle != WINED3DSP_NOSWIZZLE)
|
|
|
|
{
|
2014-05-02 12:50:16 +02:00
|
|
|
static const char swizzle_chars[] = "xyzw";
|
2010-01-17 21:31:32 +01:00
|
|
|
DWORD swizzle_x = swizzle & 0x03;
|
|
|
|
DWORD swizzle_y = (swizzle >> 2) & 0x03;
|
|
|
|
DWORD swizzle_z = (swizzle >> 4) & 0x03;
|
|
|
|
DWORD swizzle_w = (swizzle >> 6) & 0x03;
|
|
|
|
|
|
|
|
if (swizzle_x == swizzle_y
|
|
|
|
&& swizzle_x == swizzle_z
|
|
|
|
&& swizzle_x == swizzle_w)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, ".%c", swizzle_chars[swizzle_x]);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, ".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y],
|
2010-01-17 21:31:32 +01:00
|
|
|
swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-20 13:45:56 +02:00
|
|
|
/* 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)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2011-05-16 23:01:23 +02:00
|
|
|
struct wined3d_device *device = shader->device;
|
2011-03-30 20:49:24 +02:00
|
|
|
const struct wined3d_shader_frontend *fe = shader->frontend;
|
|
|
|
void *fe_data = shader->frontend_data;
|
2010-01-17 21:31:32 +01:00
|
|
|
struct wined3d_shader_version shader_version;
|
2016-12-07 12:42:58 +01:00
|
|
|
struct wined3d_shader_parser_state state;
|
2010-01-17 21:31:32 +01:00
|
|
|
struct wined3d_shader_instruction ins;
|
2010-10-29 12:25:15 +02:00
|
|
|
struct wined3d_shader_tex_mx tex_mx;
|
2010-01-17 21:31:32 +01:00
|
|
|
struct wined3d_shader_context ctx;
|
2017-02-21 00:40:03 +01:00
|
|
|
const DWORD *ptr;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
/* Initialize current parsing state. */
|
2010-10-29 12:25:15 +02:00
|
|
|
tex_mx.current_row = 0;
|
2016-12-07 12:42:58 +01:00
|
|
|
state.current_loop_depth = 0;
|
|
|
|
state.current_loop_reg = 0;
|
|
|
|
state.in_subroutine = FALSE;
|
2010-10-29 12:25:15 +02:00
|
|
|
|
2010-12-14 18:31:01 +01:00
|
|
|
ctx.shader = shader;
|
2010-01-24 21:16:13 +01:00
|
|
|
ctx.gl_info = &device->adapter->gl_info;
|
2010-01-17 21:31:32 +01:00
|
|
|
ctx.reg_maps = reg_maps;
|
|
|
|
ctx.buffer = buffer;
|
2010-10-29 12:25:15 +02:00
|
|
|
ctx.tex_mx = &tex_mx;
|
2016-12-07 12:42:58 +01:00
|
|
|
ctx.state = &state;
|
2010-01-17 21:31:32 +01:00
|
|
|
ctx.backend_data = backend_ctx;
|
|
|
|
ins.ctx = &ctx;
|
|
|
|
|
|
|
|
fe->shader_read_header(fe_data, &ptr, &shader_version);
|
2017-05-20 13:45:56 +02:00
|
|
|
if (start)
|
|
|
|
ptr = start;
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2017-05-20 13:45:56 +02:00
|
|
|
while (!fe->shader_is_end(fe_data, &ptr) && ptr != end)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
/* Read opcode. */
|
2012-09-04 20:15:08 +02:00
|
|
|
fe->shader_read_instruction(fe_data, &ptr, &ins);
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
/* Unknown opcode and its parameters. */
|
|
|
|
if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
|
|
|
|
{
|
2017-03-08 10:53:05 +01:00
|
|
|
WARN("Encountered unrecognised or invalid instruction.\n");
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2010-04-07 21:04:49 +02:00
|
|
|
if (ins.predicate)
|
|
|
|
FIXME("Predicates not implemented.\n");
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
/* Call appropriate function for output target */
|
|
|
|
device->shader_backend->shader_handle_instruction(&ins);
|
|
|
|
}
|
2017-03-08 10:53:05 +01:00
|
|
|
|
|
|
|
return WINED3D_OK;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
static void shader_dump_ins_modifiers(struct wined3d_string_buffer *buffer,
|
|
|
|
const struct wined3d_shader_dst_param *dst)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
DWORD mmask = dst->modifiers;
|
|
|
|
|
|
|
|
switch (dst->shift)
|
|
|
|
{
|
|
|
|
case 0: break;
|
2016-02-12 18:52:21 +01:00
|
|
|
case 13: shader_addline(buffer, "_d8"); break;
|
|
|
|
case 14: shader_addline(buffer, "_d4"); break;
|
|
|
|
case 15: shader_addline(buffer, "_d2"); break;
|
|
|
|
case 1: shader_addline(buffer, "_x2"); break;
|
|
|
|
case 2: shader_addline(buffer, "_x4"); break;
|
|
|
|
case 3: shader_addline(buffer, "_x8"); break;
|
|
|
|
default: shader_addline(buffer, "_unhandled_shift(%d)", dst->shift); break;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
if (mmask & WINED3DSPDM_SATURATE) shader_addline(buffer, "_sat");
|
|
|
|
if (mmask & WINED3DSPDM_PARTIALPRECISION) shader_addline(buffer, "_pp");
|
|
|
|
if (mmask & WINED3DSPDM_MSAMPCENTROID) shader_addline(buffer, "_centroid");
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID);
|
2016-10-07 16:01:22 +02:00
|
|
|
if (mmask) FIXME("Unrecognised modifier %#x.\n", mmask);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
static void shader_dump_primitive_type(struct wined3d_string_buffer *buffer,
|
2017-05-15 12:05:47 +02:00
|
|
|
const struct wined3d_shader_primitive_type *primitive_type)
|
2012-09-17 12:22:24 +02:00
|
|
|
{
|
2017-05-15 12:05:47 +02:00
|
|
|
switch (primitive_type->type)
|
2012-09-17 12:22:24 +02:00
|
|
|
{
|
|
|
|
case WINED3D_PT_UNDEFINED:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "undefined");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_PT_POINTLIST:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "pointlist");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_PT_LINELIST:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "linelist");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_PT_LINESTRIP:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "linestrip");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_PT_TRIANGLELIST:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "trianglelist");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_PT_TRIANGLESTRIP:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "trianglestrip");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_PT_TRIANGLEFAN:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "trianglefan");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_PT_LINELIST_ADJ:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "linelist_adj");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_PT_LINESTRIP_ADJ:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "linestrip_adj");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_PT_TRIANGLELIST_ADJ:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "trianglelist_adj");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_PT_TRIANGLESTRIP_ADJ:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "trianglestrip_adj");
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
2017-05-15 12:05:47 +02:00
|
|
|
case WINED3D_PT_PATCH:
|
|
|
|
shader_addline(buffer, "patch%u", primitive_type->patch_vertex_count);
|
|
|
|
break;
|
2012-09-17 12:22:24 +02:00
|
|
|
default:
|
2017-05-15 12:05:47 +02:00
|
|
|
shader_addline(buffer, "<unrecognized_primitive_type %#x>", primitive_type->type);
|
2012-09-17 12:22:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
static void shader_dump_interpolation_mode(struct wined3d_string_buffer *buffer,
|
|
|
|
enum wined3d_shader_interpolation_mode interpolation_mode)
|
2016-02-02 11:32:27 +01:00
|
|
|
{
|
|
|
|
switch (interpolation_mode)
|
|
|
|
{
|
|
|
|
case WINED3DSIM_CONSTANT:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "constant");
|
2016-02-02 11:32:27 +01:00
|
|
|
break;
|
|
|
|
case WINED3DSIM_LINEAR:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "linear");
|
2016-02-02 11:32:27 +01:00
|
|
|
break;
|
|
|
|
case WINED3DSIM_LINEAR_CENTROID:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "linear centroid");
|
2016-02-02 11:32:27 +01:00
|
|
|
break;
|
|
|
|
case WINED3DSIM_LINEAR_NOPERSPECTIVE:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "linear noperspective");
|
2016-02-02 11:32:27 +01:00
|
|
|
break;
|
|
|
|
case WINED3DSIM_LINEAR_SAMPLE:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "linear sample");
|
2016-02-02 11:32:27 +01:00
|
|
|
break;
|
|
|
|
case WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "linear noperspective centroid");
|
2016-02-02 11:32:27 +01:00
|
|
|
break;
|
|
|
|
case WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "linear noperspective sample");
|
2016-02-02 11:32:27 +01:00
|
|
|
break;
|
|
|
|
default:
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(buffer, "<unrecognized_interpolation_mode %#x>", interpolation_mode);
|
2016-02-02 11:32:27 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-21 00:40:03 +01:00
|
|
|
static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
struct wined3d_shader_version shader_version;
|
2016-02-12 18:52:21 +01:00
|
|
|
struct wined3d_string_buffer buffer;
|
2010-01-17 21:31:32 +01:00
|
|
|
const char *type_prefix;
|
2016-02-12 18:52:21 +01:00
|
|
|
const char *p, *q;
|
2017-02-21 00:40:03 +01:00
|
|
|
const DWORD *ptr;
|
2010-01-17 21:31:32 +01:00
|
|
|
DWORD i;
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
if (!string_buffer_init(&buffer))
|
|
|
|
{
|
|
|
|
ERR("Failed to initialize string buffer.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
fe->shader_read_header(fe_data, &ptr, &shader_version);
|
|
|
|
|
2017-02-21 00:40:03 +01:00
|
|
|
TRACE("Parsing %p.\n", ptr);
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
switch (shader_version.type)
|
|
|
|
{
|
|
|
|
case WINED3D_SHADER_TYPE_VERTEX:
|
|
|
|
type_prefix = "vs";
|
|
|
|
break;
|
|
|
|
|
2016-03-29 12:14:53 +02:00
|
|
|
case WINED3D_SHADER_TYPE_HULL:
|
|
|
|
type_prefix = "hs";
|
|
|
|
break;
|
|
|
|
|
2016-04-01 11:21:41 +02:00
|
|
|
case WINED3D_SHADER_TYPE_DOMAIN:
|
|
|
|
type_prefix = "ds";
|
|
|
|
break;
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
case WINED3D_SHADER_TYPE_GEOMETRY:
|
|
|
|
type_prefix = "gs";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_TYPE_PIXEL:
|
|
|
|
type_prefix = "ps";
|
|
|
|
break;
|
|
|
|
|
2016-06-21 13:09:56 +02:00
|
|
|
case WINED3D_SHADER_TYPE_COMPUTE:
|
|
|
|
type_prefix = "cs";
|
|
|
|
break;
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled shader type %#x.\n", shader_version.type);
|
|
|
|
type_prefix = "unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s_%u_%u\n", type_prefix, shader_version.major, shader_version.minor);
|
2010-01-17 21:31:32 +01:00
|
|
|
|
|
|
|
while (!fe->shader_is_end(fe_data, &ptr))
|
|
|
|
{
|
|
|
|
struct wined3d_shader_instruction ins;
|
|
|
|
|
2012-09-04 20:15:08 +02:00
|
|
|
fe->shader_read_instruction(fe_data, &ptr, &ins);
|
2010-01-17 21:31:32 +01:00
|
|
|
if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
WARN("Skipping unrecognized instruction.\n");
|
|
|
|
shader_addline(&buffer, "<unrecognized instruction>\n");
|
2010-01-17 21:31:32 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-03-25 19:53:38 +01:00
|
|
|
if (ins.handler_idx == WINED3DSIH_DCL || ins.handler_idx == WINED3DSIH_DCL_UAV_TYPED)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2017-03-08 12:07:19 +01:00
|
|
|
shader_dump_decl_usage(&buffer, &ins.declaration.semantic, ins.flags, &shader_version);
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_dump_ins_modifiers(&buffer, &ins.declaration.semantic.reg);
|
|
|
|
shader_addline(&buffer, " ");
|
|
|
|
shader_dump_dst_param(&buffer, &ins.declaration.semantic.reg, &shader_version);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
2012-10-01 22:48:13 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_CONSTANT_BUFFER)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
|
|
|
|
shader_dump_src_param(&buffer, &ins.declaration.src, &shader_version);
|
|
|
|
shader_addline(&buffer, ", %s",
|
|
|
|
ins.flags & WINED3DSI_INDEXED_DYNAMIC ? "dynamicIndexed" : "immediateIndexed");
|
2012-10-01 22:48:13 +02:00
|
|
|
}
|
2016-12-07 12:43:03 +01:00
|
|
|
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);
|
|
|
|
}
|
2016-02-02 11:32:34 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_GLOBAL_FLAGS)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
|
|
|
|
shader_dump_global_flags(&buffer, ins.flags);
|
2016-02-02 11:32:34 +01:00
|
|
|
}
|
2016-03-31 10:54:42 +02:00
|
|
|
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);
|
|
|
|
}
|
2016-02-01 00:14:36 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s {\n", shader_opcode_names[ins.handler_idx]);
|
2016-07-08 12:12:32 +02:00
|
|
|
for (i = 0; i < ins.declaration.icb->vec4_count; ++i)
|
2016-02-01 00:14:36 +01:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, " {0x%08x, 0x%08x, 0x%08x, 0x%08x},\n",
|
2016-02-01 00:14:36 +01:00
|
|
|
ins.declaration.icb->data[4 * i + 0],
|
|
|
|
ins.declaration.icb->data[4 * i + 1],
|
|
|
|
ins.declaration.icb->data[4 * i + 2],
|
|
|
|
ins.declaration.icb->data[4 * i + 3]);
|
|
|
|
}
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "}");
|
2016-02-01 00:14:36 +01:00
|
|
|
}
|
2017-03-10 09:10:57 +01:00
|
|
|
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);
|
|
|
|
}
|
2016-06-23 12:08:00 +02:00
|
|
|
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);
|
|
|
|
}
|
2016-02-02 11:32:27 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PS)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
|
|
|
|
shader_dump_interpolation_mode(&buffer, ins.flags);
|
|
|
|
shader_addline(&buffer, " ");
|
|
|
|
shader_dump_dst_param(&buffer, &ins.declaration.dst, &shader_version);
|
2016-02-02 11:32:27 +01:00
|
|
|
}
|
2016-02-02 11:32:31 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PS_SGV
|
2016-02-02 11:32:32 +01:00
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_INPUT_SGV
|
2016-02-02 11:32:33 +01:00
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_INPUT_SIV
|
2016-02-02 11:32:32 +01:00
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_OUTPUT_SIV)
|
2016-02-02 11:32:29 +01:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
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, ", ");
|
2017-05-20 13:46:01 +02:00
|
|
|
shader_dump_shader_input_sysval_semantic(&buffer, ins.declaration.register_semantic.sysval_semantic);
|
2016-02-02 11:32:30 +01:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PS_SIV)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
|
|
|
|
shader_dump_interpolation_mode(&buffer, ins.flags);
|
|
|
|
shader_addline(&buffer, " ");
|
|
|
|
shader_dump_dst_param(&buffer, &ins.declaration.register_semantic.reg, &shader_version);
|
|
|
|
shader_addline(&buffer, ", ");
|
2017-05-20 13:46:01 +02:00
|
|
|
shader_dump_shader_input_sysval_semantic(&buffer, ins.declaration.register_semantic.sysval_semantic);
|
2016-02-02 11:32:29 +01:00
|
|
|
}
|
2016-02-02 11:32:28 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT
|
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_OUTPUT)
|
2016-02-01 00:14:37 +01:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
|
|
|
|
shader_dump_dst_param(&buffer, &ins.declaration.dst, &shader_version);
|
2016-02-01 00:14:37 +01:00
|
|
|
}
|
2012-09-17 12:22:25 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PRIMITIVE
|
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_OUTPUT_TOPOLOGY)
|
2012-09-17 12:22:24 +02:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
|
2017-05-15 12:05:47 +02:00
|
|
|
shader_dump_primitive_type(&buffer, &ins.declaration.primitive_type);
|
2012-09-17 12:22:24 +02:00
|
|
|
}
|
2016-12-07 12:43:03 +01:00
|
|
|
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);
|
|
|
|
}
|
2017-01-29 13:37:23 +01:00
|
|
|
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);
|
|
|
|
}
|
2016-03-25 19:53:36 +01:00
|
|
|
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);
|
|
|
|
}
|
2016-02-01 00:14:38 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_SAMPLER)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s ", shader_opcode_names[ins.handler_idx]);
|
|
|
|
shader_dump_dst_param(&buffer, &ins.declaration.dst, &shader_version);
|
2016-02-01 00:14:38 +01:00
|
|
|
if (ins.flags == WINED3DSI_SAMPLER_COMPARISON_MODE)
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, ", comparisonMode");
|
2016-02-01 00:14:38 +01:00
|
|
|
}
|
2016-01-26 00:34:04 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DCL_TEMPS
|
2017-04-21 10:59:52 +02:00
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_GS_INSTANCES
|
2016-03-31 10:54:40 +02:00
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
|
2017-03-02 15:11:47 +01:00
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT
|
2016-03-29 12:14:58 +02:00
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT
|
2017-04-21 10:59:52 +02:00
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT
|
|
|
|
|| ins.handler_idx == WINED3DSIH_DCL_VERTICES_OUT)
|
2012-09-17 12:22:23 +02:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s %u", shader_opcode_names[ins.handler_idx], ins.declaration.count);
|
2012-09-17 12:22:23 +02:00
|
|
|
}
|
2016-04-01 11:21:37 +02:00
|
|
|
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);
|
|
|
|
}
|
2016-04-01 11:21:38 +02:00
|
|
|
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);
|
|
|
|
}
|
2016-04-01 11:21:39 +02:00
|
|
|
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);
|
|
|
|
}
|
2016-06-22 11:37:30 +02:00
|
|
|
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);
|
|
|
|
}
|
2016-06-22 11:37:31 +02:00
|
|
|
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);
|
|
|
|
}
|
2016-06-21 13:10:02 +02:00
|
|
|
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);
|
|
|
|
}
|
2016-11-30 12:47:31 +01:00
|
|
|
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);
|
|
|
|
}
|
2016-11-30 12:47:32 +01:00
|
|
|
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);
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEF)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "def c%u = %.8e, %.8e, %.8e, %.8e", shader_get_float_offset(ins.dst[0].reg.type,
|
2012-10-14 18:40:36 +02:00
|
|
|
ins.dst[0].reg.idx[0].offset),
|
2016-12-07 12:43:03 +01:00
|
|
|
*(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]);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEFI)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "defi i%u = %d, %d, %d, %d", ins.dst[0].reg.idx[0].offset,
|
2016-12-07 12:43:03 +01:00
|
|
|
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]);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEFB)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "defb b%u = %s",
|
2016-12-07 12:43:03 +01:00
|
|
|
ins.dst[0].reg.idx[0].offset, ins.src[0].reg.u.immconst_data[0] ? "true" : "false");
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ins.predicate)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "(");
|
|
|
|
shader_dump_src_param(&buffer, ins.predicate, &shader_version);
|
|
|
|
shader_addline(&buffer, ") ");
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PixWin marks instructions with the coissue flag with a '+' */
|
2016-02-12 18:52:21 +01:00
|
|
|
if (ins.coissue)
|
|
|
|
shader_addline(&buffer, "+");
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "%s", shader_opcode_names[ins.handler_idx]);
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2016-05-25 10:51:21 +02:00
|
|
|
if (ins.handler_idx == WINED3DSIH_BREAKP
|
2017-05-18 15:19:54 +02:00
|
|
|
|| ins.handler_idx == WINED3DSIH_CONTINUEP
|
2017-04-11 13:30:35 +02:00
|
|
|
|| ins.handler_idx == WINED3DSIH_IF
|
2017-11-22 13:11:11 +01:00
|
|
|
|| ins.handler_idx == WINED3DSIH_RETP
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXKILL)
|
2016-05-25 10:51:20 +02:00
|
|
|
{
|
|
|
|
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
|
2010-01-17 21:31:32 +01:00
|
|
|
|| ins.handler_idx == WINED3DSIH_BREAKC)
|
|
|
|
{
|
|
|
|
switch (ins.flags)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
case WINED3D_SHADER_REL_OP_GT: shader_addline(&buffer, "_gt"); break;
|
|
|
|
case WINED3D_SHADER_REL_OP_EQ: shader_addline(&buffer, "_eq"); break;
|
|
|
|
case WINED3D_SHADER_REL_OP_GE: shader_addline(&buffer, "_ge"); break;
|
|
|
|
case WINED3D_SHADER_REL_OP_LT: shader_addline(&buffer, "_lt"); break;
|
|
|
|
case WINED3D_SHADER_REL_OP_NE: shader_addline(&buffer, "_ne"); break;
|
|
|
|
case WINED3D_SHADER_REL_OP_LE: shader_addline(&buffer, "_le"); break;
|
|
|
|
default: shader_addline(&buffer, "_(%u)", ins.flags);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_TEX
|
|
|
|
&& shader_version.major >= 2
|
|
|
|
&& (ins.flags & WINED3DSI_TEXLD_PROJECT))
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "p");
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
2016-07-15 11:16:22 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_RESINFO && ins.flags)
|
2016-01-17 22:48:48 +01:00
|
|
|
{
|
|
|
|
switch (ins.flags)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
case WINED3DSI_RESINFO_RCP_FLOAT: shader_addline(&buffer, "_rcpFloat"); break;
|
|
|
|
case WINED3DSI_RESINFO_UINT: shader_addline(&buffer, "_uint"); break;
|
|
|
|
default: shader_addline(&buffer, "_unrecognized(%#x)", ins.flags);
|
2016-01-17 22:48:48 +01:00
|
|
|
}
|
|
|
|
}
|
2016-07-15 11:16:22 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2016-11-30 12:47:30 +01:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_SYNC)
|
|
|
|
{
|
|
|
|
shader_dump_sync_flags(&buffer, ins.flags);
|
|
|
|
}
|
2018-04-26 14:53:20 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
shader_dump_precise_flags(&buffer, ins.flags);
|
|
|
|
}
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2016-03-08 17:46:50 +01:00
|
|
|
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);
|
|
|
|
|
2010-10-08 13:12:14 +02:00
|
|
|
for (i = 0; i < ins.dst_count; ++i)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_dump_ins_modifiers(&buffer, &ins.dst[i]);
|
|
|
|
shader_addline(&buffer, !i ? " " : ", ");
|
|
|
|
shader_dump_dst_param(&buffer, &ins.dst[i], &shader_version);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Other source tokens */
|
|
|
|
for (i = ins.dst_count; i < (ins.dst_count + ins.src_count); ++i)
|
|
|
|
{
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, !i ? " " : ", ");
|
|
|
|
shader_dump_src_param(&buffer, &ins.src[i - ins.dst_count], &shader_version);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
}
|
2016-02-12 18:52:21 +01:00
|
|
|
shader_addline(&buffer, "\n");
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
2016-02-12 18:52:21 +01:00
|
|
|
|
|
|
|
for (p = buffer.buffer; *p; p = q)
|
|
|
|
{
|
|
|
|
if (!(q = strstr(p, "\n")))
|
|
|
|
q = p + strlen(p);
|
|
|
|
else
|
|
|
|
++q;
|
|
|
|
TRACE(" %.*s", (int)(q - p), p);
|
|
|
|
}
|
|
|
|
|
|
|
|
string_buffer_free(&buffer);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2011-03-30 20:49:26 +02:00
|
|
|
static void shader_cleanup(struct wined3d_shader *shader)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
2017-05-18 15:19:58 +02:00
|
|
|
if (shader->reg_maps.shader_version.type == WINED3D_SHADER_TYPE_HULL)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(shader->u.hs.phases.control_point);
|
|
|
|
heap_free(shader->u.hs.phases.fork);
|
|
|
|
heap_free(shader->u.hs.phases.join);
|
2017-05-18 15:19:58 +02:00
|
|
|
}
|
|
|
|
else if (shader->reg_maps.shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(shader->u.gs.so_desc.elements);
|
2017-05-18 15:19:58 +02:00
|
|
|
}
|
2017-03-28 12:00:06 +02:00
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(shader->patch_constant_signature.elements);
|
|
|
|
heap_free(shader->output_signature.elements);
|
|
|
|
heap_free(shader->input_signature.elements);
|
2011-03-30 20:49:24 +02:00
|
|
|
shader->device->shader_backend->shader_destroy(shader);
|
2016-07-04 12:26:30 +02:00
|
|
|
shader_cleanup_reg_maps(&shader->reg_maps);
|
2018-10-05 14:10:17 +02:00
|
|
|
heap_free(shader->byte_code);
|
2011-03-30 20:49:24 +02:00
|
|
|
shader_delete_constant_list(&shader->constantsF);
|
|
|
|
shader_delete_constant_list(&shader->constantsB);
|
|
|
|
shader_delete_constant_list(&shader->constantsI);
|
|
|
|
list_remove(&shader->shader_list_entry);
|
|
|
|
|
|
|
|
if (shader->frontend && shader->frontend_data)
|
|
|
|
shader->frontend->shader_free(shader->frontend_data);
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2012-10-24 21:23:37 +02:00
|
|
|
struct shader_none_priv
|
|
|
|
{
|
2013-04-25 12:16:47 +02:00
|
|
|
const struct wined3d_vertex_pipe_ops *vertex_pipe;
|
2012-10-24 21:23:37 +02:00
|
|
|
const struct fragment_pipeline *fragment_pipe;
|
2013-01-21 09:08:36 +01:00
|
|
|
BOOL ffp_proj_control;
|
2012-10-24 21:23:37 +02:00
|
|
|
};
|
|
|
|
|
2010-01-17 21:31:32 +01:00
|
|
|
static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {}
|
2017-04-13 11:21:44 +02:00
|
|
|
static void shader_none_precompile(void *shader_priv, struct wined3d_shader *shader) {}
|
2017-02-02 12:43:41 +01:00
|
|
|
static void shader_none_select_compute(void *shader_priv, struct wined3d_context *context,
|
|
|
|
const struct wined3d_state *state) {}
|
2011-05-16 23:01:23 +02:00
|
|
|
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) {}
|
2013-08-16 09:12:30 +02:00
|
|
|
static void shader_none_load_constants(void *shader_priv, struct wined3d_context *context,
|
2013-05-14 17:38:17 +02:00
|
|
|
const struct wined3d_state *state) {}
|
2011-03-30 20:49:26 +02:00
|
|
|
static void shader_none_destroy(struct wined3d_shader *shader) {}
|
2013-08-23 10:18:14 +02:00
|
|
|
static void shader_none_free_context_data(struct wined3d_context *context) {}
|
2015-06-02 16:39:46 +02:00
|
|
|
static void shader_none_init_context_state(struct wined3d_context *context) {}
|
2010-01-17 21:31:32 +01:00
|
|
|
|
2013-05-14 17:38:18 +02:00
|
|
|
/* Context activation is done by the caller. */
|
2013-08-16 09:12:30 +02:00
|
|
|
static void shader_none_select(void *shader_priv, struct wined3d_context *context,
|
2013-05-14 17:38:19 +02:00
|
|
|
const struct wined3d_state *state)
|
2012-11-04 19:51:33 +01:00
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
2013-05-14 17:38:19 +02:00
|
|
|
struct shader_none_priv *priv = shader_priv;
|
2012-11-04 19:51:33 +01:00
|
|
|
|
2013-05-14 17:38:19 +02:00
|
|
|
priv->vertex_pipe->vp_enable(gl_info, !use_vs(state));
|
|
|
|
priv->fragment_pipe->enable_extension(gl_info, !use_ps(state));
|
2012-11-04 19:51:33 +01:00
|
|
|
}
|
|
|
|
|
2013-05-14 17:38:18 +02:00
|
|
|
/* Context activation is done by the caller. */
|
2013-08-23 10:18:14 +02:00
|
|
|
static void shader_none_disable(void *shader_priv, struct wined3d_context *context)
|
2013-05-14 17:38:18 +02:00
|
|
|
{
|
|
|
|
struct shader_none_priv *priv = shader_priv;
|
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
|
|
|
|
|
|
|
priv->vertex_pipe->vp_enable(gl_info, FALSE);
|
|
|
|
priv->fragment_pipe->enable_extension(gl_info, FALSE);
|
2013-08-23 10:18:14 +02:00
|
|
|
|
2015-08-26 12:46:47 +02:00
|
|
|
context->shader_update_mask = (1u << WINED3D_SHADER_TYPE_PIXEL)
|
|
|
|
| (1u << WINED3D_SHADER_TYPE_VERTEX)
|
2016-03-29 12:14:53 +02:00
|
|
|
| (1u << WINED3D_SHADER_TYPE_GEOMETRY)
|
2016-04-01 11:21:41 +02:00
|
|
|
| (1u << WINED3D_SHADER_TYPE_HULL)
|
2016-06-21 13:09:56 +02:00
|
|
|
| (1u << WINED3D_SHADER_TYPE_DOMAIN)
|
|
|
|
| (1u << WINED3D_SHADER_TYPE_COMPUTE);
|
2013-05-14 17:38:18 +02:00
|
|
|
}
|
|
|
|
|
2013-04-25 12:16:47 +02:00
|
|
|
static HRESULT shader_none_alloc(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
|
|
|
|
const struct fragment_pipeline *fragment_pipe)
|
2012-10-24 21:23:37 +02:00
|
|
|
{
|
2013-01-21 09:08:36 +01:00
|
|
|
struct fragment_caps fragment_caps;
|
2013-04-25 12:16:47 +02:00
|
|
|
void *vertex_priv, *fragment_priv;
|
2012-10-24 21:23:37 +02:00
|
|
|
struct shader_none_priv *priv;
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(priv = heap_alloc(sizeof(*priv))))
|
2012-10-24 21:23:37 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2013-04-25 12:16:47 +02:00
|
|
|
if (!(vertex_priv = vertex_pipe->vp_alloc(&none_shader_backend, priv)))
|
|
|
|
{
|
|
|
|
ERR("Failed to initialize vertex pipe.\n");
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(priv);
|
2013-04-25 12:16:47 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2012-10-28 20:54:54 +01:00
|
|
|
if (!(fragment_priv = fragment_pipe->alloc_private(&none_shader_backend, priv)))
|
2012-10-24 21:23:37 +02:00
|
|
|
{
|
2012-10-28 20:54:54 +01:00
|
|
|
ERR("Failed to initialize fragment pipe.\n");
|
2013-04-25 12:16:47 +02:00
|
|
|
vertex_pipe->vp_free(device);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(priv);
|
2012-10-28 20:54:54 +01:00
|
|
|
return E_FAIL;
|
2012-10-24 21:23:37 +02:00
|
|
|
}
|
|
|
|
|
2013-04-25 12:16:47 +02:00
|
|
|
priv->vertex_pipe = vertex_pipe;
|
|
|
|
priv->fragment_pipe = fragment_pipe;
|
2013-01-21 09:08:36 +01:00
|
|
|
fragment_pipe->get_caps(&device->adapter->gl_info, &fragment_caps);
|
|
|
|
priv->ffp_proj_control = fragment_caps.wined3d_caps & WINED3D_FRAGMENT_CAP_PROJ_CONTROL;
|
2013-04-25 12:16:47 +02:00
|
|
|
|
|
|
|
device->vertex_priv = vertex_priv;
|
2012-10-28 20:54:54 +01:00
|
|
|
device->fragment_priv = fragment_priv;
|
2012-10-24 21:23:37 +02:00
|
|
|
device->shader_priv = priv;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shader_none_free(struct wined3d_device *device)
|
|
|
|
{
|
|
|
|
struct shader_none_priv *priv = device->shader_priv;
|
|
|
|
|
|
|
|
priv->fragment_pipe->free_private(device);
|
2013-04-25 12:16:47 +02:00
|
|
|
priv->vertex_pipe->vp_free(device);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(priv);
|
2012-10-24 21:23:37 +02:00
|
|
|
}
|
|
|
|
|
2013-08-23 10:18:14 +02:00
|
|
|
static BOOL shader_none_allocate_context_data(struct wined3d_context *context)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-02-03 18:18:00 +01:00
|
|
|
static void shader_none_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *caps)
|
2010-01-17 21:31:32 +01:00
|
|
|
{
|
|
|
|
/* Set the shader caps to 0 for the none shader backend */
|
2012-09-18 22:13:59 +02:00
|
|
|
caps->vs_version = 0;
|
2016-03-29 12:14:53 +02:00
|
|
|
caps->hs_version = 0;
|
2016-04-01 11:21:41 +02:00
|
|
|
caps->ds_version = 0;
|
2012-09-18 22:13:59 +02:00
|
|
|
caps->gs_version = 0;
|
|
|
|
caps->ps_version = 0;
|
2016-06-21 13:09:56 +02:00
|
|
|
caps->cs_version = 0;
|
2012-09-18 22:13:59 +02:00
|
|
|
caps->vs_uniform_count = 0;
|
|
|
|
caps->ps_uniform_count = 0;
|
|
|
|
caps->ps_1x_max_value = 0.0f;
|
2015-10-06 14:24:19 +02:00
|
|
|
caps->varying_count = 0;
|
2013-01-21 09:08:37 +01:00
|
|
|
caps->wined3d_caps = 0;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup)
|
|
|
|
{
|
2013-01-25 10:57:18 +01:00
|
|
|
/* We "support" every possible fixup, since we don't support any shader
|
|
|
|
* model, and will never have to actually sample a texture. */
|
|
|
|
return TRUE;
|
2010-01-17 21:31:32 +01:00
|
|
|
}
|
|
|
|
|
2012-10-24 21:23:37 +02:00
|
|
|
static BOOL shader_none_has_ffp_proj_control(void *shader_priv)
|
|
|
|
{
|
|
|
|
struct shader_none_priv *priv = shader_priv;
|
|
|
|
|
2013-01-21 09:08:36 +01:00
|
|
|
return priv->ffp_proj_control;
|
2012-10-24 21:23:37 +02:00
|
|
|
}
|
|
|
|
|
2011-05-04 22:18:46 +02:00
|
|
|
const struct wined3d_shader_backend_ops none_shader_backend =
|
|
|
|
{
|
2010-01-17 21:31:32 +01:00
|
|
|
shader_none_handle_instruction,
|
2017-04-13 11:21:44 +02:00
|
|
|
shader_none_precompile,
|
2010-01-17 21:31:32 +01:00
|
|
|
shader_none_select,
|
2017-02-02 12:43:41 +01:00
|
|
|
shader_none_select_compute,
|
2013-05-14 17:38:18 +02:00
|
|
|
shader_none_disable,
|
2010-01-17 21:31:32 +01:00
|
|
|
shader_none_update_float_vertex_constants,
|
|
|
|
shader_none_update_float_pixel_constants,
|
|
|
|
shader_none_load_constants,
|
|
|
|
shader_none_destroy,
|
|
|
|
shader_none_alloc,
|
|
|
|
shader_none_free,
|
2013-08-23 10:18:14 +02:00
|
|
|
shader_none_allocate_context_data,
|
|
|
|
shader_none_free_context_data,
|
2015-06-02 16:39:46 +02:00
|
|
|
shader_none_init_context_state,
|
2010-01-17 21:31:32 +01:00
|
|
|
shader_none_get_caps,
|
|
|
|
shader_none_color_fixup_supported,
|
2012-10-24 21:23:37 +02:00
|
|
|
shader_none_has_ffp_proj_control,
|
2010-01-17 21:31:32 +01:00
|
|
|
};
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2018-10-03 12:32:17 +02:00
|
|
|
static unsigned int shader_max_version_from_feature_level(enum wined3d_feature_level level)
|
|
|
|
{
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case WINED3D_FEATURE_LEVEL_11_1:
|
|
|
|
case WINED3D_FEATURE_LEVEL_11:
|
|
|
|
return 5;
|
|
|
|
case WINED3D_FEATURE_LEVEL_10_1:
|
|
|
|
case WINED3D_FEATURE_LEVEL_10:
|
|
|
|
return 4;
|
|
|
|
case WINED3D_FEATURE_LEVEL_9_SM3:
|
|
|
|
return 3;
|
|
|
|
case WINED3D_FEATURE_LEVEL_9_SM2:
|
|
|
|
case WINED3D_FEATURE_LEVEL_9_1:
|
|
|
|
return 2;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT shader_set_function(struct wined3d_shader *shader, struct wined3d_device *device,
|
|
|
|
enum wined3d_shader_type type, unsigned int float_const_count)
|
2009-12-30 19:33:42 +01:00
|
|
|
{
|
2018-04-25 11:23:48 +02:00
|
|
|
const struct wined3d_d3d_info *d3d_info = &shader->device->adapter->d3d_info;
|
2011-03-30 20:49:24 +02:00
|
|
|
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
|
2018-10-03 12:32:17 +02:00
|
|
|
const struct wined3d_shader_version *version = ®_maps->shader_version;
|
2009-12-30 19:33:42 +01:00
|
|
|
const struct wined3d_shader_frontend *fe;
|
2011-10-25 16:58:47 +02:00
|
|
|
unsigned int backend_version;
|
2018-04-25 11:23:48 +02:00
|
|
|
HRESULT hr;
|
2009-12-30 19:33:42 +01:00
|
|
|
|
2018-10-03 12:32:17 +02:00
|
|
|
TRACE("shader %p, device %p, type %s, float_const_count %u.\n",
|
|
|
|
shader, device, debug_shader_type(type), float_const_count);
|
2015-07-02 17:41:32 +02:00
|
|
|
|
2017-02-23 08:10:25 +01:00
|
|
|
fe = shader->frontend;
|
|
|
|
if (!(shader->frontend_data = fe->shader_init(shader->function,
|
|
|
|
shader->functionLength, &shader->output_signature)))
|
2009-12-30 19:33:42 +01:00
|
|
|
{
|
|
|
|
FIXME("Failed to initialize frontend.\n");
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First pass: trace shader. */
|
2011-03-30 20:49:24 +02:00
|
|
|
if (TRACE_ON(d3d_shader))
|
2017-02-21 00:40:03 +01:00
|
|
|
shader_trace_init(fe, shader->frontend_data);
|
2009-12-30 19:33:42 +01:00
|
|
|
|
|
|
|
/* Second pass: figure out which registers are used, what the semantics are, etc. */
|
2018-04-25 11:23:48 +02:00
|
|
|
if (FAILED(hr = shader_get_registers_used(shader, float_const_count)))
|
2015-03-23 09:17:12 +01:00
|
|
|
return hr;
|
2009-12-30 19:33:42 +01:00
|
|
|
|
2018-10-03 12:32:17 +02:00
|
|
|
if (version->type != type)
|
2011-09-23 17:03:19 +02:00
|
|
|
{
|
2018-10-03 12:32:17 +02:00
|
|
|
WARN("Wrong shader type %s.\n", debug_shader_type(reg_maps->shader_version.type));
|
2011-09-23 17:03:19 +02:00
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
2018-10-03 12:32:17 +02:00
|
|
|
if (version->major > shader_max_version_from_feature_level(device->feature_level))
|
2011-09-23 17:03:19 +02:00
|
|
|
{
|
2018-10-03 12:32:17 +02:00
|
|
|
WARN("Shader version %u not supported by this device.\n", version->major);
|
2011-09-23 17:03:19 +02:00
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
2011-10-25 16:58:47 +02:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case WINED3D_SHADER_TYPE_VERTEX:
|
2013-04-25 15:20:27 +02:00
|
|
|
backend_version = d3d_info->limits.vs_version;
|
2012-09-18 22:13:59 +02:00
|
|
|
break;
|
2016-03-29 12:14:53 +02:00
|
|
|
case WINED3D_SHADER_TYPE_HULL:
|
|
|
|
backend_version = d3d_info->limits.hs_version;
|
|
|
|
break;
|
2016-04-01 11:21:41 +02:00
|
|
|
case WINED3D_SHADER_TYPE_DOMAIN:
|
|
|
|
backend_version = d3d_info->limits.ds_version;
|
|
|
|
break;
|
2012-09-18 22:13:59 +02:00
|
|
|
case WINED3D_SHADER_TYPE_GEOMETRY:
|
2013-04-25 15:20:27 +02:00
|
|
|
backend_version = d3d_info->limits.gs_version;
|
2011-10-25 16:58:47 +02:00
|
|
|
break;
|
|
|
|
case WINED3D_SHADER_TYPE_PIXEL:
|
2013-04-25 15:20:27 +02:00
|
|
|
backend_version = d3d_info->limits.ps_version;
|
2011-10-25 16:58:47 +02:00
|
|
|
break;
|
2016-06-21 13:09:56 +02:00
|
|
|
case WINED3D_SHADER_TYPE_COMPUTE:
|
|
|
|
backend_version = d3d_info->limits.cs_version;
|
|
|
|
break;
|
2011-10-25 16:58:47 +02:00
|
|
|
default:
|
2016-06-21 13:09:56 +02:00
|
|
|
FIXME("No backend version-checking for this shader type.\n");
|
2011-10-25 16:58:47 +02:00
|
|
|
backend_version = 0;
|
|
|
|
}
|
2018-10-03 12:32:17 +02:00
|
|
|
if (version->major > backend_version)
|
2011-10-25 16:58:47 +02:00
|
|
|
{
|
2018-10-03 12:32:17 +02:00
|
|
|
WARN("Shader version %u.%u not supported by the current shader backend.\n",
|
|
|
|
version->major, version->minor);
|
2011-10-25 16:58:47 +02:00
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
2011-09-23 17:03:19 +02:00
|
|
|
|
2018-10-03 12:32:16 +02:00
|
|
|
shader->load_local_constsF = shader->lconst_inf_or_nan;
|
|
|
|
|
2009-12-30 19:33:42 +01:00
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-03-30 20:49:25 +02:00
|
|
|
ULONG CDECL wined3d_shader_incref(struct wined3d_shader *shader)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2011-03-30 20:49:24 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&shader->ref);
|
2009-12-30 19:33:39 +01:00
|
|
|
|
|
|
|
TRACE("%p increasing refcount to %u.\n", shader, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2017-04-11 23:24:19 +02:00
|
|
|
static void wined3d_shader_init_object(void *object)
|
|
|
|
{
|
|
|
|
struct wined3d_shader *shader = object;
|
2017-04-13 11:21:44 +02:00
|
|
|
struct wined3d_device *device = shader->device;
|
|
|
|
|
|
|
|
list_add_head(&device->shaders, &shader->shader_list_entry);
|
2017-04-11 23:24:19 +02:00
|
|
|
|
2017-04-13 11:21:44 +02:00
|
|
|
device->shader_backend->shader_precompile(device->shader_priv, shader);
|
2017-04-11 23:24:19 +02:00
|
|
|
}
|
|
|
|
|
2016-06-22 10:39:01 +02:00
|
|
|
static void wined3d_shader_destroy_object(void *object)
|
|
|
|
{
|
|
|
|
shader_cleanup(object);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(object);
|
2016-06-22 10:39:01 +02:00
|
|
|
}
|
|
|
|
|
2011-03-30 20:49:25 +02:00
|
|
|
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2011-03-30 20:49:24 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&shader->ref);
|
2009-12-30 19:33:39 +01:00
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u.\n", shader, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
2011-03-30 20:49:24 +02:00
|
|
|
shader->parent_ops->wined3d_object_destroyed(shader->parent);
|
2017-02-16 00:58:53 +01:00
|
|
|
wined3d_cs_destroy_object(shader->device->cs, wined3d_shader_destroy_object, shader);
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2011-03-30 20:49:25 +02:00
|
|
|
void * CDECL wined3d_shader_get_parent(const struct wined3d_shader *shader)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2011-03-30 20:49:25 +02:00
|
|
|
TRACE("shader %p.\n", shader);
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2011-03-30 20:49:25 +02:00
|
|
|
return shader->parent;
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
|
2011-03-30 20:49:25 +02:00
|
|
|
HRESULT CDECL wined3d_shader_get_byte_code(const struct wined3d_shader *shader,
|
|
|
|
void *byte_code, UINT *byte_code_size)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2011-03-30 20:49:25 +02:00
|
|
|
TRACE("shader %p, byte_code %p, byte_code_size %p.\n", shader, byte_code, byte_code_size);
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2011-03-30 20:49:25 +02:00
|
|
|
if (!byte_code)
|
|
|
|
{
|
2018-10-05 14:10:17 +02:00
|
|
|
*byte_code_size = shader->byte_code_size;
|
2011-03-30 20:49:25 +02:00
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2018-10-05 14:10:17 +02:00
|
|
|
if (*byte_code_size < shader->byte_code_size)
|
2011-03-30 20:49:25 +02:00
|
|
|
{
|
|
|
|
/* MSDN claims (for d3d8 at least) that if *byte_code_size is smaller
|
|
|
|
* than the required size we should write the required size and
|
|
|
|
* return D3DERR_MOREDATA. That's not actually true. */
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
2018-10-05 14:10:17 +02:00
|
|
|
memcpy(byte_code, shader->byte_code, shader->byte_code_size);
|
2011-03-30 20:49:25 +02:00
|
|
|
|
|
|
|
return WINED3D_OK;
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
|
2011-03-30 20:49:25 +02:00
|
|
|
/* Set local constants for d3d8 shaders. */
|
|
|
|
HRESULT CDECL wined3d_shader_set_local_constants_float(struct wined3d_shader *shader,
|
2009-12-30 19:33:39 +01:00
|
|
|
UINT start_idx, const float *src_data, UINT count)
|
|
|
|
{
|
2011-03-30 20:49:25 +02:00
|
|
|
UINT end_idx = start_idx + count;
|
|
|
|
UINT i;
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2011-03-30 20:49:25 +02:00
|
|
|
TRACE("shader %p, start_idx %u, src_data %p, count %u.\n", shader, start_idx, src_data, count);
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2014-10-16 01:32:20 +02:00
|
|
|
if (end_idx > shader->limits->constant_float)
|
2011-03-30 20:49:25 +02:00
|
|
|
{
|
|
|
|
WARN("end_idx %u > float constants limit %u.\n",
|
2014-10-16 01:32:20 +02:00
|
|
|
end_idx, shader->limits->constant_float);
|
|
|
|
end_idx = shader->limits->constant_float;
|
2011-03-30 20:49:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = start_idx; i < end_idx; ++i)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
struct wined3d_shader_lconst *lconst;
|
2013-04-02 14:54:01 +02:00
|
|
|
float *value;
|
2018-02-14 07:39:59 +01:00
|
|
|
|
|
|
|
if (!(lconst = heap_alloc(sizeof(*lconst))))
|
2011-03-30 20:49:25 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
lconst->idx = i;
|
2013-04-02 14:54:01 +02:00
|
|
|
value = (float *)lconst->value;
|
|
|
|
memcpy(value, src_data + (i - start_idx) * 4 /* 4 components */, 4 * sizeof(float));
|
2011-03-30 20:49:25 +02:00
|
|
|
list_add_head(&shader->constantsF, &lconst->entry);
|
2013-04-02 14:54:01 +02:00
|
|
|
|
|
|
|
if (isinf(value[0]) || isnan(value[0]) || isinf(value[1]) || isnan(value[1])
|
|
|
|
|| isinf(value[2]) || isnan(value[2]) || isinf(value[3]) || isnan(value[3]))
|
|
|
|
{
|
|
|
|
shader->lconst_inf_or_nan = TRUE;
|
|
|
|
}
|
2011-03-30 20:49:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2017-10-18 00:25:09 +02:00
|
|
|
static void init_interpolation_compile_args(DWORD *interpolation_args,
|
2017-10-18 00:25:08 +02:00
|
|
|
const struct wined3d_shader *pixel_shader, const struct wined3d_gl_info *gl_info)
|
|
|
|
{
|
|
|
|
if (!needs_interpolation_qualifiers_for_shader_outputs(gl_info)
|
|
|
|
|| !pixel_shader || pixel_shader->reg_maps.shader_version.major < 4)
|
|
|
|
{
|
2017-10-18 00:25:09 +02:00
|
|
|
memset(interpolation_args, 0, sizeof(pixel_shader->u.ps.interpolation_mode));
|
2017-10-18 00:25:08 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(interpolation_args, pixel_shader->u.ps.interpolation_mode,
|
|
|
|
sizeof(pixel_shader->u.ps.interpolation_mode));
|
|
|
|
}
|
|
|
|
|
2013-09-11 11:31:17 +02:00
|
|
|
void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
|
2017-10-18 00:25:08 +02:00
|
|
|
WORD swizzle_map, struct vs_compile_args *args, const struct wined3d_context *context)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2017-10-18 00:25:08 +02:00
|
|
|
const struct wined3d_shader *geometry_shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
|
|
|
|
const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
|
|
|
|
const struct wined3d_shader *hull_shader = state->shader[WINED3D_SHADER_TYPE_HULL];
|
|
|
|
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
|
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
|
|
|
|
2011-12-19 21:00:09 +01:00
|
|
|
args->fog_src = state->render_states[WINED3D_RS_FOGTABLEMODE]
|
2011-12-21 21:35:00 +01:00
|
|
|
== WINED3D_FOG_NONE ? VS_FOG_COORD : VS_FOG_Z;
|
2011-12-19 21:00:09 +01:00
|
|
|
args->clip_enabled = state->render_states[WINED3D_RS_CLIPPING]
|
|
|
|
&& state->render_states[WINED3D_RS_CLIPPLANEENABLE];
|
2015-06-02 16:39:46 +02:00
|
|
|
args->point_size = state->gl_primitive_type == GL_POINTS;
|
|
|
|
args->per_vertex_point_size = shader->reg_maps.point_size;
|
2018-06-04 20:32:31 +02:00
|
|
|
args->next_shader_type = hull_shader ? WINED3D_SHADER_TYPE_HULL
|
2017-10-18 00:25:08 +02:00
|
|
|
: geometry_shader ? WINED3D_SHADER_TYPE_GEOMETRY : WINED3D_SHADER_TYPE_PIXEL;
|
2016-05-20 19:55:55 +02:00
|
|
|
if (shader->reg_maps.shader_version.major >= 4)
|
2017-10-18 00:25:08 +02:00
|
|
|
args->next_shader_input_count = hull_shader ? hull_shader->limits->packed_input
|
|
|
|
: geometry_shader ? geometry_shader->limits->packed_input
|
|
|
|
: pixel_shader ? pixel_shader->limits->packed_input : 0;
|
2016-05-20 19:55:55 +02:00
|
|
|
else
|
|
|
|
args->next_shader_input_count = 0;
|
2013-09-11 11:31:17 +02:00
|
|
|
args->swizzle_map = swizzle_map;
|
2015-11-12 23:06:50 +01:00
|
|
|
if (d3d_info->emulated_flatshading)
|
|
|
|
args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
|
|
|
|
else
|
2016-05-20 19:55:52 +02:00
|
|
|
args->flatshading = 0;
|
2017-10-18 00:25:08 +02:00
|
|
|
|
|
|
|
init_interpolation_compile_args(args->interpolation_mode,
|
|
|
|
args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL ? pixel_shader : NULL, gl_info);
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_idx2)
|
|
|
|
{
|
2012-01-18 21:46:22 +01:00
|
|
|
if (usage_idx1 != usage_idx2)
|
|
|
|
return FALSE;
|
|
|
|
if (usage1 == usage2)
|
|
|
|
return TRUE;
|
|
|
|
if (usage1 == WINED3D_DECL_USAGE_POSITION && usage2 == WINED3D_DECL_USAGE_POSITIONT)
|
|
|
|
return TRUE;
|
|
|
|
if (usage2 == WINED3D_DECL_USAGE_POSITION && usage1 == WINED3D_DECL_USAGE_POSITIONT)
|
|
|
|
return TRUE;
|
2009-12-30 19:33:39 +01:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-07-11 22:04:32 +02:00
|
|
|
BOOL vshader_get_input(const struct wined3d_shader *shader,
|
2010-09-20 12:04:27 +02:00
|
|
|
BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2011-03-30 20:49:24 +02:00
|
|
|
WORD map = shader->reg_maps.input_registers;
|
2009-12-30 19:33:39 +01:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; map; map >>= 1, ++i)
|
|
|
|
{
|
|
|
|
if (!(map & 1)) continue;
|
|
|
|
|
2011-03-29 19:21:50 +02:00
|
|
|
if (match_usage(shader->u.vs.attributes[i].usage,
|
|
|
|
shader->u.vs.attributes[i].usage_idx, usage_req, usage_idx_req))
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
|
|
|
*regnum = i;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-10-03 12:32:15 +02:00
|
|
|
static HRESULT shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
|
2018-10-03 12:32:18 +02:00
|
|
|
const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
|
2018-10-03 12:32:15 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
2018-10-05 14:10:19 +02:00
|
|
|
TRACE("byte_code %p, byte_code_size %#lx.\n", desc->byte_code, (long)desc->byte_code_size);
|
2018-10-03 12:32:15 +02:00
|
|
|
|
2018-10-03 12:32:22 +02:00
|
|
|
if (!desc->byte_code)
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
|
2018-10-03 12:32:15 +02:00
|
|
|
shader->ref = 1;
|
|
|
|
shader->device = device;
|
|
|
|
shader->parent = parent;
|
|
|
|
shader->parent_ops = parent_ops;
|
|
|
|
|
2015-03-23 09:17:14 +01:00
|
|
|
list_init(&shader->linked_programs);
|
2017-02-23 08:10:25 +01:00
|
|
|
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);
|
2017-04-11 23:24:19 +02:00
|
|
|
list_init(&shader->shader_list_entry);
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2018-10-05 14:10:19 +02:00
|
|
|
if (desc->byte_code_size == ~(size_t)0)
|
2017-02-23 08:10:25 +01:00
|
|
|
{
|
2018-10-05 14:10:19 +02:00
|
|
|
struct wined3d_shader_version shader_version;
|
|
|
|
const struct wined3d_shader_frontend *fe;
|
|
|
|
struct wined3d_shader_instruction ins;
|
|
|
|
const DWORD *ptr;
|
|
|
|
void *fe_data;
|
|
|
|
|
|
|
|
if (!(shader->frontend = shader_select_frontend(WINED3D_SHADER_BYTE_CODE_FORMAT_SM1)))
|
2017-02-23 08:10:25 +01:00
|
|
|
{
|
2018-10-05 14:10:19 +02:00
|
|
|
FIXME("Unable to find frontend for shader.\n");
|
|
|
|
hr = WINED3DERR_INVALIDCALL;
|
2018-10-05 14:10:17 +02:00
|
|
|
goto fail;
|
2017-02-23 08:10:25 +01:00
|
|
|
}
|
|
|
|
|
2018-10-05 14:10:19 +02:00
|
|
|
fe = shader->frontend;
|
|
|
|
if (!(fe_data = fe->shader_init(desc->byte_code, desc->byte_code_size, &shader->output_signature)))
|
2018-10-05 14:10:17 +02:00
|
|
|
{
|
2018-10-05 14:10:19 +02:00
|
|
|
WARN("Failed to initialise frontend data.\n");
|
|
|
|
hr = WINED3DERR_INVALIDCALL;
|
|
|
|
goto fail;
|
|
|
|
}
|
2018-10-05 14:10:17 +02:00
|
|
|
|
2018-10-05 14:10:19 +02:00
|
|
|
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);
|
2018-10-05 14:10:17 +02:00
|
|
|
|
2018-10-05 14:10:19 +02:00
|
|
|
fe->shader_free(fe_data);
|
2018-10-05 14:10:17 +02:00
|
|
|
|
2018-10-05 14:10:19 +02:00
|
|
|
shader->byte_code_size = (ptr - desc->byte_code) * sizeof(*ptr);
|
2018-10-05 14:10:17 +02:00
|
|
|
|
2018-10-05 14:10:19 +02:00
|
|
|
if (!(shader->byte_code = heap_alloc(shader->byte_code_size)))
|
2018-10-05 14:10:17 +02:00
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto fail;
|
|
|
|
}
|
2018-10-05 14:10:19 +02:00
|
|
|
memcpy(shader->byte_code, desc->byte_code, shader->byte_code_size);
|
2018-10-05 14:10:17 +02:00
|
|
|
|
|
|
|
shader->function = shader->byte_code;
|
|
|
|
shader->functionLength = shader->byte_code_size;
|
2015-03-23 09:17:12 +01:00
|
|
|
}
|
2018-10-05 14:10:19 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
enum wined3d_shader_byte_code_format format;
|
|
|
|
unsigned int max_version;
|
2015-03-23 09:17:12 +01:00
|
|
|
|
2018-10-05 14:10:19 +02:00
|
|
|
if (!(shader->byte_code = heap_alloc(desc->byte_code_size)))
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
memcpy(shader->byte_code, desc->byte_code, desc->byte_code_size);
|
|
|
|
shader->byte_code_size = desc->byte_code_size;
|
|
|
|
|
|
|
|
max_version = shader_max_version_from_feature_level(device->feature_level);
|
|
|
|
if (FAILED(hr = shader_extract_from_dxbc(shader, max_version, &format)))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!(shader->frontend = shader_select_frontend(format)))
|
|
|
|
{
|
|
|
|
FIXME("Unable to find frontend for shader.\n");
|
|
|
|
hr = WINED3DERR_INVALIDCALL;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
2018-10-05 14:10:17 +02:00
|
|
|
|
|
|
|
fail:
|
|
|
|
shader_cleanup(shader);
|
|
|
|
return hr;
|
2015-03-23 09:17:14 +01:00
|
|
|
}
|
|
|
|
|
2016-04-01 11:21:41 +02:00
|
|
|
static HRESULT vertex_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
|
2015-03-23 09:17:14 +01:00
|
|
|
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;
|
|
|
|
unsigned int i;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2018-10-03 12:32:18 +02:00
|
|
|
if (FAILED(hr = shader_init(shader, device, desc, parent, parent_ops)))
|
2015-03-23 09:17:14 +01:00
|
|
|
return hr;
|
|
|
|
|
2018-10-03 12:32:18 +02:00
|
|
|
if (FAILED(hr = shader_set_function(shader, device,
|
|
|
|
WINED3D_SHADER_TYPE_VERTEX, device->adapter->d3d_info.limits.vs_uniform_count)))
|
|
|
|
{
|
|
|
|
shader_cleanup(shader);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-03-23 09:17:13 +01:00
|
|
|
for (i = 0; i < shader->input_signature.element_count; ++i)
|
2015-03-23 09:17:12 +01:00
|
|
|
{
|
2015-03-23 09:17:13 +01:00
|
|
|
const struct wined3d_shader_signature_element *input = &shader->input_signature.elements[i];
|
|
|
|
|
2015-08-26 12:46:47 +02:00
|
|
|
if (!(reg_maps->input_registers & (1u << input->register_idx)) || !input->semantic_name)
|
2015-03-23 09:17:12 +01:00
|
|
|
continue;
|
|
|
|
|
2015-03-23 09:17:13 +01:00
|
|
|
shader->u.vs.attributes[input->register_idx].usage =
|
|
|
|
shader_usage_from_semantic_name(input->semantic_name);
|
2015-04-08 04:56:33 +02:00
|
|
|
shader->u.vs.attributes[input->register_idx].usage_idx = input->semantic_idx;
|
2015-03-23 09:17:12 +01:00
|
|
|
}
|
|
|
|
|
2016-07-13 10:52:04 +02:00
|
|
|
if (reg_maps->usesrelconstF && !list_empty(&shader->constantsF))
|
|
|
|
shader->load_local_constsF = TRUE;
|
2009-12-30 19:33:39 +01:00
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2018-10-03 12:32:19 +02:00
|
|
|
static HRESULT geometry_shader_init_stream_output(struct wined3d_shader *shader,
|
|
|
|
const struct wined3d_stream_output_desc *so_desc)
|
2010-01-03 21:18:23 +01:00
|
|
|
{
|
2018-10-03 12:32:19 +02:00
|
|
|
const struct wined3d_shader_frontend *fe = shader->frontend;
|
2018-04-23 16:20:15 +02:00
|
|
|
struct wined3d_stream_output_element *elements;
|
2018-10-03 12:32:19 +02:00
|
|
|
struct wined3d_shader_version shader_version;
|
|
|
|
const DWORD *ptr;
|
|
|
|
void *fe_data;
|
2018-10-03 12:32:21 +02:00
|
|
|
HRESULT hr;
|
2017-03-28 12:00:06 +02:00
|
|
|
|
2018-10-03 12:32:19 +02:00
|
|
|
if (!so_desc)
|
|
|
|
return WINED3D_OK;
|
|
|
|
|
|
|
|
if (!(fe_data = fe->shader_init(shader->function, shader->functionLength, &shader->output_signature)))
|
2018-04-23 16:20:14 +02:00
|
|
|
{
|
2018-10-03 12:32:19 +02:00
|
|
|
WARN("Failed to initialise frontend data.\n");
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
fe->shader_read_header(fe_data, &ptr, &shader_version);
|
|
|
|
fe->shader_free(fe_data);
|
|
|
|
|
|
|
|
switch (shader_version.type)
|
|
|
|
{
|
|
|
|
case WINED3D_SHADER_TYPE_VERTEX:
|
2018-10-03 12:32:20 +02:00
|
|
|
case WINED3D_SHADER_TYPE_DOMAIN:
|
2018-10-03 12:32:19 +02:00
|
|
|
shader->function = NULL;
|
|
|
|
shader->functionLength = 0;
|
|
|
|
break;
|
|
|
|
case WINED3D_SHADER_TYPE_GEOMETRY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("Wrong shader type %s.\n", debug_shader_type(shader_version.type));
|
|
|
|
return E_INVALIDARG;
|
2018-04-23 16:20:14 +02:00
|
|
|
}
|
|
|
|
|
2018-10-03 12:32:21 +02:00
|
|
|
if (!shader->function)
|
|
|
|
{
|
|
|
|
shader->reg_maps.shader_version = shader_version;
|
|
|
|
shader->reg_maps.shader_version.type = WINED3D_SHADER_TYPE_GEOMETRY;
|
|
|
|
shader_set_limits(shader);
|
|
|
|
if (FAILED(hr = shader_scan_output_signature(shader)))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-10-03 12:32:19 +02:00
|
|
|
if (!(elements = heap_calloc(so_desc->element_count, sizeof(*elements))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (FAILED(hr = shader_init(shader, device, desc, parent, parent_ops)))
|
2017-03-28 12:00:06 +02:00
|
|
|
return hr;
|
|
|
|
|
2018-10-03 12:32:19 +02:00
|
|
|
if (FAILED(hr = geometry_shader_init_stream_output(shader, so_desc)))
|
|
|
|
goto fail;
|
|
|
|
|
2018-10-03 12:32:21 +02:00
|
|
|
if (shader->function
|
|
|
|
&& FAILED(hr = shader_set_function(shader, device, WINED3D_SHADER_TYPE_GEOMETRY, 0)))
|
|
|
|
goto fail;
|
2017-03-28 12:00:06 +02:00
|
|
|
|
|
|
|
return WINED3D_OK;
|
2018-10-03 12:32:19 +02:00
|
|
|
|
|
|
|
fail:
|
|
|
|
shader_cleanup(shader);
|
|
|
|
return hr;
|
2010-01-03 21:18:23 +01:00
|
|
|
}
|
|
|
|
|
2017-05-16 15:00:24 +02:00
|
|
|
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)
|
|
|
|
{
|
2017-10-18 00:25:08 +02:00
|
|
|
const struct wined3d_shader *geometry_shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
|
|
|
|
const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
|
2017-05-16 15:00:24 +02:00
|
|
|
const struct wined3d_shader *hull_shader = state->shader[WINED3D_SHADER_TYPE_HULL];
|
2017-10-18 00:25:08 +02:00
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
2017-05-16 15:00:24 +02:00
|
|
|
|
|
|
|
args->tessellator_output_primitive = hull_shader->u.hs.tessellator_output_primitive;
|
|
|
|
args->tessellator_partitioning = hull_shader->u.hs.tessellator_partitioning;
|
|
|
|
|
2017-10-18 00:25:08 +02:00
|
|
|
args->output_count = geometry_shader ? geometry_shader->limits->packed_input
|
|
|
|
: pixel_shader ? pixel_shader->limits->packed_input : shader->limits->packed_output;
|
|
|
|
args->next_shader_type = geometry_shader ? WINED3D_SHADER_TYPE_GEOMETRY : WINED3D_SHADER_TYPE_PIXEL;
|
2017-05-16 15:00:24 +02:00
|
|
|
|
|
|
|
args->render_offscreen = context->render_offscreen;
|
2017-05-17 15:42:33 +02:00
|
|
|
|
2017-10-18 00:25:08 +02:00
|
|
|
init_interpolation_compile_args(args->interpolation_mode,
|
|
|
|
args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL ? pixel_shader : NULL, gl_info);
|
|
|
|
|
2017-05-17 15:42:33 +02:00
|
|
|
args->padding = 0;
|
2017-05-16 15:00:24 +02:00
|
|
|
}
|
|
|
|
|
2016-05-20 19:55:56 +02:00
|
|
|
void find_gs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
|
2017-10-18 00:25:08 +02:00
|
|
|
struct gs_compile_args *args, const struct wined3d_context *context)
|
2016-05-20 19:55:56 +02:00
|
|
|
{
|
2017-10-18 00:25:08 +02:00
|
|
|
const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
|
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
|
|
|
|
|
|
|
args->output_count = pixel_shader ? pixel_shader->limits->packed_input : shader->limits->packed_output;
|
|
|
|
|
2018-04-23 16:20:16 +02:00
|
|
|
if (!(args->primitive_type = shader->u.gs.input_type))
|
|
|
|
args->primitive_type = d3d_primitive_type_from_gl(state->gl_primitive_type);
|
|
|
|
|
2017-10-18 00:25:08 +02:00
|
|
|
init_interpolation_compile_args(args->interpolation_mode, pixel_shader, gl_info);
|
2016-05-20 19:55:56 +02:00
|
|
|
}
|
|
|
|
|
2013-09-11 11:31:18 +02:00
|
|
|
void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
|
2015-10-06 14:24:21 +02:00
|
|
|
BOOL position_transformed, struct ps_compile_args *args, const struct wined3d_context *context)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2015-11-12 23:06:50 +01:00
|
|
|
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
|
2017-03-24 17:14:42 +01:00
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
2018-10-30 10:48:44 +01:00
|
|
|
struct wined3d_texture *texture;
|
2017-03-24 17:14:42 +01:00
|
|
|
unsigned int i;
|
2009-12-30 19:33:39 +01:00
|
|
|
|
|
|
|
memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */
|
2016-02-08 00:04:37 +01:00
|
|
|
if (!gl_info->supported[ARB_FRAMEBUFFER_SRGB] && needs_srgb_write(context, state, state->fb))
|
2010-07-02 22:21:02 +02:00
|
|
|
{
|
2016-02-08 00:04:37 +01:00
|
|
|
static unsigned int warned = 0;
|
2012-08-15 00:38:23 +02:00
|
|
|
|
2016-02-08 00:04:37 +01:00
|
|
|
args->srgb_correction = 1;
|
|
|
|
if (state->render_states[WINED3D_RS_ALPHABLENDENABLE] && !warned++)
|
|
|
|
WARN("Blending into a sRGB render target with no GL_ARB_framebuffer_sRGB "
|
|
|
|
"support, expect rendering artifacts.\n");
|
2010-07-02 22:21:02 +02:00
|
|
|
}
|
|
|
|
|
2011-03-30 20:49:24 +02:00
|
|
|
if (shader->reg_maps.shader_version.major == 1
|
|
|
|
&& shader->reg_maps.shader_version.minor <= 3)
|
2010-09-30 12:16:16 +02:00
|
|
|
{
|
2014-10-16 01:32:20 +02:00
|
|
|
for (i = 0; i < shader->limits->sampler; ++i)
|
2010-09-30 12:16:16 +02:00
|
|
|
{
|
2012-01-09 22:16:51 +01:00
|
|
|
DWORD flags = state->texture_states[i][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS];
|
2011-12-12 20:25:17 +01:00
|
|
|
|
2012-01-09 22:16:52 +01:00
|
|
|
if (flags & WINED3D_TTFF_PROJECTED)
|
2011-12-12 20:25:17 +01:00
|
|
|
{
|
2012-01-09 22:16:52 +01:00
|
|
|
DWORD tex_transform = flags & ~WINED3D_TTFF_PROJECTED;
|
2011-12-27 17:28:57 +01:00
|
|
|
|
2013-10-09 22:57:45 +02:00
|
|
|
if (!state->shader[WINED3D_SHADER_TYPE_VERTEX])
|
2011-12-27 17:28:57 +01:00
|
|
|
{
|
2014-12-03 10:28:11 +01:00
|
|
|
enum wined3d_shader_resource_type resource_type = shader->reg_maps.resource_info[i].type;
|
2011-12-27 17:28:57 +01:00
|
|
|
unsigned int j;
|
2012-01-09 22:16:51 +01:00
|
|
|
unsigned int index = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
|
2012-01-23 22:34:47 +01:00
|
|
|
DWORD max_valid = WINED3D_TTFF_COUNT4;
|
|
|
|
|
2011-12-27 17:28:57 +01:00
|
|
|
for (j = 0; j < state->vertex_declaration->element_count; ++j)
|
|
|
|
{
|
|
|
|
struct wined3d_vertex_declaration_element *element =
|
|
|
|
&state->vertex_declaration->elements[j];
|
|
|
|
|
2012-01-18 21:46:22 +01:00
|
|
|
if (element->usage == WINED3D_DECL_USAGE_TEXCOORD
|
2011-12-27 17:28:57 +01:00
|
|
|
&& element->usage_idx == index)
|
|
|
|
{
|
|
|
|
max_valid = element->format->component_count;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-23 22:34:47 +01:00
|
|
|
if (!tex_transform || tex_transform > max_valid)
|
|
|
|
{
|
|
|
|
WARN("Fixing up projected texture transform flags from %#x to %#x.\n",
|
|
|
|
tex_transform, max_valid);
|
|
|
|
tex_transform = max_valid;
|
|
|
|
}
|
2014-12-03 10:28:09 +01:00
|
|
|
if ((resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_1D && tex_transform > WINED3D_TTFF_COUNT1)
|
|
|
|
|| (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_2D
|
|
|
|
&& tex_transform > WINED3D_TTFF_COUNT2)
|
|
|
|
|| (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_3D
|
|
|
|
&& tex_transform > WINED3D_TTFF_COUNT3))
|
2012-01-23 22:34:47 +01:00
|
|
|
tex_transform |= WINED3D_PSARGS_PROJECTED;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Application requested projected texture with unsuitable texture coordinates.\n");
|
|
|
|
WARN("(texture unit %u, transform flags %#x, sampler type %u).\n",
|
2014-12-03 10:28:09 +01:00
|
|
|
i, tex_transform, resource_type);
|
2012-01-23 22:34:47 +01:00
|
|
|
}
|
2011-12-27 17:28:57 +01:00
|
|
|
}
|
2011-12-12 20:25:17 +01:00
|
|
|
else
|
2012-01-23 22:34:47 +01:00
|
|
|
tex_transform = WINED3D_TTFF_COUNT4 | WINED3D_PSARGS_PROJECTED;
|
2012-01-09 22:16:50 +01:00
|
|
|
|
|
|
|
args->tex_transform |= tex_transform << i * WINED3D_PSARGS_TEXTRANSFORM_SHIFT;
|
2011-12-12 20:25:17 +01:00
|
|
|
}
|
2010-09-30 12:16:16 +02:00
|
|
|
}
|
|
|
|
}
|
2013-04-13 16:37:16 +02:00
|
|
|
if (shader->reg_maps.shader_version.major == 1
|
|
|
|
&& shader->reg_maps.shader_version.minor <= 4)
|
|
|
|
{
|
2014-10-16 01:32:20 +02:00
|
|
|
for (i = 0; i < shader->limits->sampler; ++i)
|
2013-04-13 16:37:16 +02:00
|
|
|
{
|
2014-12-03 10:28:11 +01:00
|
|
|
if (!shader->reg_maps.resource_info[i].type)
|
2013-04-13 16:37:16 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Treat unbound textures as 2D. The dummy texture will provide
|
|
|
|
* the proper sample value. The tex_types bitmap defaults to
|
|
|
|
* 2D because of the memset. */
|
2018-10-30 10:48:44 +01:00
|
|
|
if (!(texture = state->textures[i]))
|
2013-04-13 16:37:16 +02:00
|
|
|
continue;
|
|
|
|
|
2018-10-30 10:48:44 +01:00
|
|
|
switch (wined3d_texture_gl(texture)->target)
|
2013-04-13 16:37:16 +02:00
|
|
|
{
|
|
|
|
/* RECT textures are distinguished from 2D textures via np2_fixup */
|
2018-04-02 22:58:23 +02:00
|
|
|
default:
|
2013-04-13 16:37:16 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GL_TEXTURE_3D:
|
|
|
|
args->tex_types |= WINED3D_SHADER_TEX_3D << i * WINED3D_PSARGS_TEXTYPE_SHIFT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GL_TEXTURE_CUBE_MAP_ARB:
|
|
|
|
args->tex_types |= WINED3D_SHADER_TEX_CUBE << i * WINED3D_PSARGS_TEXTYPE_SHIFT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2017-03-24 17:14:42 +01:00
|
|
|
if (shader->reg_maps.shader_version.major >= 4)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2017-03-24 17:14:42 +01:00
|
|
|
/* 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)
|
2016-03-23 21:19:10 +01:00
|
|
|
args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
|
2017-03-24 17:14:42 +01:00
|
|
|
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;
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2017-03-24 17:14:42 +01:00
|
|
|
if (texture->resource.format_flags & WINED3DFMT_FLAG_SHADOW)
|
|
|
|
args->shadow |= 1u << i;
|
2010-05-17 11:14:48 +02:00
|
|
|
|
2017-03-24 17:14:42 +01:00
|
|
|
/* Flag samplers that need NP2 texcoord fixup. */
|
|
|
|
if (!(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT))
|
|
|
|
args->np2_fixup |= (1u << i);
|
|
|
|
}
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
2016-03-23 13:42:53 +01:00
|
|
|
|
2011-03-30 20:49:24 +02:00
|
|
|
if (shader->reg_maps.shader_version.major >= 3)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2013-09-11 11:31:18 +02:00
|
|
|
if (position_transformed)
|
2018-03-23 11:44:29 +01:00
|
|
|
args->vp_mode = WINED3D_VP_MODE_NONE;
|
2010-09-28 12:00:23 +02:00
|
|
|
else if (use_vs(state))
|
2018-03-23 11:44:29 +01:00
|
|
|
args->vp_mode = WINED3D_VP_MODE_SHADER;
|
2009-12-30 19:33:39 +01:00
|
|
|
else
|
2018-03-23 11:44:29 +01:00
|
|
|
args->vp_mode = WINED3D_VP_MODE_FF;
|
2013-05-30 10:05:34 +02:00
|
|
|
args->fog = WINED3D_FFP_PS_FOG_OFF;
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-23 11:44:29 +01:00
|
|
|
args->vp_mode = WINED3D_VP_MODE_SHADER;
|
2011-12-19 21:00:09 +01:00
|
|
|
if (state->render_states[WINED3D_RS_FOGENABLE])
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2011-12-19 21:00:09 +01:00
|
|
|
switch (state->render_states[WINED3D_RS_FOGTABLEMODE])
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2011-12-21 21:35:00 +01:00
|
|
|
case WINED3D_FOG_NONE:
|
2013-09-11 11:31:18 +02:00
|
|
|
if (position_transformed || use_vs(state))
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2013-05-30 10:05:34 +02:00
|
|
|
args->fog = WINED3D_FFP_PS_FOG_LINEAR;
|
2009-12-30 19:33:39 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-19 21:00:09 +01:00
|
|
|
switch (state->render_states[WINED3D_RS_FOGVERTEXMODE])
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2011-12-21 21:35:00 +01:00
|
|
|
case WINED3D_FOG_NONE: /* Fall through. */
|
2013-05-30 10:05:34 +02:00
|
|
|
case WINED3D_FOG_LINEAR: args->fog = WINED3D_FFP_PS_FOG_LINEAR; break;
|
|
|
|
case WINED3D_FOG_EXP: args->fog = WINED3D_FFP_PS_FOG_EXP; break;
|
|
|
|
case WINED3D_FOG_EXP2: args->fog = WINED3D_FFP_PS_FOG_EXP2; break;
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-05-30 10:05:34 +02:00
|
|
|
case WINED3D_FOG_LINEAR: args->fog = WINED3D_FFP_PS_FOG_LINEAR; break;
|
|
|
|
case WINED3D_FOG_EXP: args->fog = WINED3D_FFP_PS_FOG_EXP; break;
|
|
|
|
case WINED3D_FOG_EXP2: args->fog = WINED3D_FFP_PS_FOG_EXP2; break;
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-30 10:05:34 +02:00
|
|
|
args->fog = WINED3D_FFP_PS_FOG_OFF;
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
}
|
2015-06-05 00:37:29 +02:00
|
|
|
|
2015-10-06 14:24:21 +02:00
|
|
|
if (context->d3d_info->limits.varying_count < wined3d_max_compat_varyings(context->gl_info))
|
|
|
|
{
|
|
|
|
const struct wined3d_shader *vs = state->shader[WINED3D_SHADER_TYPE_VERTEX];
|
|
|
|
|
|
|
|
args->texcoords_initialized = 0;
|
|
|
|
for (i = 0; i < MAX_TEXTURES; ++i)
|
|
|
|
{
|
|
|
|
if (vs)
|
|
|
|
{
|
|
|
|
if (state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.output_registers & (1u << i))
|
|
|
|
args->texcoords_initialized |= 1u << i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const struct wined3d_stream_info *si = &context->stream_info;
|
|
|
|
unsigned int coord_idx = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
|
|
|
|
|
|
|
|
if ((state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX] >> WINED3D_FFP_TCI_SHIFT)
|
|
|
|
& WINED3D_FFP_TCI_MASK
|
|
|
|
|| (coord_idx < MAX_TEXTURES && (si->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx)))))
|
|
|
|
args->texcoords_initialized |= 1u << i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
args->texcoords_initialized = (1u << MAX_TEXTURES) - 1;
|
|
|
|
}
|
|
|
|
|
2015-06-05 00:37:29 +02:00
|
|
|
args->pointsprite = state->render_states[WINED3D_RS_POINTSPRITEENABLE]
|
|
|
|
&& state->gl_primitive_type == GL_POINTS;
|
2015-11-12 23:06:50 +01:00
|
|
|
|
2016-05-20 19:55:52 +02:00
|
|
|
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;
|
|
|
|
|
2015-11-12 23:06:50 +01:00
|
|
|
if (d3d_info->emulated_flatshading)
|
|
|
|
args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
|
2016-10-03 23:46:52 +02:00
|
|
|
|
2016-10-07 00:57:50 +02:00
|
|
|
args->render_offscreen = shader->reg_maps.vpos && gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]
|
|
|
|
? context->render_offscreen : 0;
|
2018-10-01 18:01:15 +02:00
|
|
|
|
|
|
|
if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
|
|
|
|
{
|
|
|
|
for (i = 0; i < ARRAY_SIZE(state->fb->render_targets); ++i)
|
|
|
|
{
|
|
|
|
struct wined3d_rendertarget_view *rtv = state->fb->render_targets[i];
|
|
|
|
if (rtv && rtv->format->id == WINED3DFMT_A8_UNORM)
|
|
|
|
args->rt_alpha_swizzle |= 1u << i;
|
|
|
|
}
|
|
|
|
}
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
|
2016-04-01 11:21:41 +02:00
|
|
|
static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
|
2014-11-04 08:47:45 +01:00
|
|
|
const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
|
|
|
unsigned int i, highest_reg_used = 0, num_regs_used = 0;
|
|
|
|
HRESULT hr;
|
2015-03-23 09:17:13 +01:00
|
|
|
|
2018-10-03 12:32:18 +02:00
|
|
|
if (FAILED(hr = shader_init(shader, device, desc, parent, parent_ops)))
|
2009-12-30 19:33:42 +01:00
|
|
|
return hr;
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2018-10-03 12:32:18 +02:00
|
|
|
if (FAILED(hr = shader_set_function(shader, device,
|
|
|
|
WINED3D_SHADER_TYPE_PIXEL, device->adapter->d3d_info.limits.ps_uniform_count)))
|
|
|
|
{
|
|
|
|
shader_cleanup(shader);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-12-30 19:33:39 +01:00
|
|
|
for (i = 0; i < MAX_REG_INPUT; ++i)
|
|
|
|
{
|
2017-02-21 00:40:06 +01:00
|
|
|
if (shader->u.ps.input_reg_used & (1u << i))
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
|
|
|
++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)
|
2016-05-20 19:55:54 +02:00
|
|
|
|| num_regs_used > (gl_info->limits.glsl_varyings / 4)
|
|
|
|
|| shader->reg_maps.shader_version.major >= 4)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
|
|
|
if (num_regs_used > (gl_info->limits.glsl_varyings / 4))
|
|
|
|
{
|
|
|
|
/* This happens with relative addressing. The input mapper function
|
|
|
|
* warns about this if the higher registers are declared too, so
|
|
|
|
* don't write a FIXME here */
|
|
|
|
WARN("More varying registers used than supported\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_REG_INPUT; ++i)
|
|
|
|
{
|
2011-03-29 19:21:52 +02:00
|
|
|
shader->u.ps.input_reg_map[i] = i;
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
|
2011-03-29 19:21:52 +02:00
|
|
|
shader->u.ps.declared_in_count = highest_reg_used + 1;
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-29 19:21:52 +02:00
|
|
|
shader->u.ps.declared_in_count = 0;
|
2009-12-30 19:33:39 +01:00
|
|
|
for (i = 0; i < MAX_REG_INPUT; ++i)
|
|
|
|
{
|
2017-02-21 00:40:06 +01:00
|
|
|
if (shader->u.ps.input_reg_used & (1u << i))
|
2011-03-29 19:21:52 +02:00
|
|
|
shader->u.ps.input_reg_map[i] = shader->u.ps.declared_in_count++;
|
|
|
|
else shader->u.ps.input_reg_map[i] = ~0U;
|
2009-12-30 19:33:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2014-12-03 10:28:09 +01:00
|
|
|
void pixelshader_update_resource_types(struct wined3d_shader *shader, WORD tex_types)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2013-04-13 16:37:16 +02:00
|
|
|
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
|
2014-12-03 10:28:11 +01:00
|
|
|
struct wined3d_shader_resource_info *resource_info = reg_maps->resource_info;
|
2009-12-30 19:33:39 +01:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (reg_maps->shader_version.major != 1) return;
|
|
|
|
|
2014-10-16 01:32:20 +02:00
|
|
|
for (i = 0; i < shader->limits->sampler; ++i)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
|
|
|
/* We don't sample from this sampler. */
|
2014-12-03 10:28:11 +01:00
|
|
|
if (!resource_info[i].type)
|
2014-12-03 10:28:09 +01:00
|
|
|
continue;
|
2009-12-30 19:33:39 +01:00
|
|
|
|
2013-04-13 16:37:16 +02:00
|
|
|
switch ((tex_types >> i * WINED3D_PSARGS_TEXTYPE_SHIFT) & WINED3D_PSARGS_TEXTYPE_MASK)
|
2009-12-30 19:33:39 +01:00
|
|
|
{
|
2013-04-13 16:37:16 +02:00
|
|
|
case WINED3D_SHADER_TEX_2D:
|
2014-12-03 10:28:11 +01:00
|
|
|
resource_info[i].type = WINED3D_SHADER_RESOURCE_TEXTURE_2D;
|
2009-12-30 19:33:39 +01:00
|
|
|
break;
|
|
|
|
|
2013-04-13 16:37:16 +02:00
|
|
|
case WINED3D_SHADER_TEX_3D:
|
2014-12-03 10:28:11 +01:00
|
|
|
resource_info[i].type = WINED3D_SHADER_RESOURCE_TEXTURE_3D;
|
2009-12-30 19:33:39 +01:00
|
|
|
break;
|
|
|
|
|
2013-04-13 16:37:16 +02:00
|
|
|
case WINED3D_SHADER_TEX_CUBE:
|
2014-12-03 10:28:11 +01:00
|
|
|
resource_info[i].type = WINED3D_SHADER_RESOURCE_TEXTURE_CUBE;
|
2009-12-30 19:33:39 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-05-10 21:18:47 +02:00
|
|
|
|
2016-06-21 13:09:57 +02:00
|
|
|
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;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("device %p, desc %p, parent %p, parent_ops %p, shader %p.\n",
|
|
|
|
device, desc, parent, parent_ops, shader);
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2016-06-21 13:09:57 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2018-10-03 12:32:18 +02:00
|
|
|
if (FAILED(hr = shader_init(object, device, desc, parent, parent_ops)))
|
2016-06-21 13:09:57 +02:00
|
|
|
{
|
|
|
|
WARN("Failed to initialize compute shader, hr %#x.\n", hr);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(object);
|
2016-06-21 13:09:57 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-10-03 12:32:18 +02:00
|
|
|
if (FAILED(hr = shader_set_function(object, device, WINED3D_SHADER_TYPE_COMPUTE, 0)))
|
|
|
|
{
|
|
|
|
shader_cleanup(object);
|
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-03-26 08:38:49 +02:00
|
|
|
wined3d_cs_init_object(device->cs, wined3d_shader_init_object, object);
|
|
|
|
|
2016-06-21 13:09:57 +02:00
|
|
|
TRACE("Created compute shader %p.\n", object);
|
|
|
|
*shader = object;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2016-04-01 11:21:41 +02:00
|
|
|
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);
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2016-04-01 11:21:41 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2018-10-03 12:32:18 +02:00
|
|
|
if (FAILED(hr = shader_init(object, device, desc, parent, parent_ops)))
|
2016-04-01 11:21:41 +02:00
|
|
|
{
|
|
|
|
WARN("Failed to initialize domain shader, hr %#x.\n", hr);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(object);
|
2016-04-01 11:21:41 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-10-03 12:32:18 +02:00
|
|
|
if (FAILED(hr = shader_set_function(object, device, WINED3D_SHADER_TYPE_DOMAIN, 0)))
|
|
|
|
{
|
|
|
|
shader_cleanup(object);
|
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-03-26 08:38:49 +02:00
|
|
|
wined3d_cs_init_object(device->cs, wined3d_shader_init_object, object);
|
|
|
|
|
2016-04-01 11:21:41 +02:00
|
|
|
TRACE("Created domain shader %p.\n", object);
|
|
|
|
*shader = object;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
HRESULT CDECL wined3d_shader_create_gs(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
|
2017-03-23 12:15:48 +01:00
|
|
|
const struct wined3d_stream_output_desc *so_desc, void *parent,
|
|
|
|
const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
|
2011-05-10 21:18:47 +02:00
|
|
|
{
|
|
|
|
struct wined3d_shader *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-03-23 12:15:48 +01:00
|
|
|
TRACE("device %p, desc %p, so_desc %p, parent %p, parent_ops %p, shader %p.\n",
|
|
|
|
device, desc, so_desc, parent, parent_ops, shader);
|
2011-05-10 21:18:47 +02:00
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2011-05-10 21:18:47 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2017-03-28 12:00:06 +02:00
|
|
|
if (FAILED(hr = geometry_shader_init(object, device, desc, so_desc, parent, parent_ops)))
|
2011-05-10 21:18:47 +02:00
|
|
|
{
|
|
|
|
WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(object);
|
2011-05-10 21:18:47 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-03-26 08:38:49 +02:00
|
|
|
wined3d_cs_init_object(device->cs, wined3d_shader_init_object, object);
|
|
|
|
|
2011-05-10 21:18:47 +02:00
|
|
|
TRACE("Created geometry shader %p.\n", object);
|
|
|
|
*shader = object;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2016-03-29 12:14:54 +02:00
|
|
|
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);
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2016-03-29 12:14:54 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2018-10-03 12:32:18 +02:00
|
|
|
if (FAILED(hr = shader_init(object, device, desc, parent, parent_ops)))
|
2016-03-29 12:14:54 +02:00
|
|
|
{
|
|
|
|
WARN("Failed to initialize hull shader, hr %#x.\n", hr);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(object);
|
2016-03-29 12:14:54 +02:00
|
|
|
return hr;
|
2018-10-03 12:32:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = shader_set_function(object, device, WINED3D_SHADER_TYPE_HULL, 0)))
|
|
|
|
{
|
|
|
|
shader_cleanup(object);
|
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
2016-03-29 12:14:54 +02:00
|
|
|
}
|
|
|
|
|
2018-03-26 08:38:49 +02:00
|
|
|
wined3d_cs_init_object(device->cs, wined3d_shader_init_object, object);
|
|
|
|
|
2016-03-29 12:14:54 +02:00
|
|
|
TRACE("Created hull shader %p.\n", object);
|
|
|
|
*shader = object;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
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)
|
2011-05-10 21:18:47 +02:00
|
|
|
{
|
|
|
|
struct wined3d_shader *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
TRACE("device %p, desc %p, parent %p, parent_ops %p, shader %p.\n",
|
|
|
|
device, desc, parent, parent_ops, shader);
|
2011-05-10 21:18:47 +02:00
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2011-05-10 21:18:47 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2016-04-01 11:21:41 +02:00
|
|
|
if (FAILED(hr = pixel_shader_init(object, device, desc, parent, parent_ops)))
|
2011-05-10 21:18:47 +02:00
|
|
|
{
|
|
|
|
WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(object);
|
2011-05-10 21:18:47 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-03-26 08:38:49 +02:00
|
|
|
wined3d_cs_init_object(device->cs, wined3d_shader_init_object, object);
|
|
|
|
|
2011-05-10 21:18:47 +02:00
|
|
|
TRACE("Created pixel shader %p.\n", object);
|
|
|
|
*shader = object;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
HRESULT CDECL wined3d_shader_create_vs(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
|
|
|
|
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
|
2011-05-10 21:18:47 +02:00
|
|
|
{
|
|
|
|
struct wined3d_shader *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
TRACE("device %p, desc %p, parent %p, parent_ops %p, shader %p.\n",
|
|
|
|
device, desc, parent, parent_ops, shader);
|
2011-05-10 21:18:47 +02:00
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2011-05-10 21:18:47 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2016-04-01 11:21:41 +02:00
|
|
|
if (FAILED(hr = vertex_shader_init(object, device, desc, parent, parent_ops)))
|
2011-05-10 21:18:47 +02:00
|
|
|
{
|
|
|
|
WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(object);
|
2011-05-10 21:18:47 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-03-26 08:38:49 +02:00
|
|
|
wined3d_cs_init_object(device->cs, wined3d_shader_init_object, object);
|
|
|
|
|
2011-05-10 21:18:47 +02:00
|
|
|
TRACE("Created vertex shader %p.\n", object);
|
|
|
|
*shader = object;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|