2018-05-29 03:50:32 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2002-2003 Jason Edmeades
|
|
|
|
* Copyright 2002-2003 Raphael Junqueira
|
|
|
|
* Copyright 2004 Christian Costa
|
|
|
|
* Copyright 2005 Oliver Stieber
|
|
|
|
* Copyright 2006 Ivan Gyurdiev
|
|
|
|
* Copyright 2007-2008, 2013 Stefan Dösinger for CodeWeavers
|
|
|
|
* Copyright 2009-2011 Henri Verbeet for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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 "vkd3d_shader_private.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2021-02-18 02:24:02 -08:00
|
|
|
#include <math.h>
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
static const char * const shader_opcode_names[] =
|
|
|
|
{
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_ABS ] = "abs",
|
2024-01-21 21:26:16 -08:00
|
|
|
[VKD3DSIH_ACOS ] = "acos",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_ADD ] = "add",
|
|
|
|
[VKD3DSIH_AND ] = "and",
|
2024-01-21 21:26:16 -08:00
|
|
|
[VKD3DSIH_ASIN ] = "asin",
|
|
|
|
[VKD3DSIH_ATAN ] = "atan",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_ATOMIC_AND ] = "atomic_and",
|
|
|
|
[VKD3DSIH_ATOMIC_CMP_STORE ] = "atomic_cmp_store",
|
|
|
|
[VKD3DSIH_ATOMIC_IADD ] = "atomic_iadd",
|
|
|
|
[VKD3DSIH_ATOMIC_IMAX ] = "atomic_imax",
|
|
|
|
[VKD3DSIH_ATOMIC_IMIN ] = "atomic_imin",
|
|
|
|
[VKD3DSIH_ATOMIC_OR ] = "atomic_or",
|
|
|
|
[VKD3DSIH_ATOMIC_UMAX ] = "atomic_umax",
|
|
|
|
[VKD3DSIH_ATOMIC_UMIN ] = "atomic_umin",
|
|
|
|
[VKD3DSIH_ATOMIC_XOR ] = "atomic_xor",
|
|
|
|
[VKD3DSIH_BEM ] = "bem",
|
|
|
|
[VKD3DSIH_BFI ] = "bfi",
|
|
|
|
[VKD3DSIH_BFREV ] = "bfrev",
|
2024-01-04 06:55:51 -08:00
|
|
|
[VKD3DSIH_BRANCH ] = "branch",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_BREAK ] = "break",
|
|
|
|
[VKD3DSIH_BREAKC ] = "breakc",
|
|
|
|
[VKD3DSIH_BREAKP ] = "breakp",
|
|
|
|
[VKD3DSIH_BUFINFO ] = "bufinfo",
|
|
|
|
[VKD3DSIH_CALL ] = "call",
|
|
|
|
[VKD3DSIH_CALLNZ ] = "callnz",
|
|
|
|
[VKD3DSIH_CASE ] = "case",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_CHECK_ACCESS_FULLY_MAPPED ] = "check_access_fully_mapped",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_CMP ] = "cmp",
|
|
|
|
[VKD3DSIH_CND ] = "cnd",
|
|
|
|
[VKD3DSIH_CONTINUE ] = "continue",
|
|
|
|
[VKD3DSIH_CONTINUEP ] = "continuec",
|
|
|
|
[VKD3DSIH_COUNTBITS ] = "countbits",
|
|
|
|
[VKD3DSIH_CRS ] = "crs",
|
|
|
|
[VKD3DSIH_CUT ] = "cut",
|
|
|
|
[VKD3DSIH_CUT_STREAM ] = "cut_stream",
|
|
|
|
[VKD3DSIH_DADD ] = "dadd",
|
|
|
|
[VKD3DSIH_DCL ] = "dcl",
|
|
|
|
[VKD3DSIH_DCL_CONSTANT_BUFFER ] = "dcl_constantBuffer",
|
|
|
|
[VKD3DSIH_DCL_FUNCTION_BODY ] = "dcl_function_body",
|
|
|
|
[VKD3DSIH_DCL_FUNCTION_TABLE ] = "dcl_function_table",
|
|
|
|
[VKD3DSIH_DCL_GLOBAL_FLAGS ] = "dcl_globalFlags",
|
|
|
|
[VKD3DSIH_DCL_GS_INSTANCES ] = "dcl_gs_instances",
|
|
|
|
[VKD3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT] = "dcl_hs_fork_phase_instance_count",
|
|
|
|
[VKD3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT] = "dcl_hs_join_phase_instance_count",
|
|
|
|
[VKD3DSIH_DCL_HS_MAX_TESSFACTOR ] = "dcl_hs_max_tessfactor",
|
|
|
|
[VKD3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER ] = "dcl_immediateConstantBuffer",
|
|
|
|
[VKD3DSIH_DCL_INDEX_RANGE ] = "dcl_index_range",
|
|
|
|
[VKD3DSIH_DCL_INDEXABLE_TEMP ] = "dcl_indexableTemp",
|
|
|
|
[VKD3DSIH_DCL_INPUT ] = "dcl_input",
|
|
|
|
[VKD3DSIH_DCL_INPUT_CONTROL_POINT_COUNT ] = "dcl_input_control_point_count",
|
|
|
|
[VKD3DSIH_DCL_INPUT_PRIMITIVE ] = "dcl_inputPrimitive",
|
|
|
|
[VKD3DSIH_DCL_INPUT_PS ] = "dcl_input_ps",
|
|
|
|
[VKD3DSIH_DCL_INPUT_PS_SGV ] = "dcl_input_ps_sgv",
|
|
|
|
[VKD3DSIH_DCL_INPUT_PS_SIV ] = "dcl_input_ps_siv",
|
|
|
|
[VKD3DSIH_DCL_INPUT_SGV ] = "dcl_input_sgv",
|
|
|
|
[VKD3DSIH_DCL_INPUT_SIV ] = "dcl_input_siv",
|
|
|
|
[VKD3DSIH_DCL_INTERFACE ] = "dcl_interface",
|
|
|
|
[VKD3DSIH_DCL_OUTPUT ] = "dcl_output",
|
|
|
|
[VKD3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT ] = "dcl_output_control_point_count",
|
|
|
|
[VKD3DSIH_DCL_OUTPUT_SIV ] = "dcl_output_siv",
|
|
|
|
[VKD3DSIH_DCL_OUTPUT_TOPOLOGY ] = "dcl_outputTopology",
|
|
|
|
[VKD3DSIH_DCL_RESOURCE_RAW ] = "dcl_resource_raw",
|
|
|
|
[VKD3DSIH_DCL_RESOURCE_STRUCTURED ] = "dcl_resource_structured",
|
|
|
|
[VKD3DSIH_DCL_SAMPLER ] = "dcl_sampler",
|
|
|
|
[VKD3DSIH_DCL_STREAM ] = "dcl_stream",
|
|
|
|
[VKD3DSIH_DCL_TEMPS ] = "dcl_temps",
|
|
|
|
[VKD3DSIH_DCL_TESSELLATOR_DOMAIN ] = "dcl_tessellator_domain",
|
|
|
|
[VKD3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE] = "dcl_tessellator_output_primitive",
|
|
|
|
[VKD3DSIH_DCL_TESSELLATOR_PARTITIONING ] = "dcl_tessellator_partitioning",
|
|
|
|
[VKD3DSIH_DCL_TGSM_RAW ] = "dcl_tgsm_raw",
|
|
|
|
[VKD3DSIH_DCL_TGSM_STRUCTURED ] = "dcl_tgsm_structured",
|
|
|
|
[VKD3DSIH_DCL_THREAD_GROUP ] = "dcl_thread_group",
|
|
|
|
[VKD3DSIH_DCL_UAV_RAW ] = "dcl_uav_raw",
|
|
|
|
[VKD3DSIH_DCL_UAV_STRUCTURED ] = "dcl_uav_structured",
|
|
|
|
[VKD3DSIH_DCL_UAV_TYPED ] = "dcl_uav_typed",
|
|
|
|
[VKD3DSIH_DCL_VERTICES_OUT ] = "dcl_maxOutputVertexCount",
|
|
|
|
[VKD3DSIH_DDIV ] = "ddiv",
|
|
|
|
[VKD3DSIH_DEF ] = "def",
|
|
|
|
[VKD3DSIH_DEFAULT ] = "default",
|
|
|
|
[VKD3DSIH_DEFB ] = "defb",
|
|
|
|
[VKD3DSIH_DEFI ] = "defi",
|
2023-06-02 07:31:59 -07:00
|
|
|
[VKD3DSIH_DEQO ] = "deq",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_DFMA ] = "dfma",
|
2023-06-02 07:31:59 -07:00
|
|
|
[VKD3DSIH_DGEO ] = "dge",
|
2023-04-20 19:20:33 -07:00
|
|
|
[VKD3DSIH_DISCARD ] = "discard",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_DIV ] = "div",
|
|
|
|
[VKD3DSIH_DLT ] = "dlt",
|
|
|
|
[VKD3DSIH_DMAX ] = "dmax",
|
|
|
|
[VKD3DSIH_DMIN ] = "dmin",
|
|
|
|
[VKD3DSIH_DMOV ] = "dmov",
|
|
|
|
[VKD3DSIH_DMOVC ] = "dmovc",
|
|
|
|
[VKD3DSIH_DMUL ] = "dmul",
|
|
|
|
[VKD3DSIH_DNE ] = "dne",
|
|
|
|
[VKD3DSIH_DP2 ] = "dp2",
|
|
|
|
[VKD3DSIH_DP2ADD ] = "dp2add",
|
|
|
|
[VKD3DSIH_DP3 ] = "dp3",
|
|
|
|
[VKD3DSIH_DP4 ] = "dp4",
|
|
|
|
[VKD3DSIH_DRCP ] = "drcp",
|
|
|
|
[VKD3DSIH_DST ] = "dst",
|
|
|
|
[VKD3DSIH_DSX ] = "dsx",
|
|
|
|
[VKD3DSIH_DSX_COARSE ] = "deriv_rtx_coarse",
|
|
|
|
[VKD3DSIH_DSX_FINE ] = "deriv_rtx_fine",
|
|
|
|
[VKD3DSIH_DSY ] = "dsy",
|
|
|
|
[VKD3DSIH_DSY_COARSE ] = "deriv_rty_coarse",
|
|
|
|
[VKD3DSIH_DSY_FINE ] = "deriv_rty_fine",
|
|
|
|
[VKD3DSIH_DTOF ] = "dtof",
|
|
|
|
[VKD3DSIH_DTOI ] = "dtoi",
|
|
|
|
[VKD3DSIH_DTOU ] = "dtou",
|
|
|
|
[VKD3DSIH_ELSE ] = "else",
|
|
|
|
[VKD3DSIH_EMIT ] = "emit",
|
|
|
|
[VKD3DSIH_EMIT_STREAM ] = "emit_stream",
|
|
|
|
[VKD3DSIH_ENDIF ] = "endif",
|
|
|
|
[VKD3DSIH_ENDLOOP ] = "endloop",
|
|
|
|
[VKD3DSIH_ENDREP ] = "endrep",
|
|
|
|
[VKD3DSIH_ENDSWITCH ] = "endswitch",
|
2023-06-02 07:31:59 -07:00
|
|
|
[VKD3DSIH_EQO ] = "eq",
|
|
|
|
[VKD3DSIH_EQU ] = "eq_unord",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_EVAL_CENTROID ] = "eval_centroid",
|
|
|
|
[VKD3DSIH_EVAL_SAMPLE_INDEX ] = "eval_sample_index",
|
|
|
|
[VKD3DSIH_EXP ] = "exp",
|
|
|
|
[VKD3DSIH_EXPP ] = "expp",
|
|
|
|
[VKD3DSIH_F16TOF32 ] = "f16tof32",
|
|
|
|
[VKD3DSIH_F32TOF16 ] = "f32tof16",
|
|
|
|
[VKD3DSIH_FCALL ] = "fcall",
|
|
|
|
[VKD3DSIH_FIRSTBIT_HI ] = "firstbit_hi",
|
|
|
|
[VKD3DSIH_FIRSTBIT_LO ] = "firstbit_lo",
|
|
|
|
[VKD3DSIH_FIRSTBIT_SHI ] = "firstbit_shi",
|
|
|
|
[VKD3DSIH_FRC ] = "frc",
|
2023-05-24 19:06:22 -07:00
|
|
|
[VKD3DSIH_FREM ] = "frem",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_FTOD ] = "ftod",
|
|
|
|
[VKD3DSIH_FTOI ] = "ftoi",
|
|
|
|
[VKD3DSIH_FTOU ] = "ftou",
|
|
|
|
[VKD3DSIH_GATHER4 ] = "gather4",
|
|
|
|
[VKD3DSIH_GATHER4_C ] = "gather4_c",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_GATHER4_C_S ] = "gather4_c_s",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_GATHER4_PO ] = "gather4_po",
|
|
|
|
[VKD3DSIH_GATHER4_PO_C ] = "gather4_po_c",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_GATHER4_PO_C_S ] = "gather4_po_c_s",
|
|
|
|
[VKD3DSIH_GATHER4_PO_S ] = "gather4_po_s",
|
|
|
|
[VKD3DSIH_GATHER4_S ] = "gather4_s",
|
2023-06-02 07:31:59 -07:00
|
|
|
[VKD3DSIH_GEO ] = "ge",
|
|
|
|
[VKD3DSIH_GEU ] = "ge_unord",
|
2024-01-21 21:28:44 -08:00
|
|
|
[VKD3DSIH_HCOS ] = "hcos",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_HS_CONTROL_POINT_PHASE ] = "hs_control_point_phase",
|
|
|
|
[VKD3DSIH_HS_DECLS ] = "hs_decls",
|
|
|
|
[VKD3DSIH_HS_FORK_PHASE ] = "hs_fork_phase",
|
|
|
|
[VKD3DSIH_HS_JOIN_PHASE ] = "hs_join_phase",
|
2024-01-21 21:28:44 -08:00
|
|
|
[VKD3DSIH_HSIN ] = "hsin",
|
|
|
|
[VKD3DSIH_HTAN ] = "htan",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_IADD ] = "iadd",
|
|
|
|
[VKD3DSIH_IBFE ] = "ibfe",
|
2023-05-24 19:07:26 -07:00
|
|
|
[VKD3DSIH_IDIV ] = "idiv",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_IEQ ] = "ieq",
|
|
|
|
[VKD3DSIH_IF ] = "if",
|
|
|
|
[VKD3DSIH_IFC ] = "ifc",
|
|
|
|
[VKD3DSIH_IGE ] = "ige",
|
|
|
|
[VKD3DSIH_ILT ] = "ilt",
|
|
|
|
[VKD3DSIH_IMAD ] = "imad",
|
|
|
|
[VKD3DSIH_IMAX ] = "imax",
|
|
|
|
[VKD3DSIH_IMIN ] = "imin",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_ALLOC ] = "imm_atomic_alloc",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_AND ] = "imm_atomic_and",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_CMP_EXCH ] = "imm_atomic_cmp_exch",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_CONSUME ] = "imm_atomic_consume",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_EXCH ] = "imm_atomic_exch",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_IADD ] = "imm_atomic_iadd",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_IMAX ] = "imm_atomic_imax",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_IMIN ] = "imm_atomic_imin",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_OR ] = "imm_atomic_or",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_UMAX ] = "imm_atomic_umax",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_UMIN ] = "imm_atomic_umin",
|
|
|
|
[VKD3DSIH_IMM_ATOMIC_XOR ] = "imm_atomic_xor",
|
|
|
|
[VKD3DSIH_IMUL ] = "imul",
|
|
|
|
[VKD3DSIH_INE ] = "ine",
|
|
|
|
[VKD3DSIH_INEG ] = "ineg",
|
2024-01-21 21:18:27 -08:00
|
|
|
[VKD3DSIH_ISFINITE ] = "isfinite",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_ISHL ] = "ishl",
|
|
|
|
[VKD3DSIH_ISHR ] = "ishr",
|
2024-01-21 21:18:27 -08:00
|
|
|
[VKD3DSIH_ISINF ] = "isinf",
|
|
|
|
[VKD3DSIH_ISNAN ] = "isnan",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_ITOD ] = "itod",
|
|
|
|
[VKD3DSIH_ITOF ] = "itof",
|
2023-10-31 22:31:24 -07:00
|
|
|
[VKD3DSIH_ITOI ] = "itoi",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_LABEL ] = "label",
|
|
|
|
[VKD3DSIH_LD ] = "ld",
|
|
|
|
[VKD3DSIH_LD2DMS ] = "ld2dms",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_LD2DMS_S ] = "ld2dms_s",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_LD_RAW ] = "ld_raw",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_LD_RAW_S ] = "ld_raw_s",
|
|
|
|
[VKD3DSIH_LD_S ] = "ld_s",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_LD_STRUCTURED ] = "ld_structured",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_LD_STRUCTURED_S ] = "ld_structured_s",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_LD_UAV_TYPED ] = "ld_uav_typed",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_LD_UAV_TYPED_S ] = "ld_uav_typed_s",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_LIT ] = "lit",
|
|
|
|
[VKD3DSIH_LOD ] = "lod",
|
|
|
|
[VKD3DSIH_LOG ] = "log",
|
|
|
|
[VKD3DSIH_LOGP ] = "logp",
|
|
|
|
[VKD3DSIH_LOOP ] = "loop",
|
|
|
|
[VKD3DSIH_LRP ] = "lrp",
|
2023-06-02 07:31:59 -07:00
|
|
|
[VKD3DSIH_LTO ] = "lt",
|
|
|
|
[VKD3DSIH_LTU ] = "lt_unord",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_M3x2 ] = "m3x2",
|
|
|
|
[VKD3DSIH_M3x3 ] = "m3x3",
|
|
|
|
[VKD3DSIH_M3x4 ] = "m3x4",
|
|
|
|
[VKD3DSIH_M4x3 ] = "m4x3",
|
|
|
|
[VKD3DSIH_M4x4 ] = "m4x4",
|
|
|
|
[VKD3DSIH_MAD ] = "mad",
|
|
|
|
[VKD3DSIH_MAX ] = "max",
|
|
|
|
[VKD3DSIH_MIN ] = "min",
|
|
|
|
[VKD3DSIH_MOV ] = "mov",
|
|
|
|
[VKD3DSIH_MOVA ] = "mova",
|
|
|
|
[VKD3DSIH_MOVC ] = "movc",
|
2022-03-14 03:55:02 -07:00
|
|
|
[VKD3DSIH_MSAD ] = "msad",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_MUL ] = "mul",
|
2023-06-02 07:31:59 -07:00
|
|
|
[VKD3DSIH_NEO ] = "ne_ord",
|
|
|
|
[VKD3DSIH_NEU ] = "ne",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_NOP ] = "nop",
|
|
|
|
[VKD3DSIH_NOT ] = "not",
|
|
|
|
[VKD3DSIH_NRM ] = "nrm",
|
|
|
|
[VKD3DSIH_OR ] = "or",
|
2024-03-04 06:38:46 -08:00
|
|
|
[VKD3DSIH_ORD ] = "ord",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_PHASE ] = "phase",
|
2023-11-23 17:23:09 -08:00
|
|
|
[VKD3DSIH_PHI ] = "phi",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_POW ] = "pow",
|
2024-04-23 05:16:51 -07:00
|
|
|
[VKD3DSIH_QUAD_READ_ACROSS_D ] = "quad_read_across_d",
|
|
|
|
[VKD3DSIH_QUAD_READ_ACROSS_X ] = "quad_read_across_x",
|
|
|
|
[VKD3DSIH_QUAD_READ_ACROSS_Y ] = "quad_read_across_y",
|
2024-04-23 05:31:40 -07:00
|
|
|
[VKD3DSIH_QUAD_READ_LANE_AT ] = "quad_read_lane_at",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_RCP ] = "rcp",
|
|
|
|
[VKD3DSIH_REP ] = "rep",
|
|
|
|
[VKD3DSIH_RESINFO ] = "resinfo",
|
|
|
|
[VKD3DSIH_RET ] = "ret",
|
|
|
|
[VKD3DSIH_RETP ] = "retp",
|
|
|
|
[VKD3DSIH_ROUND_NE ] = "round_ne",
|
|
|
|
[VKD3DSIH_ROUND_NI ] = "round_ni",
|
|
|
|
[VKD3DSIH_ROUND_PI ] = "round_pi",
|
|
|
|
[VKD3DSIH_ROUND_Z ] = "round_z",
|
|
|
|
[VKD3DSIH_RSQ ] = "rsq",
|
|
|
|
[VKD3DSIH_SAMPLE ] = "sample",
|
|
|
|
[VKD3DSIH_SAMPLE_B ] = "sample_b",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_SAMPLE_B_CL_S ] = "sample_b_cl_s",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_SAMPLE_C ] = "sample_c",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_SAMPLE_C_CL_S ] = "sample_c_cl_s",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_SAMPLE_C_LZ ] = "sample_c_lz",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_SAMPLE_C_LZ_S ] = "sample_c_lz_s",
|
|
|
|
[VKD3DSIH_SAMPLE_CL_S ] = "sample_cl_s",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_SAMPLE_GRAD ] = "sample_d",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_SAMPLE_GRAD_CL_S ] = "sample_d_cl_s",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_SAMPLE_INFO ] = "sample_info",
|
|
|
|
[VKD3DSIH_SAMPLE_LOD ] = "sample_l",
|
2022-01-10 17:03:36 -08:00
|
|
|
[VKD3DSIH_SAMPLE_LOD_S ] = "sample_l_s",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_SAMPLE_POS ] = "sample_pos",
|
|
|
|
[VKD3DSIH_SETP ] = "setp",
|
|
|
|
[VKD3DSIH_SGE ] = "sge",
|
|
|
|
[VKD3DSIH_SGN ] = "sgn",
|
|
|
|
[VKD3DSIH_SINCOS ] = "sincos",
|
|
|
|
[VKD3DSIH_SLT ] = "slt",
|
|
|
|
[VKD3DSIH_SQRT ] = "sqrt",
|
|
|
|
[VKD3DSIH_STORE_RAW ] = "store_raw",
|
|
|
|
[VKD3DSIH_STORE_STRUCTURED ] = "store_structured",
|
|
|
|
[VKD3DSIH_STORE_UAV_TYPED ] = "store_uav_typed",
|
|
|
|
[VKD3DSIH_SUB ] = "sub",
|
|
|
|
[VKD3DSIH_SWAPC ] = "swapc",
|
|
|
|
[VKD3DSIH_SWITCH ] = "switch",
|
2023-12-11 21:58:08 -08:00
|
|
|
[VKD3DSIH_SWITCH_MONOLITHIC ] = "switch",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_SYNC ] = "sync",
|
2024-01-21 21:32:22 -08:00
|
|
|
[VKD3DSIH_TAN ] = "tan",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_TEX ] = "texld",
|
|
|
|
[VKD3DSIH_TEXBEM ] = "texbem",
|
|
|
|
[VKD3DSIH_TEXBEML ] = "texbeml",
|
|
|
|
[VKD3DSIH_TEXCOORD ] = "texcrd",
|
|
|
|
[VKD3DSIH_TEXDEPTH ] = "texdepth",
|
|
|
|
[VKD3DSIH_TEXDP3 ] = "texdp3",
|
|
|
|
[VKD3DSIH_TEXDP3TEX ] = "texdp3tex",
|
|
|
|
[VKD3DSIH_TEXKILL ] = "texkill",
|
|
|
|
[VKD3DSIH_TEXLDD ] = "texldd",
|
|
|
|
[VKD3DSIH_TEXLDL ] = "texldl",
|
|
|
|
[VKD3DSIH_TEXM3x2DEPTH ] = "texm3x2depth",
|
|
|
|
[VKD3DSIH_TEXM3x2PAD ] = "texm3x2pad",
|
|
|
|
[VKD3DSIH_TEXM3x2TEX ] = "texm3x2tex",
|
|
|
|
[VKD3DSIH_TEXM3x3 ] = "texm3x3",
|
|
|
|
[VKD3DSIH_TEXM3x3DIFF ] = "texm3x3diff",
|
|
|
|
[VKD3DSIH_TEXM3x3PAD ] = "texm3x3pad",
|
|
|
|
[VKD3DSIH_TEXM3x3SPEC ] = "texm3x3spec",
|
|
|
|
[VKD3DSIH_TEXM3x3TEX ] = "texm3x3tex",
|
|
|
|
[VKD3DSIH_TEXM3x3VSPEC ] = "texm3x3vspec",
|
|
|
|
[VKD3DSIH_TEXREG2AR ] = "texreg2ar",
|
|
|
|
[VKD3DSIH_TEXREG2GB ] = "texreg2gb",
|
|
|
|
[VKD3DSIH_TEXREG2RGB ] = "texreg2rgb",
|
|
|
|
[VKD3DSIH_UBFE ] = "ubfe",
|
|
|
|
[VKD3DSIH_UDIV ] = "udiv",
|
|
|
|
[VKD3DSIH_UGE ] = "uge",
|
|
|
|
[VKD3DSIH_ULT ] = "ult",
|
|
|
|
[VKD3DSIH_UMAX ] = "umax",
|
|
|
|
[VKD3DSIH_UMIN ] = "umin",
|
|
|
|
[VKD3DSIH_UMUL ] = "umul",
|
2024-03-04 06:38:46 -08:00
|
|
|
[VKD3DSIH_UNO ] = "uno",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_USHR ] = "ushr",
|
|
|
|
[VKD3DSIH_UTOD ] = "utod",
|
|
|
|
[VKD3DSIH_UTOF ] = "utof",
|
2023-10-31 22:31:24 -07:00
|
|
|
[VKD3DSIH_UTOU ] = "utou",
|
2024-04-17 18:18:29 -07:00
|
|
|
[VKD3DSIH_WAVE_ACTIVE_ALL_EQUAL ] = "wave_active_all_equal",
|
2024-04-23 03:57:43 -07:00
|
|
|
[VKD3DSIH_WAVE_ACTIVE_BALLOT ] = "wave_active_ballot",
|
2024-04-23 04:10:24 -07:00
|
|
|
[VKD3DSIH_WAVE_ACTIVE_BIT_AND ] = "wave_active_bit_and",
|
|
|
|
[VKD3DSIH_WAVE_ACTIVE_BIT_OR ] = "wave_active_bit_or",
|
|
|
|
[VKD3DSIH_WAVE_ACTIVE_BIT_XOR ] = "wave_active_bit_xor",
|
2024-04-23 04:40:12 -07:00
|
|
|
[VKD3DSIH_WAVE_ALL_BIT_COUNT ] = "wave_all_bit_count",
|
2024-04-17 18:32:52 -07:00
|
|
|
[VKD3DSIH_WAVE_ALL_TRUE ] = "wave_all_true",
|
2024-04-17 18:32:52 -07:00
|
|
|
[VKD3DSIH_WAVE_ANY_TRUE ] = "wave_any_true",
|
2024-04-23 04:53:53 -07:00
|
|
|
[VKD3DSIH_WAVE_IS_FIRST_LANE ] = "wave_is_first_lane",
|
2024-04-23 04:28:21 -07:00
|
|
|
[VKD3DSIH_WAVE_OP_ADD ] = "wave_op_add",
|
|
|
|
[VKD3DSIH_WAVE_OP_IMAX ] = "wave_op_imax",
|
|
|
|
[VKD3DSIH_WAVE_OP_IMIN ] = "wave_op_imin",
|
|
|
|
[VKD3DSIH_WAVE_OP_MAX ] = "wave_op_max",
|
|
|
|
[VKD3DSIH_WAVE_OP_MIN ] = "wave_op_min",
|
|
|
|
[VKD3DSIH_WAVE_OP_MUL ] = "wave_op_mul",
|
|
|
|
[VKD3DSIH_WAVE_OP_UMAX ] = "wave_op_umax",
|
|
|
|
[VKD3DSIH_WAVE_OP_UMIN ] = "wave_op_umin",
|
2024-04-23 05:01:37 -07:00
|
|
|
[VKD3DSIH_WAVE_PREFIX_BIT_COUNT ] = "wave_prefix_bit_count",
|
2024-05-08 19:24:02 -07:00
|
|
|
[VKD3DSIH_WAVE_READ_LANE_AT ] = "wave_read_lane_at",
|
2024-04-23 06:33:56 -07:00
|
|
|
[VKD3DSIH_WAVE_READ_LANE_FIRST ] = "wave_read_lane_first",
|
2022-01-10 17:03:35 -08:00
|
|
|
[VKD3DSIH_XOR ] = "xor",
|
2018-05-29 03:50:32 -07:00
|
|
|
};
|
|
|
|
|
2021-02-16 05:58:27 -08:00
|
|
|
struct vkd3d_d3d_asm_colours
|
|
|
|
{
|
|
|
|
const char *reset;
|
2021-09-28 07:07:22 -07:00
|
|
|
const char *error;
|
2021-02-18 02:24:02 -08:00
|
|
|
const char *literal;
|
2021-09-28 07:07:22 -07:00
|
|
|
const char *modifier;
|
2021-02-16 05:58:27 -08:00
|
|
|
const char *opcode;
|
2021-02-17 03:21:07 -08:00
|
|
|
const char *reg;
|
2021-02-18 02:24:04 -08:00
|
|
|
const char *swizzle;
|
2021-02-19 06:57:07 -08:00
|
|
|
const char *version;
|
2021-02-18 02:24:03 -08:00
|
|
|
const char *write_mask;
|
2024-03-07 05:47:32 -08:00
|
|
|
const char *label;
|
2021-02-16 05:58:27 -08:00
|
|
|
};
|
|
|
|
|
2021-02-16 05:58:24 -08:00
|
|
|
struct vkd3d_d3d_asm_compiler
|
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer buffer;
|
2021-02-16 05:58:24 -08:00
|
|
|
struct vkd3d_shader_version shader_version;
|
2021-02-16 05:58:27 -08:00
|
|
|
struct vkd3d_d3d_asm_colours colours;
|
2024-01-17 14:14:33 -08:00
|
|
|
enum vsir_asm_flags flags;
|
2023-11-09 14:31:27 -08:00
|
|
|
const struct vkd3d_shader_instruction *current;
|
2021-02-16 05:58:24 -08:00
|
|
|
};
|
|
|
|
|
2018-05-29 03:50:32 -07:00
|
|
|
/* Convert floating point offset relative to a register file to an absolute
|
|
|
|
* offset for float constants. */
|
|
|
|
static unsigned int shader_get_float_offset(enum vkd3d_shader_register_type register_type, UINT register_idx)
|
|
|
|
{
|
|
|
|
switch (register_type)
|
|
|
|
{
|
|
|
|
case VKD3DSPR_CONST: return register_idx;
|
|
|
|
case VKD3DSPR_CONST2: return 2048 + register_idx;
|
|
|
|
case VKD3DSPR_CONST3: return 4096 + register_idx;
|
|
|
|
case VKD3DSPR_CONST4: return 6144 + register_idx;
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported register type: %u.\n", register_type);
|
|
|
|
return register_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-02 21:50:09 -07:00
|
|
|
static void shader_dump_global_flags(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
enum vkd3d_shader_global_flags global_flags)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2018-10-11 06:33:33 -07:00
|
|
|
unsigned int i;
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2018-10-11 06:33:33 -07:00
|
|
|
static const struct
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2023-10-02 21:50:09 -07:00
|
|
|
enum vkd3d_shader_global_flags flag;
|
2018-10-11 06:33:33 -07:00
|
|
|
const char *name;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2018-10-11 06:33:33 -07:00
|
|
|
global_flag_info[] =
|
|
|
|
{
|
|
|
|
{VKD3DSGF_REFACTORING_ALLOWED, "refactoringAllowed"},
|
|
|
|
{VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL, "forceEarlyDepthStencil"},
|
|
|
|
{VKD3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS, "enableRawAndStructuredBuffers"},
|
|
|
|
{VKD3DSGF_ENABLE_MINIMUM_PRECISION, "enableMinimumPrecision"},
|
2020-09-15 10:05:11 -07:00
|
|
|
{VKD3DSGF_SKIP_OPTIMIZATION, "skipOptimization"},
|
2021-07-09 08:31:36 -07:00
|
|
|
{VKD3DSGF_ENABLE_DOUBLE_PRECISION_FLOAT_OPS, "enableDoublePrecisionFloatOps"},
|
|
|
|
{VKD3DSGF_ENABLE_11_1_DOUBLE_EXTENSIONS, "enable11_1DoubleExtensions"},
|
2018-10-11 06:33:33 -07:00
|
|
|
};
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2018-10-11 06:33:33 -07:00
|
|
|
for (i = 0; i < ARRAY_SIZE(global_flag_info); ++i)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2018-10-11 06:33:33 -07:00
|
|
|
if (global_flags & global_flag_info[i].flag)
|
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s", global_flag_info[i].name);
|
2018-10-11 06:33:33 -07:00
|
|
|
global_flags &= ~global_flag_info[i].flag;
|
|
|
|
if (global_flags)
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, " | ");
|
2018-10-11 06:33:33 -07:00
|
|
|
}
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (global_flags)
|
2023-10-20 06:01:35 -07:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "unknown_flags(%#"PRIx64")", (uint64_t)global_flags);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-02-29 22:03:47 -08:00
|
|
|
static void shader_dump_atomic_op_flags(struct vkd3d_d3d_asm_compiler *compiler, uint32_t atomic_flags)
|
|
|
|
{
|
|
|
|
if (atomic_flags & VKD3DARF_SEQ_CST)
|
|
|
|
{
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_seqCst");
|
|
|
|
atomic_flags &= ~VKD3DARF_SEQ_CST;
|
|
|
|
}
|
|
|
|
if (atomic_flags & VKD3DARF_VOLATILE)
|
|
|
|
{
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_volatile");
|
|
|
|
atomic_flags &= ~VKD3DARF_VOLATILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (atomic_flags)
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_unknown_flags(%#x)", atomic_flags);
|
|
|
|
}
|
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
static void shader_dump_sync_flags(struct vkd3d_d3d_asm_compiler *compiler, uint32_t sync_flags)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2021-02-03 19:09:17 -08:00
|
|
|
if (sync_flags & VKD3DSSF_GLOBAL_UAV)
|
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_uglobal");
|
2021-02-03 19:09:17 -08:00
|
|
|
sync_flags &= ~VKD3DSSF_GLOBAL_UAV;
|
|
|
|
}
|
2023-08-15 20:46:10 -07:00
|
|
|
if (sync_flags & VKD3DSSF_THREAD_GROUP_UAV)
|
|
|
|
{
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_ugroup");
|
|
|
|
sync_flags &= ~VKD3DSSF_THREAD_GROUP_UAV;
|
|
|
|
}
|
2018-05-29 03:50:32 -07:00
|
|
|
if (sync_flags & VKD3DSSF_GROUP_SHARED_MEMORY)
|
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_g");
|
2018-05-29 03:50:32 -07:00
|
|
|
sync_flags &= ~VKD3DSSF_GROUP_SHARED_MEMORY;
|
|
|
|
}
|
|
|
|
if (sync_flags & VKD3DSSF_THREAD_GROUP)
|
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_t");
|
2018-05-29 03:50:32 -07:00
|
|
|
sync_flags &= ~VKD3DSSF_THREAD_GROUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sync_flags)
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_unknown_flags(%#x)", sync_flags);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
static void shader_dump_precise_flags(struct vkd3d_d3d_asm_compiler *compiler, uint32_t flags)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
if (!(flags & VKD3DSI_PRECISE_XYZW))
|
|
|
|
return;
|
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, " [precise");
|
2018-05-29 03:50:32 -07:00
|
|
|
if (flags != VKD3DSI_PRECISE_XYZW)
|
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "(%s%s%s%s)",
|
2018-05-29 03:50:32 -07:00
|
|
|
flags & VKD3DSI_PRECISE_X ? "x" : "",
|
|
|
|
flags & VKD3DSI_PRECISE_Y ? "y" : "",
|
|
|
|
flags & VKD3DSI_PRECISE_Z ? "z" : "",
|
|
|
|
flags & VKD3DSI_PRECISE_W ? "w" : "");
|
|
|
|
}
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "]");
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
static void shader_dump_uav_flags(struct vkd3d_d3d_asm_compiler *compiler, uint32_t uav_flags)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
if (uav_flags & VKD3DSUF_GLOBALLY_COHERENT)
|
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_glc");
|
2018-05-29 03:50:32 -07:00
|
|
|
uav_flags &= ~VKD3DSUF_GLOBALLY_COHERENT;
|
|
|
|
}
|
|
|
|
if (uav_flags & VKD3DSUF_ORDER_PRESERVING_COUNTER)
|
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_opc");
|
2018-05-29 03:50:32 -07:00
|
|
|
uav_flags &= ~VKD3DSUF_ORDER_PRESERVING_COUNTER;
|
|
|
|
}
|
2023-08-27 21:17:17 -07:00
|
|
|
if (uav_flags & VKD3DSUF_RASTERISER_ORDERED_VIEW)
|
|
|
|
{
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_rov");
|
|
|
|
uav_flags &= ~VKD3DSUF_RASTERISER_ORDERED_VIEW;
|
|
|
|
}
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
if (uav_flags)
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "_unknown_flags(%#x)", uav_flags);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-03-11 09:33:29 -07:00
|
|
|
static void shader_print_tessellator_domain(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, enum vkd3d_tessellator_domain d, const char *suffix)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
2024-03-11 09:33:29 -07:00
|
|
|
const char *domain;
|
2021-02-16 05:58:25 -08:00
|
|
|
|
2024-03-11 09:33:29 -07:00
|
|
|
switch (d)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
case VKD3D_TESSELLATOR_DOMAIN_LINE:
|
2024-03-11 09:33:29 -07:00
|
|
|
domain = "domain_isoline";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_TESSELLATOR_DOMAIN_TRIANGLE:
|
2024-03-11 09:33:29 -07:00
|
|
|
domain = "domain_tri";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_TESSELLATOR_DOMAIN_QUAD:
|
2024-03-11 09:33:29 -07:00
|
|
|
domain = "domain_quad";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
default:
|
2024-03-11 09:33:29 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s<unhandled tessellator domain %#x>%s%s",
|
|
|
|
prefix, compiler->colours.error, d, compiler->colours.reset, suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2024-03-11 09:33:29 -07:00
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s%s", prefix, domain, suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-03-11 09:42:09 -07:00
|
|
|
static void shader_print_tessellator_output_primitive(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, enum vkd3d_shader_tessellator_output_primitive p, const char *suffix)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
2024-03-11 09:42:09 -07:00
|
|
|
const char *primitive;
|
2021-02-16 05:58:25 -08:00
|
|
|
|
2024-03-11 09:42:09 -07:00
|
|
|
switch (p)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2020-06-23 02:20:13 -07:00
|
|
|
case VKD3D_SHADER_TESSELLATOR_OUTPUT_POINT:
|
2024-03-11 09:42:09 -07:00
|
|
|
primitive = "output_point";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
2020-06-23 02:20:13 -07:00
|
|
|
case VKD3D_SHADER_TESSELLATOR_OUTPUT_LINE:
|
2024-03-11 09:42:09 -07:00
|
|
|
primitive = "output_line";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
2020-06-23 02:20:13 -07:00
|
|
|
case VKD3D_SHADER_TESSELLATOR_OUTPUT_TRIANGLE_CW:
|
2024-03-11 09:42:09 -07:00
|
|
|
primitive = "output_triangle_cw";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
2020-06-23 02:20:13 -07:00
|
|
|
case VKD3D_SHADER_TESSELLATOR_OUTPUT_TRIANGLE_CCW:
|
2024-03-11 09:42:09 -07:00
|
|
|
primitive = "output_triangle_ccw";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
default:
|
2024-03-11 09:42:09 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s<unhandled tessellator output primitive %#x>%s%s",
|
|
|
|
prefix, compiler->colours.error, p, compiler->colours.reset, suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2024-03-11 09:42:09 -07:00
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s%s", prefix, primitive, suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-03-11 09:51:27 -07:00
|
|
|
static void shader_print_tessellator_partitioning(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, enum vkd3d_shader_tessellator_partitioning p, const char *suffix)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
2024-03-11 09:51:27 -07:00
|
|
|
const char *partitioning;
|
2021-02-16 05:58:25 -08:00
|
|
|
|
2024-03-11 09:51:27 -07:00
|
|
|
switch (p)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2020-06-23 02:20:14 -07:00
|
|
|
case VKD3D_SHADER_TESSELLATOR_PARTITIONING_INTEGER:
|
2024-03-11 09:51:27 -07:00
|
|
|
partitioning = "partitioning_integer";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
2020-06-23 02:20:14 -07:00
|
|
|
case VKD3D_SHADER_TESSELLATOR_PARTITIONING_POW2:
|
2024-03-11 09:51:27 -07:00
|
|
|
partitioning = "partitioning_pow2";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
2020-06-23 02:20:14 -07:00
|
|
|
case VKD3D_SHADER_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD:
|
2024-03-11 09:51:27 -07:00
|
|
|
partitioning = "partitioning_fractional_odd";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
2020-06-23 02:20:14 -07:00
|
|
|
case VKD3D_SHADER_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN:
|
2024-03-11 09:51:27 -07:00
|
|
|
partitioning = "partitioning_fractional_even";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
default:
|
2024-03-11 09:51:27 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s<unhandled tessellator partitioning %#x>%s%s",
|
|
|
|
prefix, compiler->colours.error, p, compiler->colours.reset, suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2024-03-11 09:51:27 -07:00
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s%s", prefix, partitioning, suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-03-14 13:31:08 -07:00
|
|
|
static void shader_print_input_sysval_semantic(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, enum vkd3d_shader_input_sysval_semantic semantic, const char *suffix)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2024-03-14 13:31:08 -07:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
enum vkd3d_shader_input_sysval_semantic sysval_semantic;
|
|
|
|
const char *sysval_name;
|
|
|
|
}
|
|
|
|
shader_input_sysval_semantic_names[] =
|
|
|
|
{
|
|
|
|
{VKD3D_SIV_POSITION, "position"},
|
|
|
|
{VKD3D_SIV_CLIP_DISTANCE, "clip_distance"},
|
|
|
|
{VKD3D_SIV_CULL_DISTANCE, "cull_distance"},
|
|
|
|
{VKD3D_SIV_RENDER_TARGET_ARRAY_INDEX, "render_target_array_index"},
|
|
|
|
{VKD3D_SIV_VIEWPORT_ARRAY_INDEX, "viewport_array_index"},
|
|
|
|
{VKD3D_SIV_VERTEX_ID, "vertex_id"},
|
|
|
|
{VKD3D_SIV_INSTANCE_ID, "instance_id"},
|
|
|
|
{VKD3D_SIV_PRIMITIVE_ID, "primitive_id"},
|
|
|
|
{VKD3D_SIV_IS_FRONT_FACE, "is_front_face"},
|
|
|
|
{VKD3D_SIV_SAMPLE_INDEX, "sample_index"},
|
|
|
|
{VKD3D_SIV_QUAD_U0_TESS_FACTOR, "finalQuadUeq0EdgeTessFactor"},
|
|
|
|
{VKD3D_SIV_QUAD_V0_TESS_FACTOR, "finalQuadVeq0EdgeTessFactor"},
|
|
|
|
{VKD3D_SIV_QUAD_U1_TESS_FACTOR, "finalQuadUeq1EdgeTessFactor"},
|
|
|
|
{VKD3D_SIV_QUAD_V1_TESS_FACTOR, "finalQuadVeq1EdgeTessFactor"},
|
|
|
|
{VKD3D_SIV_QUAD_U_INNER_TESS_FACTOR, "finalQuadUInsideTessFactor"},
|
|
|
|
{VKD3D_SIV_QUAD_V_INNER_TESS_FACTOR, "finalQuadVInsideTessFactor"},
|
|
|
|
{VKD3D_SIV_TRIANGLE_U_TESS_FACTOR, "finalTriUeq0EdgeTessFactor"},
|
|
|
|
{VKD3D_SIV_TRIANGLE_V_TESS_FACTOR, "finalTriVeq0EdgeTessFactor"},
|
|
|
|
{VKD3D_SIV_TRIANGLE_W_TESS_FACTOR, "finalTriWeq0EdgeTessFactor"},
|
|
|
|
{VKD3D_SIV_TRIANGLE_INNER_TESS_FACTOR, "finalTriInsideTessFactor"},
|
|
|
|
{VKD3D_SIV_LINE_DETAIL_TESS_FACTOR, "finalLineDetailTessFactor"},
|
|
|
|
{VKD3D_SIV_LINE_DENSITY_TESS_FACTOR, "finalLineDensityTessFactor"},
|
|
|
|
};
|
|
|
|
|
2018-05-29 03:50:32 -07:00
|
|
|
for (i = 0; i < ARRAY_SIZE(shader_input_sysval_semantic_names); ++i)
|
|
|
|
{
|
2024-03-14 13:31:08 -07:00
|
|
|
if (shader_input_sysval_semantic_names[i].sysval_semantic != semantic)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s%s",
|
|
|
|
prefix, shader_input_sysval_semantic_names[i].sysval_name, suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-03-14 13:31:08 -07:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s<unhandled input sysval semantic %#x>%s%s",
|
|
|
|
prefix, compiler->colours.error, semantic, compiler->colours.reset, suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
static void shader_dump_resource_type(struct vkd3d_d3d_asm_compiler *compiler, enum vkd3d_shader_resource_type type)
|
2020-09-04 15:57:04 -07:00
|
|
|
{
|
|
|
|
static const char *const resource_type_names[] =
|
|
|
|
{
|
2023-06-12 03:29:35 -07:00
|
|
|
[VKD3D_SHADER_RESOURCE_NONE ] = "none",
|
|
|
|
[VKD3D_SHADER_RESOURCE_BUFFER ] = "buffer",
|
|
|
|
[VKD3D_SHADER_RESOURCE_TEXTURE_1D ] = "texture1d",
|
|
|
|
[VKD3D_SHADER_RESOURCE_TEXTURE_2D ] = "texture2d",
|
|
|
|
[VKD3D_SHADER_RESOURCE_TEXTURE_2DMS ] = "texture2dms",
|
|
|
|
[VKD3D_SHADER_RESOURCE_TEXTURE_3D ] = "texture3d",
|
|
|
|
[VKD3D_SHADER_RESOURCE_TEXTURE_CUBE ] = "texturecube",
|
|
|
|
[VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY ] = "texture1darray",
|
|
|
|
[VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY ] = "texture2darray",
|
|
|
|
[VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY] = "texture2dmsarray",
|
|
|
|
[VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY] = "texturecubearray",
|
2020-09-04 15:57:04 -07:00
|
|
|
};
|
|
|
|
|
2020-09-30 13:34:01 -07:00
|
|
|
if (type < ARRAY_SIZE(resource_type_names))
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s", resource_type_names[type]);
|
2020-09-04 15:57:04 -07:00
|
|
|
else
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "unknown");
|
2020-09-04 15:57:04 -07:00
|
|
|
}
|
|
|
|
|
2023-11-30 02:53:11 -08:00
|
|
|
static void shader_dump_data_type(struct vkd3d_d3d_asm_compiler *compiler, enum vkd3d_data_type type)
|
2020-09-04 15:57:05 -07:00
|
|
|
{
|
|
|
|
static const char *const data_type_names[] =
|
|
|
|
{
|
2023-06-12 03:29:35 -07:00
|
|
|
[VKD3D_DATA_FLOAT ] = "float",
|
|
|
|
[VKD3D_DATA_INT ] = "int",
|
|
|
|
[VKD3D_DATA_RESOURCE ] = "resource",
|
|
|
|
[VKD3D_DATA_SAMPLER ] = "sampler",
|
|
|
|
[VKD3D_DATA_UAV ] = "uav",
|
|
|
|
[VKD3D_DATA_UINT ] = "uint",
|
|
|
|
[VKD3D_DATA_UNORM ] = "unorm",
|
|
|
|
[VKD3D_DATA_SNORM ] = "snorm",
|
|
|
|
[VKD3D_DATA_OPAQUE ] = "opaque",
|
|
|
|
[VKD3D_DATA_MIXED ] = "mixed",
|
|
|
|
[VKD3D_DATA_DOUBLE ] = "double",
|
|
|
|
[VKD3D_DATA_CONTINUED] = "<continued>",
|
|
|
|
[VKD3D_DATA_UNUSED ] = "<unused>",
|
2023-11-30 02:54:53 -08:00
|
|
|
[VKD3D_DATA_UINT8 ] = "uint8",
|
|
|
|
[VKD3D_DATA_UINT64 ] = "uint64",
|
|
|
|
[VKD3D_DATA_BOOL ] = "bool",
|
2023-12-12 21:40:48 -08:00
|
|
|
[VKD3D_DATA_UINT16 ] = "uint16",
|
|
|
|
[VKD3D_DATA_HALF ] = "half",
|
2020-09-04 15:57:05 -07:00
|
|
|
};
|
2023-11-30 02:53:11 -08:00
|
|
|
|
2020-09-16 16:14:45 -07:00
|
|
|
const char *name;
|
2023-11-30 02:53:11 -08:00
|
|
|
|
|
|
|
if (type < ARRAY_SIZE(data_type_names))
|
|
|
|
name = data_type_names[type];
|
|
|
|
else
|
2023-11-30 02:55:20 -08:00
|
|
|
name = "<unknown>";
|
2023-11-30 02:53:11 -08:00
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shader_dump_resource_data_type(struct vkd3d_d3d_asm_compiler *compiler, const enum vkd3d_data_type *type)
|
|
|
|
{
|
2020-09-25 17:05:37 -07:00
|
|
|
int i;
|
2020-09-04 15:57:05 -07:00
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "(");
|
2020-09-25 17:05:37 -07:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
2023-11-30 02:53:11 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s", i == 0 ? "" : ",");
|
|
|
|
shader_dump_data_type(compiler, type[i]);
|
2020-09-25 17:05:37 -07:00
|
|
|
}
|
2020-09-16 16:14:45 -07:00
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, ")");
|
2020-09-04 15:57:05 -07:00
|
|
|
}
|
|
|
|
|
2024-04-03 10:42:03 -07:00
|
|
|
static void shader_print_dcl_usage(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, const struct vkd3d_shader_semantic *semantic, uint32_t flags, const char *suffix)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
2024-04-03 10:42:03 -07:00
|
|
|
unsigned int usage_idx;
|
|
|
|
const char *usage;
|
|
|
|
bool indexed;
|
2021-02-16 05:58:25 -08:00
|
|
|
|
2023-03-07 14:45:18 -08:00
|
|
|
if (semantic->resource.reg.reg.type == VKD3DSPR_COMBINED_SAMPLER)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
switch (semantic->resource_type)
|
|
|
|
{
|
|
|
|
case VKD3D_SHADER_RESOURCE_TEXTURE_2D:
|
2024-04-03 10:42:03 -07:00
|
|
|
usage = "2d";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_SHADER_RESOURCE_TEXTURE_3D:
|
2024-04-03 10:42:03 -07:00
|
|
|
usage = "volume";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_SHADER_RESOURCE_TEXTURE_CUBE:
|
2024-04-03 10:42:03 -07:00
|
|
|
usage = "cube";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
default:
|
2024-04-03 10:42:03 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s<unhandled resource type %#x>%s%s",
|
|
|
|
prefix, compiler->colours.error, semantic->resource_type, compiler->colours.reset, suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2024-04-03 10:42:03 -07:00
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s%s", prefix, usage, suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2024-04-03 10:42:03 -07:00
|
|
|
|
|
|
|
if (semantic->resource.reg.reg.type == VKD3DSPR_RESOURCE || semantic->resource.reg.reg.type == VKD3DSPR_UAV)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2024-04-03 10:42:03 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", prefix);
|
2020-06-30 03:32:03 -07:00
|
|
|
if (semantic->resource.reg.reg.type == VKD3DSPR_RESOURCE)
|
2024-04-03 10:42:03 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "resource_");
|
2020-09-15 10:05:12 -07:00
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
shader_dump_resource_type(compiler, semantic->resource_type);
|
2023-03-04 00:58:46 -08:00
|
|
|
if (semantic->resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMS
|
|
|
|
|| semantic->resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY)
|
|
|
|
{
|
2024-04-03 10:42:03 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "(%u)", semantic->sample_count);
|
2023-03-04 00:58:46 -08:00
|
|
|
}
|
2020-06-30 03:32:03 -07:00
|
|
|
if (semantic->resource.reg.reg.type == VKD3DSPR_UAV)
|
2021-02-16 05:58:25 -08:00
|
|
|
shader_dump_uav_flags(compiler, flags);
|
2024-04-03 10:42:03 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, " ");
|
2023-11-30 02:53:11 -08:00
|
|
|
shader_dump_resource_data_type(compiler, semantic->resource_data_type);
|
2024-04-03 10:42:03 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-04-03 10:42:03 -07:00
|
|
|
/* Pixel shaders 3.0 don't have usage semantics. */
|
|
|
|
if (!vkd3d_shader_ver_ge(&compiler->shader_version, 3, 0)
|
|
|
|
&& compiler->shader_version.type == VKD3D_SHADER_TYPE_PIXEL)
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2024-04-03 10:42:03 -07:00
|
|
|
indexed = false;
|
|
|
|
usage_idx = semantic->usage_idx;
|
|
|
|
switch (semantic->usage)
|
|
|
|
{
|
|
|
|
case VKD3D_DECL_USAGE_POSITION:
|
|
|
|
usage = "position";
|
|
|
|
indexed = true;
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_BLEND_INDICES:
|
|
|
|
usage = "blend";
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_BLEND_WEIGHT:
|
|
|
|
usage = "weight";
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_NORMAL:
|
|
|
|
usage = "normal";
|
|
|
|
indexed = true;
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_PSIZE:
|
|
|
|
usage = "psize";
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_COLOR:
|
|
|
|
if (semantic->usage_idx)
|
|
|
|
{
|
|
|
|
usage = "specular";
|
|
|
|
indexed = true;
|
|
|
|
--usage_idx;
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
2024-04-03 10:42:03 -07:00
|
|
|
}
|
|
|
|
usage = "color";
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_TEXCOORD:
|
|
|
|
usage = "texcoord";
|
|
|
|
indexed = true;
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_TANGENT:
|
|
|
|
usage = "tangent";
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_BINORMAL:
|
|
|
|
usage = "binormal";
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_TESS_FACTOR:
|
|
|
|
usage = "tessfactor";
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_POSITIONT:
|
|
|
|
usage = "positionT";
|
|
|
|
indexed = true;
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_FOG:
|
|
|
|
usage = "fog";
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_DEPTH:
|
|
|
|
usage = "depth";
|
|
|
|
break;
|
|
|
|
case VKD3D_DECL_USAGE_SAMPLE:
|
|
|
|
usage = "sample";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s<unhandled usage %#x, index %u>%s%s",
|
|
|
|
prefix, compiler->colours.error, semantic->usage, usage_idx, compiler->colours.reset, suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2024-04-03 10:42:03 -07:00
|
|
|
|
|
|
|
if (indexed)
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s%u%s", prefix, usage, usage_idx, suffix);
|
|
|
|
else
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s%s", prefix, usage, suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-03-14 11:08:16 -07:00
|
|
|
static void shader_print_src_param(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, const struct vkd3d_shader_src_param *param, const char *suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2021-02-17 03:21:09 -08:00
|
|
|
static void shader_print_float_literal(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, float f, const char *suffix)
|
|
|
|
{
|
2022-03-01 04:21:33 -08:00
|
|
|
const char *sign = "";
|
|
|
|
|
2021-02-18 02:24:02 -08:00
|
|
|
if (isfinite(f) && signbit(f))
|
2022-03-01 04:21:33 -08:00
|
|
|
{
|
|
|
|
sign = "-";
|
|
|
|
f = -f;
|
|
|
|
}
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s%s", prefix, sign, compiler->colours.literal);
|
|
|
|
vkd3d_string_buffer_print_f32(&compiler->buffer, f);
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s", compiler->colours.reset, suffix);
|
2021-02-17 03:21:09 -08:00
|
|
|
}
|
|
|
|
|
2021-07-30 06:27:20 -07:00
|
|
|
static void shader_print_double_literal(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, double d, const char *suffix)
|
|
|
|
{
|
2022-03-01 04:21:34 -08:00
|
|
|
const char *sign = "";
|
|
|
|
|
2021-07-30 06:27:20 -07:00
|
|
|
if (isfinite(d) && signbit(d))
|
2022-03-01 04:21:34 -08:00
|
|
|
{
|
|
|
|
sign = "-";
|
|
|
|
d = -d;
|
|
|
|
}
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s%s", prefix, sign, compiler->colours.literal);
|
|
|
|
vkd3d_string_buffer_print_f64(&compiler->buffer, d);
|
2022-03-01 04:21:35 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "l%s%s", compiler->colours.reset, suffix);
|
2021-07-30 06:27:20 -07:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:21:10 -08:00
|
|
|
static void shader_print_int_literal(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, int i, const char *suffix)
|
|
|
|
{
|
2021-02-18 02:24:02 -08:00
|
|
|
if (i < 0)
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s-%s%d%s%s",
|
|
|
|
prefix, compiler->colours.literal, -i, compiler->colours.reset, suffix);
|
|
|
|
else
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s%d%s%s",
|
|
|
|
prefix, compiler->colours.literal, i, compiler->colours.reset, suffix);
|
2021-02-17 03:21:10 -08:00
|
|
|
}
|
|
|
|
|
2021-02-17 03:21:11 -08:00
|
|
|
static void shader_print_uint_literal(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, unsigned int i, const char *suffix)
|
|
|
|
{
|
2021-02-18 02:24:02 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s%u%s%s",
|
|
|
|
prefix, compiler->colours.literal, i, compiler->colours.reset, suffix);
|
2021-02-17 03:21:11 -08:00
|
|
|
}
|
|
|
|
|
2023-11-23 19:14:44 -08:00
|
|
|
static void shader_print_uint64_literal(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, uint64_t i, const char *suffix)
|
|
|
|
{
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s%"PRIu64"%s%s",
|
|
|
|
prefix, compiler->colours.literal, i, compiler->colours.reset, suffix);
|
|
|
|
}
|
|
|
|
|
2021-02-18 02:24:00 -08:00
|
|
|
static void shader_print_hex_literal(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, unsigned int i, const char *suffix)
|
|
|
|
{
|
2021-02-18 02:24:02 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s0x%08x%s%s",
|
|
|
|
prefix, compiler->colours.literal, i, compiler->colours.reset, suffix);
|
2021-02-18 02:24:00 -08:00
|
|
|
}
|
|
|
|
|
2021-02-18 02:24:01 -08:00
|
|
|
static void shader_print_bool_literal(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, unsigned int b, const char *suffix)
|
|
|
|
{
|
2021-02-18 02:24:02 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s%s%s%s", prefix,
|
|
|
|
compiler->colours.literal, b ? "true" : "false", compiler->colours.reset, suffix);
|
2021-02-18 02:24:01 -08:00
|
|
|
}
|
|
|
|
|
2023-11-09 14:31:27 -08:00
|
|
|
static void shader_print_untyped_literal(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, uint32_t u, const char *suffix)
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
uint32_t u;
|
|
|
|
float f;
|
|
|
|
} value;
|
|
|
|
unsigned int exponent = (u >> 23) & 0xff;
|
|
|
|
|
|
|
|
value.u = u;
|
|
|
|
|
|
|
|
if (exponent != 0 && exponent != 0xff)
|
|
|
|
return shader_print_float_literal(compiler, prefix, value.f, suffix);
|
|
|
|
|
|
|
|
if (u <= 10000)
|
|
|
|
return shader_print_uint_literal(compiler, prefix, value.u, suffix);
|
|
|
|
|
|
|
|
return shader_print_hex_literal(compiler, prefix, value.u, suffix);
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:21:08 -08:00
|
|
|
static void shader_print_subscript(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
unsigned int offset, const struct vkd3d_shader_src_param *rel_addr)
|
|
|
|
{
|
|
|
|
if (rel_addr)
|
2024-03-14 11:08:16 -07:00
|
|
|
shader_print_src_param(compiler, "[", rel_addr, " + ");
|
|
|
|
shader_print_uint_literal(compiler, rel_addr ? "" : "[", offset, "]");
|
2021-02-17 03:21:08 -08:00
|
|
|
}
|
|
|
|
|
2021-07-08 21:33:41 -07:00
|
|
|
static void shader_print_subscript_range(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
unsigned int offset_first, unsigned int offset_last)
|
|
|
|
{
|
|
|
|
shader_print_uint_literal(compiler, "[", offset_first, ":");
|
|
|
|
if (offset_last != ~0u)
|
|
|
|
shader_print_uint_literal(compiler, "", offset_last, "]");
|
|
|
|
else
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "*]");
|
|
|
|
}
|
|
|
|
|
2024-03-14 12:04:31 -07:00
|
|
|
static void shader_print_register(struct vkd3d_d3d_asm_compiler *compiler, const char *prefix,
|
|
|
|
const struct vkd3d_shader_register *reg, bool is_declaration, const char *suffix)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
|
|
|
unsigned int offset = reg->idx[0].offset;
|
2021-07-08 08:17:50 -07:00
|
|
|
bool is_descriptor = false;
|
2021-02-16 05:58:25 -08:00
|
|
|
|
2018-05-29 03:50:32 -07:00
|
|
|
static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
|
|
|
|
static const char * const misctype_reg_names[] = {"vPos", "vFace"};
|
|
|
|
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s", prefix,
|
|
|
|
reg->type == VKD3DSPR_LABEL ? compiler->colours.label : compiler->colours.reg);
|
2018-05-29 03:50:32 -07:00
|
|
|
switch (reg->type)
|
|
|
|
{
|
|
|
|
case VKD3DSPR_TEMP:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "r");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_INPUT:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "v");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_CONST:
|
|
|
|
case VKD3DSPR_CONST2:
|
|
|
|
case VKD3DSPR_CONST3:
|
|
|
|
case VKD3DSPR_CONST4:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "c");
|
2018-05-29 03:50:32 -07:00
|
|
|
offset = shader_get_float_offset(reg->type, offset);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_TEXTURE: /* vs: case VKD3DSPR_ADDR */
|
2021-02-16 05:58:24 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%c",
|
|
|
|
compiler->shader_version.type == VKD3D_SHADER_TYPE_PIXEL ? 't' : 'a');
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_RASTOUT:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", rastout_reg_names[offset]);
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_COLOROUT:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "oC");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_DEPTHOUT:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "oDepth");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_DEPTHOUTGE:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "oDepthGE");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_DEPTHOUTLE:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "oDepthLE");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_ATTROUT:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "oD");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_TEXCRDOUT:
|
|
|
|
/* Vertex shaders >= 3.0 use general purpose output registers
|
|
|
|
* (VKD3DSPR_OUTPUT), which can include an address token. */
|
2023-10-30 09:14:26 -07:00
|
|
|
if (vkd3d_shader_ver_ge(&compiler->shader_version, 3, 0))
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "o");
|
2018-05-29 03:50:32 -07:00
|
|
|
else
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "oT");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_CONSTINT:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "i");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_CONSTBOOL:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "b");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_LABEL:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "l");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_LOOP:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "aL");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
2023-03-07 14:45:18 -08:00
|
|
|
case VKD3DSPR_COMBINED_SAMPLER:
|
2018-05-29 03:50:32 -07:00
|
|
|
case VKD3DSPR_SAMPLER:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "s");
|
2021-07-08 08:17:50 -07:00
|
|
|
is_descriptor = true;
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_MISCTYPE:
|
|
|
|
if (offset > 1)
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s<unhandled misctype %#x>%s",
|
|
|
|
compiler->colours.error, offset, compiler->colours.reset);
|
2018-05-29 03:50:32 -07:00
|
|
|
else
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", misctype_reg_names[offset]);
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_PREDICATE:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "p");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_IMMCONST:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "l");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
2021-07-30 06:27:20 -07:00
|
|
|
case VKD3DSPR_IMMCONST64:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "d");
|
2021-07-30 06:27:20 -07:00
|
|
|
break;
|
|
|
|
|
2018-05-29 03:50:32 -07:00
|
|
|
case VKD3DSPR_CONSTBUFFER:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "cb");
|
2021-07-08 08:17:50 -07:00
|
|
|
is_descriptor = true;
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_IMMCONSTBUFFER:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "icb");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_PRIMID:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "primID");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_NULL:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "null");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_RASTERIZER:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "rasterizer");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_RESOURCE:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "t");
|
2021-07-08 08:17:50 -07:00
|
|
|
is_descriptor = true;
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_UAV:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "u");
|
2021-07-08 08:17:50 -07:00
|
|
|
is_descriptor = true;
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_OUTPOINTID:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vOutputControlPointID");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_FORKINSTID:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vForkInstanceId");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_JOININSTID:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vJoinInstanceId");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_INCONTROLPOINT:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vicp");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_OUTCONTROLPOINT:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vocp");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_PATCHCONST:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vpc");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_TESSCOORD:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vDomainLocation");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_GROUPSHAREDMEM:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "g");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_THREADID:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vThreadID");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_THREADGROUPID:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vThreadGroupID");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_LOCALTHREADID:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vThreadIDInGroup");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_LOCALTHREADINDEX:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vThreadIDInGroupFlattened");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_IDXTEMP:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "x");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_STREAM:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "m");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_FUNCTIONBODY:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "fb");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_FUNCTIONPOINTER:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "fp");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_COVERAGE:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vCoverage");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_SAMPLEMASK:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "oMask");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_GSINSTID:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "vGSInstanceID");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
|
2021-10-18 09:28:12 -07:00
|
|
|
case VKD3DSPR_OUTSTENCILREF:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "oStencilRef");
|
2021-10-18 09:28:12 -07:00
|
|
|
break;
|
|
|
|
|
2023-08-30 19:39:08 -07:00
|
|
|
case VKD3DSPR_UNDEF:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "undef");
|
2023-08-30 19:39:08 -07:00
|
|
|
break;
|
|
|
|
|
2023-05-17 22:51:53 -07:00
|
|
|
case VKD3DSPR_SSA:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "sr");
|
2023-05-17 22:51:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-04-17 17:35:07 -07:00
|
|
|
case VKD3DSPR_WAVELANECOUNT:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "vWaveLaneCount");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSPR_WAVELANEINDEX:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "vWaveLaneIndex");
|
|
|
|
break;
|
|
|
|
|
2018-05-29 03:50:32 -07:00
|
|
|
default:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s<unhandled register type %#x>%s",
|
|
|
|
compiler->colours.error, reg->type, compiler->colours.reset);
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reg->type == VKD3DSPR_IMMCONST)
|
|
|
|
{
|
2023-11-09 14:31:27 -08:00
|
|
|
bool untyped = false;
|
|
|
|
|
2024-04-24 11:34:42 -07:00
|
|
|
switch (compiler->current->opcode)
|
2023-11-09 14:31:27 -08:00
|
|
|
{
|
|
|
|
case VKD3DSIH_MOV:
|
|
|
|
case VKD3DSIH_MOVC:
|
|
|
|
untyped = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s(", compiler->colours.reset);
|
2023-08-14 10:21:41 -07:00
|
|
|
switch (reg->dimension)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2023-08-14 10:21:41 -07:00
|
|
|
case VSIR_DIMENSION_SCALAR:
|
2018-05-29 03:50:32 -07:00
|
|
|
switch (reg->data_type)
|
|
|
|
{
|
|
|
|
case VKD3D_DATA_FLOAT:
|
2023-11-09 14:31:27 -08:00
|
|
|
if (untyped)
|
|
|
|
shader_print_untyped_literal(compiler, "", reg->u.immconst_u32[0], "");
|
|
|
|
else
|
|
|
|
shader_print_float_literal(compiler, "", reg->u.immconst_f32[0], "");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_DATA_INT:
|
2023-12-05 14:24:36 -08:00
|
|
|
shader_print_int_literal(compiler, "", reg->u.immconst_u32[0], "");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_DATA_RESOURCE:
|
|
|
|
case VKD3D_DATA_SAMPLER:
|
|
|
|
case VKD3D_DATA_UINT:
|
2023-12-05 14:24:36 -08:00
|
|
|
shader_print_uint_literal(compiler, "", reg->u.immconst_u32[0], "");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
default:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s<unhandled data type %#x>%s",
|
|
|
|
compiler->colours.error, reg->data_type, compiler->colours.reset);
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2023-08-14 10:21:41 -07:00
|
|
|
case VSIR_DIMENSION_VEC4:
|
2018-05-29 03:50:32 -07:00
|
|
|
switch (reg->data_type)
|
|
|
|
{
|
|
|
|
case VKD3D_DATA_FLOAT:
|
2023-11-09 14:31:27 -08:00
|
|
|
if (untyped)
|
|
|
|
{
|
|
|
|
shader_print_untyped_literal(compiler, "", reg->u.immconst_u32[0], "");
|
|
|
|
shader_print_untyped_literal(compiler, ", ", reg->u.immconst_u32[1], "");
|
|
|
|
shader_print_untyped_literal(compiler, ", ", reg->u.immconst_u32[2], "");
|
|
|
|
shader_print_untyped_literal(compiler, ", ", reg->u.immconst_u32[3], "");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shader_print_float_literal(compiler, "", reg->u.immconst_f32[0], "");
|
|
|
|
shader_print_float_literal(compiler, ", ", reg->u.immconst_f32[1], "");
|
|
|
|
shader_print_float_literal(compiler, ", ", reg->u.immconst_f32[2], "");
|
|
|
|
shader_print_float_literal(compiler, ", ", reg->u.immconst_f32[3], "");
|
|
|
|
}
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_DATA_INT:
|
2023-12-05 14:24:36 -08:00
|
|
|
shader_print_int_literal(compiler, "", reg->u.immconst_u32[0], "");
|
|
|
|
shader_print_int_literal(compiler, ", ", reg->u.immconst_u32[1], "");
|
|
|
|
shader_print_int_literal(compiler, ", ", reg->u.immconst_u32[2], "");
|
|
|
|
shader_print_int_literal(compiler, ", ", reg->u.immconst_u32[3], "");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_DATA_RESOURCE:
|
|
|
|
case VKD3D_DATA_SAMPLER:
|
|
|
|
case VKD3D_DATA_UINT:
|
2023-12-05 14:24:36 -08:00
|
|
|
shader_print_uint_literal(compiler, "", reg->u.immconst_u32[0], "");
|
|
|
|
shader_print_uint_literal(compiler, ", ", reg->u.immconst_u32[1], "");
|
|
|
|
shader_print_uint_literal(compiler, ", ", reg->u.immconst_u32[2], "");
|
|
|
|
shader_print_uint_literal(compiler, ", ", reg->u.immconst_u32[3], "");
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
default:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s<unhandled data type %#x>%s",
|
|
|
|
compiler->colours.error, reg->data_type, compiler->colours.reset);
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s<unhandled immconst dimension %#x>%s",
|
|
|
|
compiler->colours.error, reg->dimension, compiler->colours.reset);
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
}
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, ")");
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2021-07-30 06:27:20 -07:00
|
|
|
else if (reg->type == VKD3DSPR_IMMCONST64)
|
|
|
|
{
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s(", compiler->colours.reset);
|
2023-08-14 10:21:41 -07:00
|
|
|
/* A double2 vector is treated as a float4 vector in enum vsir_dimension. */
|
|
|
|
if (reg->dimension == VSIR_DIMENSION_SCALAR || reg->dimension == VSIR_DIMENSION_VEC4)
|
2021-07-30 06:27:20 -07:00
|
|
|
{
|
|
|
|
if (reg->data_type == VKD3D_DATA_DOUBLE)
|
|
|
|
{
|
2023-12-05 14:33:16 -08:00
|
|
|
shader_print_double_literal(compiler, "", reg->u.immconst_f64[0], "");
|
2023-08-14 10:21:41 -07:00
|
|
|
if (reg->dimension == VSIR_DIMENSION_VEC4)
|
2023-12-05 14:33:16 -08:00
|
|
|
shader_print_double_literal(compiler, ", ", reg->u.immconst_f64[1], "");
|
2021-07-30 06:27:20 -07:00
|
|
|
}
|
2023-11-23 19:14:44 -08:00
|
|
|
else if (reg->data_type == VKD3D_DATA_UINT64)
|
|
|
|
{
|
|
|
|
shader_print_uint64_literal(compiler, "", reg->u.immconst_u64[0], "");
|
|
|
|
if (reg->dimension == VSIR_DIMENSION_VEC4)
|
|
|
|
shader_print_uint64_literal(compiler, "", reg->u.immconst_u64[1], "");
|
|
|
|
}
|
2021-07-30 06:27:20 -07:00
|
|
|
else
|
|
|
|
{
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s<unhandled data type %#x>%s",
|
|
|
|
compiler->colours.error, reg->data_type, compiler->colours.reset);
|
2021-07-30 06:27:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s<unhandled immconst64 dimension %#x>%s",
|
|
|
|
compiler->colours.error, reg->dimension, compiler->colours.reset);
|
2021-07-30 06:27:20 -07:00
|
|
|
}
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, ")");
|
2021-07-30 06:27:20 -07:00
|
|
|
}
|
2018-05-29 03:50:32 -07:00
|
|
|
else if (reg->type != VKD3DSPR_RASTOUT
|
|
|
|
&& reg->type != VKD3DSPR_MISCTYPE
|
2023-08-29 16:08:24 -07:00
|
|
|
&& reg->type != VKD3DSPR_NULL
|
|
|
|
&& reg->type != VKD3DSPR_DEPTHOUT)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
if (offset != ~0u)
|
|
|
|
{
|
2023-10-30 09:14:26 -07:00
|
|
|
bool is_sm_5_1 = vkd3d_shader_ver_ge(&compiler->shader_version, 5, 1);
|
2021-07-08 21:33:41 -07:00
|
|
|
|
2021-02-17 03:21:08 -08:00
|
|
|
if (reg->idx[0].rel_addr || reg->type == VKD3DSPR_IMMCONSTBUFFER
|
|
|
|
|| reg->type == VKD3DSPR_INCONTROLPOINT || (reg->type == VKD3DSPR_INPUT
|
|
|
|
&& (compiler->shader_version.type == VKD3D_SHADER_TYPE_GEOMETRY
|
|
|
|
|| compiler->shader_version.type == VKD3D_SHADER_TYPE_HULL)))
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2021-02-17 03:21:08 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", compiler->colours.reset);
|
|
|
|
shader_print_subscript(compiler, offset, reg->idx[0].rel_addr);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2021-02-17 03:21:07 -08:00
|
|
|
else
|
2021-02-17 03:21:08 -08:00
|
|
|
{
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%u%s", offset, compiler->colours.reset);
|
|
|
|
}
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2021-07-08 21:33:41 -07:00
|
|
|
/* For sm 5.1 descriptor declarations we need to print the register range instead of
|
|
|
|
* a single register index. */
|
|
|
|
if (is_descriptor && is_declaration && is_sm_5_1)
|
|
|
|
{
|
|
|
|
shader_print_subscript_range(compiler, reg->idx[1].offset, reg->idx[2].offset);
|
|
|
|
}
|
2023-05-17 22:51:53 -07:00
|
|
|
else if (reg->type != VKD3DSPR_SSA)
|
2021-07-08 21:33:41 -07:00
|
|
|
{
|
|
|
|
/* For descriptors in sm < 5.1 we move the reg->idx values up one slot
|
|
|
|
* to normalise with 5.1.
|
|
|
|
* Here we should ignore it if it's a descriptor in sm < 5.1. */
|
|
|
|
if (reg->idx[1].offset != ~0u && (!is_descriptor || is_sm_5_1))
|
|
|
|
shader_print_subscript(compiler, reg->idx[1].offset, reg->idx[1].rel_addr);
|
|
|
|
|
|
|
|
if (reg->idx[2].offset != ~0u)
|
|
|
|
shader_print_subscript(compiler, reg->idx[2].offset, reg->idx[2].rel_addr);
|
|
|
|
}
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2021-02-17 03:21:07 -08:00
|
|
|
else
|
|
|
|
{
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", compiler->colours.reset);
|
2021-02-17 03:21:07 -08:00
|
|
|
}
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
if (reg->type == VKD3DSPR_FUNCTIONPOINTER)
|
2021-02-17 03:21:08 -08:00
|
|
|
shader_print_subscript(compiler, reg->u.fp_body_idx, NULL);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2021-02-17 03:21:07 -08:00
|
|
|
else
|
|
|
|
{
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", compiler->colours.reset);
|
2021-02-17 03:21:07 -08:00
|
|
|
}
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2021-09-28 07:07:22 -07:00
|
|
|
static void shader_print_precision(struct vkd3d_d3d_asm_compiler *compiler, const struct vkd3d_shader_register *reg)
|
|
|
|
{
|
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
|
|
|
const char *precision;
|
|
|
|
|
|
|
|
if (reg->precision == VKD3D_SHADER_REGISTER_PRECISION_DEFAULT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (reg->precision)
|
|
|
|
{
|
|
|
|
case VKD3D_SHADER_REGISTER_PRECISION_MIN_FLOAT_16:
|
|
|
|
precision = "min16f";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3D_SHADER_REGISTER_PRECISION_MIN_FLOAT_10:
|
|
|
|
precision = "min2_8f";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3D_SHADER_REGISTER_PRECISION_MIN_INT_16:
|
|
|
|
precision = "min16i";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3D_SHADER_REGISTER_PRECISION_MIN_UINT_16:
|
|
|
|
precision = "min16u";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
vkd3d_string_buffer_printf(buffer, " {%s<unhandled precision %#x>%s}",
|
|
|
|
compiler->colours.error, reg->precision, compiler->colours.reset);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
vkd3d_string_buffer_printf(buffer, " {%s%s%s}", compiler->colours.modifier, precision, compiler->colours.reset);
|
|
|
|
}
|
|
|
|
|
2021-09-28 07:07:23 -07:00
|
|
|
static void shader_print_non_uniform(struct vkd3d_d3d_asm_compiler *compiler, const struct vkd3d_shader_register *reg)
|
|
|
|
{
|
|
|
|
if (reg->non_uniform)
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, " {%snonuniform%s}",
|
|
|
|
compiler->colours.modifier, compiler->colours.reset);
|
|
|
|
}
|
|
|
|
|
2024-03-14 12:26:58 -07:00
|
|
|
static void shader_print_reg_type(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, const struct vkd3d_shader_register *reg, const char *suffix)
|
2023-11-30 03:09:04 -08:00
|
|
|
{
|
|
|
|
static const char *dimensions[] =
|
|
|
|
{
|
|
|
|
[VSIR_DIMENSION_NONE] = "",
|
|
|
|
[VSIR_DIMENSION_SCALAR] = "s:",
|
|
|
|
[VSIR_DIMENSION_VEC4] = "v4:",
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
|
|
|
const char *dimension;
|
|
|
|
|
2024-01-17 14:14:33 -08:00
|
|
|
if (!(compiler->flags & VSIR_ASM_FLAG_DUMP_TYPES))
|
2024-03-14 12:26:58 -07:00
|
|
|
{
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s", prefix, suffix);
|
2023-11-30 03:09:04 -08:00
|
|
|
return;
|
2024-03-14 12:26:58 -07:00
|
|
|
}
|
2023-11-30 03:09:04 -08:00
|
|
|
|
2024-03-14 14:39:46 -07:00
|
|
|
if (reg->data_type == VKD3D_DATA_UNUSED)
|
|
|
|
return;
|
|
|
|
|
2023-11-30 03:09:04 -08:00
|
|
|
if (reg->dimension < ARRAY_SIZE(dimensions))
|
|
|
|
dimension = dimensions[reg->dimension];
|
|
|
|
else
|
|
|
|
dimension = "??";
|
|
|
|
|
2024-03-14 12:26:58 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s <%s", prefix, dimension);
|
2023-11-30 03:09:04 -08:00
|
|
|
shader_dump_data_type(compiler, reg->data_type);
|
2024-03-14 12:26:58 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, ">%s", suffix);
|
2023-11-30 03:09:04 -08:00
|
|
|
}
|
|
|
|
|
2024-01-19 06:44:09 -08:00
|
|
|
static void shader_print_write_mask(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, uint32_t mask, const char *suffix)
|
|
|
|
{
|
|
|
|
unsigned int i = 0;
|
|
|
|
char buffer[5];
|
|
|
|
|
2024-01-17 14:30:06 -08:00
|
|
|
if (mask == 0)
|
|
|
|
{
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s", prefix, suffix);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-19 06:44:09 -08:00
|
|
|
if (mask & VKD3DSP_WRITEMASK_0)
|
|
|
|
buffer[i++] = 'x';
|
|
|
|
if (mask & VKD3DSP_WRITEMASK_1)
|
|
|
|
buffer[i++] = 'y';
|
|
|
|
if (mask & VKD3DSP_WRITEMASK_2)
|
|
|
|
buffer[i++] = 'z';
|
|
|
|
if (mask & VKD3DSP_WRITEMASK_3)
|
|
|
|
buffer[i++] = 'w';
|
|
|
|
buffer[i++] = '\0';
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s.%s%s%s%s", prefix,
|
|
|
|
compiler->colours.write_mask, buffer, compiler->colours.reset, suffix);
|
|
|
|
}
|
|
|
|
|
2024-03-14 11:23:41 -07:00
|
|
|
static void shader_print_dst_param(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, const struct vkd3d_shader_dst_param *param, bool is_declaration, const char *suffix)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
uint32_t write_mask = param->write_mask;
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2024-03-14 12:04:31 -07:00
|
|
|
shader_print_register(compiler, prefix, ¶m->reg, is_declaration, "");
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2023-08-29 15:33:50 -07:00
|
|
|
if (write_mask && param->reg.dimension == VSIR_DIMENSION_VEC4)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2024-01-22 08:15:36 -08:00
|
|
|
if (data_type_is_64_bit(param->reg.data_type))
|
2023-12-05 13:42:32 -08:00
|
|
|
write_mask = vsir_write_mask_32_from_64(write_mask);
|
2021-07-27 07:26:10 -07:00
|
|
|
|
2024-01-19 06:44:09 -08:00
|
|
|
shader_print_write_mask(compiler, "", write_mask, "");
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2021-09-28 07:07:22 -07:00
|
|
|
|
|
|
|
shader_print_precision(compiler, ¶m->reg);
|
2021-09-28 07:07:23 -07:00
|
|
|
shader_print_non_uniform(compiler, ¶m->reg);
|
2024-03-14 12:26:58 -07:00
|
|
|
shader_print_reg_type(compiler, "", ¶m->reg, suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-03-14 11:08:16 -07:00
|
|
|
static void shader_print_src_param(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, const struct vkd3d_shader_src_param *param, const char *suffix)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
enum vkd3d_shader_src_modifier src_modifier = param->modifiers;
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
|
|
|
uint32_t swizzle = param->swizzle;
|
2024-03-14 11:08:16 -07:00
|
|
|
const char *modifier = "";
|
2024-03-14 12:04:31 -07:00
|
|
|
bool is_abs = false;
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
if (src_modifier == VKD3DSPSM_NEG
|
|
|
|
|| src_modifier == VKD3DSPSM_BIASNEG
|
|
|
|
|| src_modifier == VKD3DSPSM_SIGNNEG
|
|
|
|
|| src_modifier == VKD3DSPSM_X2NEG
|
|
|
|
|| src_modifier == VKD3DSPSM_ABSNEG)
|
2024-03-14 11:08:16 -07:00
|
|
|
modifier = "-";
|
2018-05-29 03:50:32 -07:00
|
|
|
else if (src_modifier == VKD3DSPSM_COMP)
|
2024-03-14 11:08:16 -07:00
|
|
|
modifier = "1-";
|
2018-05-29 03:50:32 -07:00
|
|
|
else if (src_modifier == VKD3DSPSM_NOT)
|
2024-03-14 11:08:16 -07:00
|
|
|
modifier = "!";
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s", prefix, modifier);
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
if (src_modifier == VKD3DSPSM_ABS || src_modifier == VKD3DSPSM_ABSNEG)
|
2024-03-14 12:04:31 -07:00
|
|
|
is_abs = true;
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2024-03-14 12:04:31 -07:00
|
|
|
shader_print_register(compiler, is_abs ? "|" : "", ¶m->reg, false, "");
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
switch (src_modifier)
|
|
|
|
{
|
2024-03-14 11:08:16 -07:00
|
|
|
case VKD3DSPSM_NONE:
|
|
|
|
case VKD3DSPSM_NEG:
|
|
|
|
case VKD3DSPSM_COMP:
|
|
|
|
case VKD3DSPSM_ABS:
|
2020-09-16 16:14:44 -07:00
|
|
|
case VKD3DSPSM_ABSNEG:
|
2024-03-14 11:08:16 -07:00
|
|
|
case VKD3DSPSM_NOT:
|
|
|
|
break;
|
|
|
|
case VKD3DSPSM_BIAS:
|
|
|
|
case VKD3DSPSM_BIASNEG:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_bias");
|
|
|
|
break;
|
|
|
|
case VKD3DSPSM_SIGN:
|
|
|
|
case VKD3DSPSM_SIGNNEG:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_bx2");
|
|
|
|
break;
|
|
|
|
case VKD3DSPSM_X2:
|
|
|
|
case VKD3DSPSM_X2NEG:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_x2");
|
|
|
|
break;
|
|
|
|
case VKD3DSPSM_DZ:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_dz");
|
|
|
|
break;
|
|
|
|
case VKD3DSPSM_DW:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_dw");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_%s<unhandled modifier %#x>%s",
|
|
|
|
compiler->colours.error, src_modifier, compiler->colours.reset);
|
|
|
|
break;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2021-07-30 06:27:20 -07:00
|
|
|
if (param->reg.type != VKD3DSPR_IMMCONST && param->reg.type != VKD3DSPR_IMMCONST64
|
vkd3d-shader/d3d-asm: Use vkd3d_shader_register.dimension to know when to dump swizzle.
The assumption that sampler registers never have a swizzle is not
totally correct.
For instance, for the following shader:
Texture2D tex;
sampler sam;
float4 main() : sv_target
{
return tex.GatherGreen(sam, float2(0, 0));
}
the gather instruction is being disassembled as
gather4_indexable(texture2d) o0.xyzw, l(0.0, 0.0, 0.0, 0.0), t0.xyzw, s0
instead of
gather4_indexable(texture2d)(float,float,float,float) o0.xyzw, l(0.0, 0.0, 0.0, 0.0), t0.xyzw, s0.y
(notice the missing swizzle in the last parameter s0).
This is because the Gather instructions give the sampler register a vec4
dimension (and scalar swizzle type) to indicate the channel for the
gather operation.
The solution is using the new vkd3d_shader_register.dimension instead of
checking the swizzle type.
2023-08-15 22:33:43 -07:00
|
|
|
&& param->reg.dimension == VSIR_DIMENSION_VEC4)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
static const char swizzle_chars[] = "xyzw";
|
|
|
|
|
2024-01-22 08:15:36 -08:00
|
|
|
unsigned int swizzle_x, swizzle_y, swizzle_z, swizzle_w;
|
|
|
|
|
|
|
|
if (data_type_is_64_bit(param->reg.data_type))
|
|
|
|
swizzle = vsir_swizzle_32_from_64(swizzle);
|
|
|
|
|
|
|
|
swizzle_x = vsir_swizzle_get_component(swizzle, 0);
|
|
|
|
swizzle_y = vsir_swizzle_get_component(swizzle, 1);
|
|
|
|
swizzle_z = vsir_swizzle_get_component(swizzle, 2);
|
|
|
|
swizzle_w = vsir_swizzle_get_component(swizzle, 3);
|
|
|
|
|
2024-03-14 11:08:16 -07:00
|
|
|
if (swizzle_x == swizzle_y && swizzle_x == swizzle_z && swizzle_x == swizzle_w)
|
|
|
|
vkd3d_string_buffer_printf(buffer, ".%s%c%s", compiler->colours.swizzle,
|
2021-02-18 02:24:04 -08:00
|
|
|
swizzle_chars[swizzle_x], compiler->colours.reset);
|
2018-05-29 03:50:32 -07:00
|
|
|
else
|
2024-03-14 11:08:16 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, ".%s%c%c%c%c%s", compiler->colours.swizzle,
|
2021-02-18 02:24:04 -08:00
|
|
|
swizzle_chars[swizzle_x], swizzle_chars[swizzle_y],
|
|
|
|
swizzle_chars[swizzle_z], swizzle_chars[swizzle_w], compiler->colours.reset);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2024-03-14 11:08:16 -07:00
|
|
|
|
2024-03-14 12:04:31 -07:00
|
|
|
if (is_abs)
|
2024-03-14 11:08:16 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "|");
|
2021-09-28 07:07:22 -07:00
|
|
|
|
|
|
|
shader_print_precision(compiler, ¶m->reg);
|
2021-09-28 07:07:23 -07:00
|
|
|
shader_print_non_uniform(compiler, ¶m->reg);
|
2024-03-14 12:26:58 -07:00
|
|
|
shader_print_reg_type(compiler, "", ¶m->reg, suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
static void shader_dump_ins_modifiers(struct vkd3d_d3d_asm_compiler *compiler,
|
2018-05-29 03:50:32 -07:00
|
|
|
const struct vkd3d_shader_dst_param *dst)
|
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
|
|
|
uint32_t mmask = dst->modifiers;
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
switch (dst->shift)
|
|
|
|
{
|
2024-03-07 12:49:45 -08:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_d8");
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_d4");
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_d2");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_x2");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_x4");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_x8");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_unhandled_shift(%d)", dst->shift);
|
|
|
|
break;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-03-07 12:49:45 -08:00
|
|
|
if (mmask & VKD3DSPDM_SATURATE)
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_sat");
|
|
|
|
if (mmask & VKD3DSPDM_PARTIALPRECISION)
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_pp");
|
|
|
|
if (mmask & VKD3DSPDM_MSAMPCENTROID)
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_centroid");
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2023-08-29 13:17:28 -07:00
|
|
|
mmask &= ~VKD3DSPDM_MASK;
|
2018-05-29 03:50:32 -07:00
|
|
|
if (mmask) FIXME("Unrecognised modifier %#x.\n", mmask);
|
|
|
|
}
|
|
|
|
|
2024-04-04 08:19:25 -07:00
|
|
|
static void shader_print_primitive_type(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, const struct vkd3d_shader_primitive_type *p, const char *suffix)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
2024-04-04 08:19:25 -07:00
|
|
|
const char *primitive_type;
|
2021-02-16 05:58:25 -08:00
|
|
|
|
2024-04-04 08:19:25 -07:00
|
|
|
switch (p->type)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
case VKD3D_PT_UNDEFINED:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "undefined";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_POINTLIST:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "pointlist";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_LINELIST:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "linelist";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_LINESTRIP:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "linestrip";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_TRIANGLELIST:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "trianglelist";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_TRIANGLESTRIP:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "trianglestrip";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_TRIANGLEFAN:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "trianglefan";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_LINELIST_ADJ:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "linelist_adj";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_LINESTRIP_ADJ:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "linestrip_adj";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_TRIANGLELIST_ADJ:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "trianglelist_adj";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_TRIANGLESTRIP_ADJ:
|
2024-04-04 08:19:25 -07:00
|
|
|
primitive_type = "trianglestrip_adj";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3D_PT_PATCH:
|
2024-04-04 08:19:25 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%spatch%u%s", prefix, p->patch_vertex_count, suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
default:
|
2024-04-04 08:19:25 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s<unhandled primitive type %#x>%s%s",
|
|
|
|
prefix, compiler->colours.error, p->type, compiler->colours.reset, suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2024-04-04 08:19:25 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s%s", prefix, primitive_type, suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-04-11 08:25:11 -07:00
|
|
|
static void shader_print_interpolation_mode(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *prefix, enum vkd3d_shader_interpolation_mode m, const char *suffix)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
2024-04-11 08:25:11 -07:00
|
|
|
const char *mode;
|
2021-02-16 05:58:25 -08:00
|
|
|
|
2024-04-11 08:25:11 -07:00
|
|
|
switch (m)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
case VKD3DSIM_CONSTANT:
|
2024-04-11 08:25:11 -07:00
|
|
|
mode = "constant";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3DSIM_LINEAR:
|
2024-04-11 08:25:11 -07:00
|
|
|
mode = "linear";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3DSIM_LINEAR_CENTROID:
|
2024-04-11 08:25:11 -07:00
|
|
|
mode = "linear centroid";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3DSIM_LINEAR_NOPERSPECTIVE:
|
2024-04-11 08:25:11 -07:00
|
|
|
mode = "linear noperspective";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3DSIM_LINEAR_SAMPLE:
|
2024-04-11 08:25:11 -07:00
|
|
|
mode = "linear sample";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3DSIM_LINEAR_NOPERSPECTIVE_CENTROID:
|
2024-04-11 08:25:11 -07:00
|
|
|
mode = "linear noperspective centroid";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
case VKD3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE:
|
2024-04-11 08:25:11 -07:00
|
|
|
mode = "linear noperspective sample";
|
2018-05-29 03:50:32 -07:00
|
|
|
break;
|
|
|
|
default:
|
2024-04-11 08:25:11 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s<unhandled interpolation mode %#x>%s%s",
|
|
|
|
prefix, compiler->colours.error, m, compiler->colours.reset, suffix);
|
|
|
|
return;
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2024-04-11 08:25:11 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s%s", prefix, mode, suffix);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2019-01-31 02:29:27 -08:00
|
|
|
const char *shader_get_type_prefix(enum vkd3d_shader_type type)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2019-01-31 02:29:27 -08:00
|
|
|
switch (type)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
|
|
|
case VKD3D_SHADER_TYPE_VERTEX:
|
2019-01-31 02:29:27 -08:00
|
|
|
return "vs";
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
case VKD3D_SHADER_TYPE_HULL:
|
2019-01-31 02:29:27 -08:00
|
|
|
return "hs";
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
case VKD3D_SHADER_TYPE_DOMAIN:
|
2019-01-31 02:29:27 -08:00
|
|
|
return "ds";
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
case VKD3D_SHADER_TYPE_GEOMETRY:
|
2019-01-31 02:29:27 -08:00
|
|
|
return "gs";
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
case VKD3D_SHADER_TYPE_PIXEL:
|
2019-01-31 02:29:27 -08:00
|
|
|
return "ps";
|
2018-05-29 03:50:32 -07:00
|
|
|
|
|
|
|
case VKD3D_SHADER_TYPE_COMPUTE:
|
2019-01-31 02:29:27 -08:00
|
|
|
return "cs";
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2021-01-27 08:29:44 -08:00
|
|
|
case VKD3D_SHADER_TYPE_EFFECT:
|
|
|
|
return "fx";
|
|
|
|
|
|
|
|
case VKD3D_SHADER_TYPE_TEXTURE:
|
|
|
|
return "tx";
|
|
|
|
|
|
|
|
case VKD3D_SHADER_TYPE_LIBRARY:
|
|
|
|
return "lib";
|
|
|
|
|
2018-05-29 03:50:32 -07:00
|
|
|
default:
|
2019-01-31 02:29:27 -08:00
|
|
|
FIXME("Unhandled shader type %#x.\n", type);
|
|
|
|
return "unknown";
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
2018-06-05 04:52:56 -07:00
|
|
|
}
|
|
|
|
|
2021-02-16 05:58:24 -08:00
|
|
|
static void shader_dump_instruction_flags(struct vkd3d_d3d_asm_compiler *compiler,
|
2021-02-16 05:58:25 -08:00
|
|
|
const struct vkd3d_shader_instruction *ins)
|
2018-06-05 04:52:57 -07:00
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
|
|
|
|
2024-04-24 11:34:42 -07:00
|
|
|
switch (ins->opcode)
|
2018-06-05 04:52:57 -07:00
|
|
|
{
|
|
|
|
case VKD3DSIH_BREAKP:
|
|
|
|
case VKD3DSIH_CONTINUEP:
|
2023-04-20 19:20:33 -07:00
|
|
|
case VKD3DSIH_DISCARD:
|
2018-06-05 04:52:57 -07:00
|
|
|
case VKD3DSIH_IF:
|
|
|
|
case VKD3DSIH_RETP:
|
|
|
|
switch (ins->flags)
|
|
|
|
{
|
2024-03-07 12:49:45 -08:00
|
|
|
case VKD3D_SHADER_CONDITIONAL_OP_NZ:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_nz");
|
|
|
|
break;
|
|
|
|
case VKD3D_SHADER_CONDITIONAL_OP_Z:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_z");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_unrecognized(%#x)", ins->flags);
|
|
|
|
break;
|
2018-06-05 04:52:57 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_IFC:
|
|
|
|
case VKD3DSIH_BREAKC:
|
|
|
|
switch (ins->flags)
|
|
|
|
{
|
2024-03-07 12:49:45 -08:00
|
|
|
case VKD3D_SHADER_REL_OP_GT:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_gt");
|
|
|
|
break;
|
|
|
|
case VKD3D_SHADER_REL_OP_EQ:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_eq");
|
|
|
|
break;
|
|
|
|
case VKD3D_SHADER_REL_OP_GE:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_ge");
|
|
|
|
break;
|
|
|
|
case VKD3D_SHADER_REL_OP_LT:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_lt");
|
|
|
|
break;
|
|
|
|
case VKD3D_SHADER_REL_OP_NE:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_ne");
|
|
|
|
break;
|
|
|
|
case VKD3D_SHADER_REL_OP_LE:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_le");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_(%u)", ins->flags);
|
|
|
|
break;
|
2018-06-05 04:52:57 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_RESINFO:
|
|
|
|
switch (ins->flags)
|
|
|
|
{
|
2024-03-07 12:49:45 -08:00
|
|
|
case VKD3DSI_NONE:
|
|
|
|
break;
|
|
|
|
case VKD3DSI_RESINFO_RCP_FLOAT:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_rcpFloat");
|
|
|
|
break;
|
|
|
|
case VKD3DSI_RESINFO_UINT:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_uint");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_unrecognized(%#x)", ins->flags);
|
|
|
|
break;
|
2018-06-05 04:52:57 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_SAMPLE_INFO:
|
|
|
|
switch (ins->flags)
|
|
|
|
{
|
2024-03-07 12:49:45 -08:00
|
|
|
case VKD3DSI_NONE:
|
|
|
|
break;
|
|
|
|
case VKD3DSI_SAMPLE_INFO_UINT:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_uint");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "_unrecognized(%#x)", ins->flags);
|
|
|
|
break;
|
2018-06-05 04:52:57 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2024-02-29 22:03:47 -08:00
|
|
|
case VKD3DSIH_IMM_ATOMIC_CMP_EXCH:
|
|
|
|
case VKD3DSIH_IMM_ATOMIC_IADD:
|
|
|
|
case VKD3DSIH_IMM_ATOMIC_AND:
|
|
|
|
case VKD3DSIH_IMM_ATOMIC_IMAX:
|
|
|
|
case VKD3DSIH_IMM_ATOMIC_IMIN:
|
|
|
|
case VKD3DSIH_IMM_ATOMIC_OR:
|
|
|
|
case VKD3DSIH_IMM_ATOMIC_UMAX:
|
|
|
|
case VKD3DSIH_IMM_ATOMIC_UMIN:
|
|
|
|
case VKD3DSIH_IMM_ATOMIC_EXCH:
|
|
|
|
case VKD3DSIH_IMM_ATOMIC_XOR:
|
|
|
|
shader_dump_atomic_op_flags(compiler, ins->flags);
|
|
|
|
break;
|
|
|
|
|
2018-06-05 04:52:57 -07:00
|
|
|
case VKD3DSIH_SYNC:
|
2021-02-16 05:58:25 -08:00
|
|
|
shader_dump_sync_flags(compiler, ins->flags);
|
2018-06-05 04:52:57 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_TEX:
|
2024-05-21 12:38:44 -07:00
|
|
|
if (vkd3d_shader_ver_ge(&compiler->shader_version, 2, 0))
|
|
|
|
{
|
|
|
|
if (ins->flags & VKD3DSI_TEXLD_PROJECT)
|
|
|
|
vkd3d_string_buffer_printf(buffer, "p");
|
|
|
|
else if (ins->flags & VKD3DSI_TEXLD_BIAS)
|
|
|
|
vkd3d_string_buffer_printf(buffer, "b");
|
|
|
|
}
|
2018-06-05 04:52:57 -07:00
|
|
|
break;
|
|
|
|
|
2024-04-23 04:28:21 -07:00
|
|
|
case VKD3DSIH_WAVE_OP_ADD:
|
|
|
|
case VKD3DSIH_WAVE_OP_IMAX:
|
|
|
|
case VKD3DSIH_WAVE_OP_IMIN:
|
|
|
|
case VKD3DSIH_WAVE_OP_MAX:
|
|
|
|
case VKD3DSIH_WAVE_OP_MIN:
|
|
|
|
case VKD3DSIH_WAVE_OP_MUL:
|
|
|
|
case VKD3DSIH_WAVE_OP_UMAX:
|
|
|
|
case VKD3DSIH_WAVE_OP_UMIN:
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, (ins->flags & VKD3DSI_WAVE_PREFIX) ? "_prefix" : "_active");
|
|
|
|
break;
|
|
|
|
|
2023-11-22 05:58:44 -08:00
|
|
|
case VKD3DSIH_ISHL:
|
|
|
|
case VKD3DSIH_ISHR:
|
|
|
|
case VKD3DSIH_USHR:
|
|
|
|
if (ins->flags & VKD3DSI_SHIFT_UNMASKED)
|
2024-03-07 12:49:45 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, "_unmasked");
|
2023-11-22 05:58:44 -08:00
|
|
|
/* fall through */
|
2018-06-05 04:52:57 -07:00
|
|
|
default:
|
2021-02-16 05:58:25 -08:00
|
|
|
shader_dump_precise_flags(compiler, ins->flags);
|
2018-06-05 04:52:57 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
static void shader_dump_register_space(struct vkd3d_d3d_asm_compiler *compiler, unsigned int register_space)
|
2019-04-29 02:38:15 -07:00
|
|
|
{
|
2023-10-30 09:14:26 -07:00
|
|
|
if (vkd3d_shader_ver_ge(&compiler->shader_version, 5, 1))
|
2021-02-17 03:21:11 -08:00
|
|
|
shader_print_uint_literal(compiler, ", space=", register_space, "");
|
2019-04-29 02:38:15 -07:00
|
|
|
}
|
|
|
|
|
2021-02-16 05:58:26 -08:00
|
|
|
static void shader_print_opcode(struct vkd3d_d3d_asm_compiler *compiler, enum vkd3d_shader_opcode opcode)
|
|
|
|
{
|
2021-02-16 05:58:27 -08:00
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s%s%s", compiler->colours.opcode,
|
|
|
|
shader_opcode_names[opcode], compiler->colours.reset);
|
2021-02-16 05:58:26 -08:00
|
|
|
}
|
|
|
|
|
2023-11-13 06:50:30 -08:00
|
|
|
static void shader_dump_icb(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const struct vkd3d_shader_immediate_constant_buffer *icb)
|
|
|
|
{
|
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
|
|
|
unsigned int i, j;
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, " {\n");
|
|
|
|
if (icb->component_count == 1)
|
|
|
|
{
|
|
|
|
for (i = 0; i < icb->element_count; )
|
|
|
|
{
|
|
|
|
for (j = 0; i < icb->element_count && j < 4; ++i, ++j)
|
|
|
|
shader_print_hex_literal(compiler, !j ? " " : ", ", icb->data[i], "");
|
|
|
|
vkd3d_string_buffer_printf(buffer, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
assert(icb->component_count == VKD3D_VEC4_SIZE);
|
|
|
|
for (i = 0; i < icb->element_count; ++i)
|
|
|
|
{
|
|
|
|
shader_print_hex_literal(compiler, " {", icb->data[4 * i + 0], "");
|
|
|
|
shader_print_hex_literal(compiler, ", ", icb->data[4 * i + 1], "");
|
|
|
|
shader_print_hex_literal(compiler, ", ", icb->data[4 * i + 2], "");
|
|
|
|
shader_print_hex_literal(compiler, ", ", icb->data[4 * i + 3], "},\n");
|
|
|
|
}
|
|
|
|
}
|
2024-03-07 12:49:45 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, "}");
|
2023-11-13 06:50:30 -08:00
|
|
|
}
|
|
|
|
|
2021-02-16 05:58:24 -08:00
|
|
|
static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
|
2021-02-16 05:58:25 -08:00
|
|
|
const struct vkd3d_shader_instruction *ins)
|
2018-06-05 04:52:58 -07:00
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
2018-06-05 04:52:58 -07:00
|
|
|
unsigned int i;
|
|
|
|
|
2023-11-09 14:31:27 -08:00
|
|
|
compiler->current = ins;
|
|
|
|
|
2021-02-16 05:58:26 -08:00
|
|
|
if (ins->predicate)
|
2024-03-14 11:08:16 -07:00
|
|
|
shader_print_src_param(compiler, "(", ins->predicate, ") ");
|
2021-02-16 05:58:26 -08:00
|
|
|
|
|
|
|
/* PixWin marks instructions with the coissue flag with a '+' */
|
|
|
|
if (ins->coissue)
|
|
|
|
vkd3d_string_buffer_printf(buffer, "+");
|
|
|
|
|
2024-04-24 11:34:42 -07:00
|
|
|
shader_print_opcode(compiler, ins->opcode);
|
2021-02-16 05:58:26 -08:00
|
|
|
|
2024-04-24 11:34:42 -07:00
|
|
|
switch (ins->opcode)
|
2018-06-05 04:52:58 -07:00
|
|
|
{
|
|
|
|
case VKD3DSIH_DCL:
|
|
|
|
case VKD3DSIH_DCL_UAV_TYPED:
|
2021-02-16 05:58:27 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", compiler->colours.opcode);
|
2024-04-03 10:42:03 -07:00
|
|
|
shader_print_dcl_usage(compiler, "_", &ins->declaration.semantic, ins->flags, "");
|
2021-02-16 05:58:25 -08:00
|
|
|
shader_dump_ins_modifiers(compiler, &ins->declaration.semantic.resource.reg);
|
2024-03-14 12:04:31 -07:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", compiler->colours.reset);
|
|
|
|
shader_print_register(compiler, " ", &ins->declaration.semantic.resource.reg.reg, true, "");
|
2021-06-23 21:03:46 -07:00
|
|
|
shader_dump_register_space(compiler, ins->declaration.semantic.resource.range.space);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_CONSTANT_BUFFER:
|
2024-03-14 12:04:31 -07:00
|
|
|
shader_print_register(compiler, " ", &ins->declaration.cb.src.reg, true, "");
|
2023-10-30 09:14:26 -07:00
|
|
|
if (vkd3d_shader_ver_ge(&compiler->shader_version, 6, 0))
|
2021-02-17 03:21:08 -08:00
|
|
|
shader_print_subscript(compiler, ins->declaration.cb.size, NULL);
|
2023-10-30 09:14:26 -07:00
|
|
|
else if (vkd3d_shader_ver_ge(&compiler->shader_version, 5, 1))
|
2023-10-18 20:15:46 -07:00
|
|
|
shader_print_subscript(compiler, ins->declaration.cb.size / VKD3D_VEC4_SIZE / sizeof(float), NULL);
|
2024-03-07 12:49:45 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, ", %s",
|
2018-06-05 04:52:58 -07:00
|
|
|
ins->flags & VKD3DSI_INDEXED_DYNAMIC ? "dynamicIndexed" : "immediateIndexed");
|
2021-06-23 21:03:48 -07:00
|
|
|
shader_dump_register_space(compiler, ins->declaration.cb.range.space);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_FUNCTION_BODY:
|
2021-02-16 05:58:26 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, " fb%u", ins->declaration.index);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_FUNCTION_TABLE:
|
2021-02-16 05:58:26 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, " ft%u = {...}", ins->declaration.index);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_GLOBAL_FLAGS:
|
2021-02-16 05:58:26 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, " ");
|
2023-10-02 21:50:09 -07:00
|
|
|
shader_dump_global_flags(compiler, ins->declaration.global_flags);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_HS_MAX_TESSFACTOR:
|
2021-02-17 03:21:09 -08:00
|
|
|
shader_print_float_literal(compiler, " ", ins->declaration.max_tessellation_factor, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER:
|
2023-11-13 06:50:30 -08:00
|
|
|
shader_dump_icb(compiler, ins->declaration.icb);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_INDEX_RANGE:
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.index_range.dst, true, "");
|
2021-02-17 03:21:11 -08:00
|
|
|
shader_print_uint_literal(compiler, " ", ins->declaration.index_range.register_count, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_INDEXABLE_TEMP:
|
2021-02-17 03:21:08 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, " %sx%u%s", compiler->colours.reg,
|
|
|
|
ins->declaration.indexable_temp.register_idx, compiler->colours.reset);
|
|
|
|
shader_print_subscript(compiler, ins->declaration.indexable_temp.register_size, NULL);
|
2021-02-17 03:21:11 -08:00
|
|
|
shader_print_uint_literal(compiler, ", ", ins->declaration.indexable_temp.component_count, "");
|
2023-11-12 22:09:58 -08:00
|
|
|
if (ins->declaration.indexable_temp.alignment)
|
|
|
|
shader_print_uint_literal(compiler, ", align ", ins->declaration.indexable_temp.alignment, "");
|
2023-11-13 06:50:30 -08:00
|
|
|
if (ins->declaration.indexable_temp.initialiser)
|
|
|
|
shader_dump_icb(compiler, ins->declaration.indexable_temp.initialiser);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_INPUT_PS:
|
2024-04-11 08:25:11 -07:00
|
|
|
shader_print_interpolation_mode(compiler, " ", ins->flags, "");
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.dst, true, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_INPUT_PS_SGV:
|
|
|
|
case VKD3DSIH_DCL_INPUT_SGV:
|
|
|
|
case VKD3DSIH_DCL_INPUT_SIV:
|
|
|
|
case VKD3DSIH_DCL_OUTPUT_SIV:
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.register_semantic.reg, true, "");
|
2024-03-14 13:31:08 -07:00
|
|
|
shader_print_input_sysval_semantic(compiler, ", ", ins->declaration.register_semantic.sysval_semantic, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_INPUT_PS_SIV:
|
2024-04-11 08:25:11 -07:00
|
|
|
shader_print_interpolation_mode(compiler, " ", ins->flags, "");
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.register_semantic.reg, true, "");
|
2024-03-14 13:31:08 -07:00
|
|
|
shader_print_input_sysval_semantic(compiler, ", ", ins->declaration.register_semantic.sysval_semantic, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_INPUT:
|
|
|
|
case VKD3DSIH_DCL_OUTPUT:
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.dst, true, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_INPUT_PRIMITIVE:
|
|
|
|
case VKD3DSIH_DCL_OUTPUT_TOPOLOGY:
|
2024-04-04 08:19:25 -07:00
|
|
|
shader_print_primitive_type(compiler, " ", &ins->declaration.primitive_type, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_INTERFACE:
|
2021-02-17 03:21:08 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, " fp%u", ins->declaration.fp.index);
|
|
|
|
shader_print_subscript(compiler, ins->declaration.fp.array_size, NULL);
|
|
|
|
shader_print_subscript(compiler, ins->declaration.fp.body_count, NULL);
|
|
|
|
vkd3d_string_buffer_printf(buffer, " = {...}");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_RESOURCE_RAW:
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.raw_resource.resource.reg, true, "");
|
2021-06-23 21:03:46 -07:00
|
|
|
shader_dump_register_space(compiler, ins->declaration.raw_resource.resource.range.space);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_RESOURCE_STRUCTURED:
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.structured_resource.resource.reg, true, "");
|
2021-02-17 03:21:11 -08:00
|
|
|
shader_print_uint_literal(compiler, ", ", ins->declaration.structured_resource.byte_stride, "");
|
2021-06-23 21:03:46 -07:00
|
|
|
shader_dump_register_space(compiler, ins->declaration.structured_resource.resource.range.space);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_SAMPLER:
|
2024-03-14 12:04:31 -07:00
|
|
|
shader_print_register(compiler, " ", &ins->declaration.sampler.src.reg, true,
|
|
|
|
ins->flags == VKD3DSI_SAMPLER_COMPARISON_MODE ? ", comparisonMode" : "");
|
2021-06-23 21:03:47 -07:00
|
|
|
shader_dump_register_space(compiler, ins->declaration.sampler.range.space);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_TEMPS:
|
|
|
|
case VKD3DSIH_DCL_GS_INSTANCES:
|
|
|
|
case VKD3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT:
|
|
|
|
case VKD3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT:
|
|
|
|
case VKD3DSIH_DCL_INPUT_CONTROL_POINT_COUNT:
|
|
|
|
case VKD3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT:
|
|
|
|
case VKD3DSIH_DCL_VERTICES_OUT:
|
2021-02-17 03:21:11 -08:00
|
|
|
shader_print_uint_literal(compiler, " ", ins->declaration.count, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_TESSELLATOR_DOMAIN:
|
2024-03-11 09:33:29 -07:00
|
|
|
shader_print_tessellator_domain(compiler, " ", ins->declaration.tessellator_domain, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE:
|
2024-03-11 09:42:09 -07:00
|
|
|
shader_print_tessellator_output_primitive(compiler, " ", ins->declaration.tessellator_output_primitive, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_TESSELLATOR_PARTITIONING:
|
2024-03-11 09:51:27 -07:00
|
|
|
shader_print_tessellator_partitioning(compiler, " ", ins->declaration.tessellator_partitioning, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_TGSM_RAW:
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.tgsm_raw.reg, true, "");
|
2021-02-17 03:21:11 -08:00
|
|
|
shader_print_uint_literal(compiler, ", ", ins->declaration.tgsm_raw.byte_count, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_TGSM_STRUCTURED:
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.tgsm_structured.reg, true, "");
|
2021-02-17 03:21:11 -08:00
|
|
|
shader_print_uint_literal(compiler, ", ", ins->declaration.tgsm_structured.byte_stride, "");
|
|
|
|
shader_print_uint_literal(compiler, ", ", ins->declaration.tgsm_structured.structure_count, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_THREAD_GROUP:
|
2021-02-17 03:21:11 -08:00
|
|
|
shader_print_uint_literal(compiler, " ", ins->declaration.thread_group_size.x, "");
|
|
|
|
shader_print_uint_literal(compiler, ", ", ins->declaration.thread_group_size.y, "");
|
|
|
|
shader_print_uint_literal(compiler, ", ", ins->declaration.thread_group_size.z, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_UAV_RAW:
|
2021-02-16 05:58:25 -08:00
|
|
|
shader_dump_uav_flags(compiler, ins->flags);
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.raw_resource.resource.reg, true, "");
|
2021-06-23 21:03:46 -07:00
|
|
|
shader_dump_register_space(compiler, ins->declaration.raw_resource.resource.range.space);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DCL_UAV_STRUCTURED:
|
2021-02-16 05:58:25 -08:00
|
|
|
shader_dump_uav_flags(compiler, ins->flags);
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, " ", &ins->declaration.structured_resource.resource.reg, true, "");
|
2021-02-17 03:21:11 -08:00
|
|
|
shader_print_uint_literal(compiler, ", ", ins->declaration.structured_resource.byte_stride, "");
|
2021-06-23 21:03:46 -07:00
|
|
|
shader_dump_register_space(compiler, ins->declaration.structured_resource.resource.range.space);
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DEF:
|
2021-02-17 03:21:09 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, " %sc%u%s", compiler->colours.reg,
|
|
|
|
shader_get_float_offset(ins->dst[0].reg.type, ins->dst[0].reg.idx[0].offset),
|
|
|
|
compiler->colours.reset);
|
2023-12-05 14:29:04 -08:00
|
|
|
shader_print_float_literal(compiler, " = ", ins->src[0].reg.u.immconst_f32[0], "");
|
|
|
|
shader_print_float_literal(compiler, ", ", ins->src[0].reg.u.immconst_f32[1], "");
|
|
|
|
shader_print_float_literal(compiler, ", ", ins->src[0].reg.u.immconst_f32[2], "");
|
|
|
|
shader_print_float_literal(compiler, ", ", ins->src[0].reg.u.immconst_f32[3], "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DEFI:
|
2021-02-17 03:21:10 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, " %si%u%s", compiler->colours.reg,
|
|
|
|
ins->dst[0].reg.idx[0].offset, compiler->colours.reset);
|
2023-12-05 14:24:36 -08:00
|
|
|
shader_print_int_literal(compiler, " = ", ins->src[0].reg.u.immconst_u32[0], "");
|
|
|
|
shader_print_int_literal(compiler, ", ", ins->src[0].reg.u.immconst_u32[1], "");
|
|
|
|
shader_print_int_literal(compiler, ", ", ins->src[0].reg.u.immconst_u32[2], "");
|
|
|
|
shader_print_int_literal(compiler, ", ", ins->src[0].reg.u.immconst_u32[3], "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VKD3DSIH_DEFB:
|
2021-02-18 02:24:01 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, " %sb%u%s", compiler->colours.reg,
|
|
|
|
ins->dst[0].reg.idx[0].offset, compiler->colours.reset);
|
2023-12-05 14:24:36 -08:00
|
|
|
shader_print_bool_literal(compiler, " = ", ins->src[0].reg.u.immconst_u32[0], "");
|
2018-06-05 04:52:58 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-02-16 05:58:25 -08:00
|
|
|
shader_dump_instruction_flags(compiler, ins);
|
2018-06-05 04:52:58 -07:00
|
|
|
|
2020-09-04 15:57:04 -07:00
|
|
|
if (ins->resource_type != VKD3D_SHADER_RESOURCE_NONE)
|
|
|
|
{
|
2024-03-07 12:49:45 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, "_indexable(");
|
2021-02-19 06:57:12 -08:00
|
|
|
if (ins->raw)
|
|
|
|
vkd3d_string_buffer_printf(buffer, "raw_");
|
|
|
|
if (ins->structured)
|
|
|
|
vkd3d_string_buffer_printf(buffer, "structured_");
|
2021-02-16 05:58:25 -08:00
|
|
|
shader_dump_resource_type(compiler, ins->resource_type);
|
2021-02-19 06:57:11 -08:00
|
|
|
if (ins->resource_stride)
|
|
|
|
shader_print_uint_literal(compiler, ", stride=", ins->resource_stride, "");
|
2024-03-07 12:49:45 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, ")");
|
2020-09-04 15:57:04 -07:00
|
|
|
}
|
|
|
|
|
2021-02-19 06:57:11 -08:00
|
|
|
if (vkd3d_shader_instruction_has_texel_offset(ins))
|
|
|
|
{
|
|
|
|
shader_print_int_literal(compiler, "(", ins->texel_offset.u, "");
|
|
|
|
shader_print_int_literal(compiler, ",", ins->texel_offset.v, "");
|
|
|
|
shader_print_int_literal(compiler, ",", ins->texel_offset.w, ")");
|
|
|
|
}
|
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
if (ins->resource_data_type[0] != VKD3D_DATA_FLOAT
|
|
|
|
|| ins->resource_data_type[1] != VKD3D_DATA_FLOAT
|
|
|
|
|| ins->resource_data_type[2] != VKD3D_DATA_FLOAT
|
|
|
|
|| ins->resource_data_type[3] != VKD3D_DATA_FLOAT)
|
2023-11-30 02:53:11 -08:00
|
|
|
shader_dump_resource_data_type(compiler, ins->resource_data_type);
|
2020-09-04 15:57:05 -07:00
|
|
|
|
2018-06-05 04:52:58 -07:00
|
|
|
for (i = 0; i < ins->dst_count; ++i)
|
|
|
|
{
|
2021-02-16 05:58:25 -08:00
|
|
|
shader_dump_ins_modifiers(compiler, &ins->dst[i]);
|
2024-03-14 11:23:41 -07:00
|
|
|
shader_print_dst_param(compiler, !i ? " " : ", ", &ins->dst[i], false, "");
|
2018-06-05 04:52:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Other source tokens */
|
|
|
|
for (i = ins->dst_count; i < (ins->dst_count + ins->src_count); ++i)
|
|
|
|
{
|
2024-03-14 11:08:16 -07:00
|
|
|
shader_print_src_param(compiler, !i ? " " : ", ", &ins->src[i - ins->dst_count], "");
|
2018-06-05 04:52:58 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-03-07 12:49:45 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, "\n");
|
2018-06-05 04:52:58 -07:00
|
|
|
}
|
|
|
|
|
2024-01-17 14:30:06 -08:00
|
|
|
static const char *get_sysval_semantic_name(enum vkd3d_shader_sysval_semantic semantic)
|
|
|
|
{
|
|
|
|
switch (semantic)
|
|
|
|
{
|
|
|
|
case VKD3D_SHADER_SV_NONE: return "NONE";
|
|
|
|
case VKD3D_SHADER_SV_POSITION: return "POS";
|
|
|
|
case VKD3D_SHADER_SV_CLIP_DISTANCE: return "CLIPDST";
|
|
|
|
case VKD3D_SHADER_SV_CULL_DISTANCE: return "CULLDST";
|
|
|
|
case VKD3D_SHADER_SV_RENDER_TARGET_ARRAY_INDEX: return "RTINDEX";
|
|
|
|
case VKD3D_SHADER_SV_VIEWPORT_ARRAY_INDEX: return "VPINDEX";
|
|
|
|
case VKD3D_SHADER_SV_VERTEX_ID: return "VERTID";
|
|
|
|
case VKD3D_SHADER_SV_PRIMITIVE_ID: return "PRIMID";
|
|
|
|
case VKD3D_SHADER_SV_INSTANCE_ID: return "INSTID";
|
|
|
|
case VKD3D_SHADER_SV_IS_FRONT_FACE: return "FFACE";
|
|
|
|
case VKD3D_SHADER_SV_SAMPLE_INDEX: return "SAMPLE";
|
|
|
|
case VKD3D_SHADER_SV_TESS_FACTOR_QUADEDGE: return "QUADEDGE";
|
|
|
|
case VKD3D_SHADER_SV_TESS_FACTOR_QUADINT: return "QUADINT";
|
|
|
|
case VKD3D_SHADER_SV_TESS_FACTOR_TRIEDGE: return "TRIEDGE";
|
|
|
|
case VKD3D_SHADER_SV_TESS_FACTOR_TRIINT: return "TRIINT";
|
|
|
|
case VKD3D_SHADER_SV_TESS_FACTOR_LINEDET: return "LINEDET";
|
|
|
|
case VKD3D_SHADER_SV_TESS_FACTOR_LINEDEN: return "LINEDEN";
|
|
|
|
case VKD3D_SHADER_SV_TARGET: return "TARGET";
|
|
|
|
case VKD3D_SHADER_SV_DEPTH: return "DEPTH";
|
|
|
|
case VKD3D_SHADER_SV_COVERAGE: return "COVERAGE";
|
|
|
|
case VKD3D_SHADER_SV_DEPTH_GREATER_EQUAL: return "DEPTHGE";
|
|
|
|
case VKD3D_SHADER_SV_DEPTH_LESS_EQUAL: return "DEPTHLE";
|
|
|
|
case VKD3D_SHADER_SV_STENCIL_REF: return "STENCILREF";
|
|
|
|
default: return "??";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *get_component_type_name(enum vkd3d_shader_component_type type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case VKD3D_SHADER_COMPONENT_VOID: return "void";
|
|
|
|
case VKD3D_SHADER_COMPONENT_UINT: return "uint";
|
|
|
|
case VKD3D_SHADER_COMPONENT_INT: return "int";
|
|
|
|
case VKD3D_SHADER_COMPONENT_FLOAT: return "float";
|
|
|
|
case VKD3D_SHADER_COMPONENT_BOOL: return "bool";
|
|
|
|
case VKD3D_SHADER_COMPONENT_DOUBLE: return "double";
|
|
|
|
case VKD3D_SHADER_COMPONENT_UINT64: return "uint64";
|
|
|
|
default: return "??";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *get_minimum_precision_name(enum vkd3d_shader_minimum_precision prec)
|
|
|
|
{
|
|
|
|
switch (prec)
|
|
|
|
{
|
|
|
|
case VKD3D_SHADER_MINIMUM_PRECISION_NONE: return "NONE";
|
|
|
|
case VKD3D_SHADER_MINIMUM_PRECISION_FLOAT_16: return "FLOAT_16";
|
|
|
|
case VKD3D_SHADER_MINIMUM_PRECISION_FIXED_8_2: return "FIXED_8_2";
|
|
|
|
case VKD3D_SHADER_MINIMUM_PRECISION_INT_16: return "INT_16";
|
|
|
|
case VKD3D_SHADER_MINIMUM_PRECISION_UINT_16: return "UINT_16";
|
|
|
|
default: return "??";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *get_semantic_register_name(enum vkd3d_shader_sysval_semantic semantic)
|
|
|
|
{
|
|
|
|
switch (semantic)
|
|
|
|
{
|
|
|
|
case VKD3D_SHADER_SV_DEPTH: return "oDepth";
|
|
|
|
case VKD3D_SHADER_SV_DEPTH_GREATER_EQUAL: return "oDepthGE";
|
|
|
|
case VKD3D_SHADER_SV_DEPTH_LESS_EQUAL: return "oDepthLE";
|
|
|
|
/* SV_Coverage has name vCoverage when used as an input,
|
|
|
|
* but it doens't appear in the signature in that case. */
|
|
|
|
case VKD3D_SHADER_SV_COVERAGE: return "oMask";
|
|
|
|
case VKD3D_SHADER_SV_STENCIL_REF: return "oStencilRef";
|
|
|
|
default: return "??";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum vkd3d_result dump_signature(struct vkd3d_d3d_asm_compiler *compiler,
|
|
|
|
const char *name, const char *register_name, const struct shader_signature *signature)
|
|
|
|
{
|
|
|
|
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (signature->element_count == 0)
|
|
|
|
return VKD3D_OK;
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s%s\n",
|
|
|
|
compiler->colours.opcode, name, compiler->colours.reset);
|
|
|
|
|
|
|
|
for (i = 0; i < signature->element_count; ++i)
|
|
|
|
{
|
|
|
|
struct signature_element *element = &signature->elements[i];
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s.param%s %s", compiler->colours.opcode,
|
|
|
|
compiler->colours.reset, element->semantic_name);
|
|
|
|
|
|
|
|
if (element->semantic_index != 0)
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%u", element->semantic_index);
|
|
|
|
|
|
|
|
if (element->register_index != -1)
|
|
|
|
{
|
|
|
|
shader_print_write_mask(compiler, "", element->mask, "");
|
|
|
|
vkd3d_string_buffer_printf(buffer, ", %s%s%d%s", compiler->colours.reg,
|
|
|
|
register_name, element->register_index, compiler->colours.reset);
|
|
|
|
shader_print_write_mask(compiler, "", element->used_mask, "");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vkd3d_string_buffer_printf(buffer, ", %s%s%s", compiler->colours.reg,
|
|
|
|
get_semantic_register_name(element->sysval_semantic), compiler->colours.reset);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!element->component_type && !element->sysval_semantic
|
|
|
|
&& !element->min_precision && !element->stream_index)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, ", %s",
|
|
|
|
get_component_type_name(element->component_type));
|
|
|
|
|
|
|
|
if (!element->sysval_semantic && !element->min_precision && !element->stream_index)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, ", %s",
|
|
|
|
get_sysval_semantic_name(element->sysval_semantic));
|
|
|
|
|
|
|
|
if (!element->min_precision && !element->stream_index)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, ", %s",
|
|
|
|
get_minimum_precision_name(element->min_precision));
|
|
|
|
|
|
|
|
if (!element->stream_index)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(buffer, ", m%u",
|
|
|
|
element->stream_index);
|
|
|
|
|
|
|
|
done:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return VKD3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum vkd3d_result dump_signatures(struct vkd3d_d3d_asm_compiler *compiler,
|
2024-03-01 04:36:11 -08:00
|
|
|
const struct vsir_program *program)
|
2024-01-17 14:30:06 -08:00
|
|
|
{
|
|
|
|
enum vkd3d_result ret;
|
|
|
|
|
|
|
|
if ((ret = dump_signature(compiler, ".input",
|
2024-03-01 04:36:11 -08:00
|
|
|
program->shader_version.type == VKD3D_SHADER_TYPE_DOMAIN ? "vicp" : "v",
|
|
|
|
&program->input_signature)) < 0)
|
2024-01-17 14:30:06 -08:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
if ((ret = dump_signature(compiler, ".output", "o",
|
2024-03-01 04:36:11 -08:00
|
|
|
&program->output_signature)) < 0)
|
2024-01-17 14:30:06 -08:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
if ((ret = dump_signature(compiler, ".patch_constant",
|
2024-03-01 04:36:11 -08:00
|
|
|
program->shader_version.type == VKD3D_SHADER_TYPE_DOMAIN ? "vpc" : "o",
|
|
|
|
&program->patch_constant_signature)) < 0)
|
2024-01-17 14:30:06 -08:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(&compiler->buffer, "%s.text%s\n",
|
|
|
|
compiler->colours.opcode, compiler->colours.reset);
|
|
|
|
|
|
|
|
return VKD3D_OK;
|
|
|
|
}
|
|
|
|
|
2024-03-11 07:23:57 -07:00
|
|
|
enum vkd3d_result d3d_asm_compile(const struct vsir_program *program,
|
|
|
|
const struct vkd3d_shader_compile_info *compile_info,
|
2024-01-17 14:14:33 -08:00
|
|
|
struct vkd3d_shader_code *out, enum vsir_asm_flags flags)
|
2018-06-05 04:52:56 -07:00
|
|
|
{
|
2024-01-16 07:40:30 -08:00
|
|
|
const struct vkd3d_shader_version *shader_version = &program->shader_version;
|
2021-02-16 05:58:27 -08:00
|
|
|
enum vkd3d_shader_compile_option_formatting_flags formatting;
|
2023-11-30 03:09:04 -08:00
|
|
|
struct vkd3d_d3d_asm_compiler compiler =
|
|
|
|
{
|
2024-01-17 14:14:33 -08:00
|
|
|
.flags = flags,
|
2023-11-30 03:09:04 -08:00
|
|
|
};
|
2020-09-24 18:26:36 -07:00
|
|
|
enum vkd3d_result result = VKD3D_OK;
|
2021-02-16 05:58:25 -08:00
|
|
|
struct vkd3d_string_buffer *buffer;
|
2023-01-19 18:08:22 -08:00
|
|
|
unsigned int indent, i, j;
|
2021-02-19 06:57:08 -08:00
|
|
|
const char *indent_str;
|
2018-06-05 04:52:56 -07:00
|
|
|
|
2021-02-16 05:58:27 -08:00
|
|
|
static const struct vkd3d_d3d_asm_colours no_colours =
|
|
|
|
{
|
|
|
|
.reset = "",
|
2021-09-28 07:07:22 -07:00
|
|
|
.error = "",
|
2021-02-18 02:24:02 -08:00
|
|
|
.literal = "",
|
2021-09-28 07:07:22 -07:00
|
|
|
.modifier = "",
|
2021-02-16 05:58:27 -08:00
|
|
|
.opcode = "",
|
2021-02-17 03:21:07 -08:00
|
|
|
.reg = "",
|
2021-02-18 02:24:04 -08:00
|
|
|
.swizzle = "",
|
2021-02-19 06:57:07 -08:00
|
|
|
.version = "",
|
2021-02-18 02:24:03 -08:00
|
|
|
.write_mask = "",
|
2024-03-07 05:47:32 -08:00
|
|
|
.label = "",
|
2021-02-16 05:58:27 -08:00
|
|
|
};
|
|
|
|
static const struct vkd3d_d3d_asm_colours colours =
|
|
|
|
{
|
|
|
|
.reset = "\x1b[m",
|
2021-09-28 07:07:22 -07:00
|
|
|
.error = "\x1b[97;41m",
|
2021-02-18 02:24:02 -08:00
|
|
|
.literal = "\x1b[95m",
|
2021-09-28 07:07:22 -07:00
|
|
|
.modifier = "\x1b[36m",
|
2021-02-16 05:58:27 -08:00
|
|
|
.opcode = "\x1b[96;1m",
|
2021-02-17 03:21:07 -08:00
|
|
|
.reg = "\x1b[96m",
|
2021-02-18 02:24:04 -08:00
|
|
|
.swizzle = "\x1b[93m",
|
2021-02-19 06:57:07 -08:00
|
|
|
.version = "\x1b[36m",
|
2021-02-18 02:24:03 -08:00
|
|
|
.write_mask = "\x1b[93m",
|
2024-03-07 05:47:32 -08:00
|
|
|
.label = "\x1b[91m",
|
2021-02-16 05:58:27 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
formatting = VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT
|
|
|
|
| VKD3D_SHADER_COMPILE_OPTION_FORMATTING_HEADER;
|
|
|
|
if (compile_info)
|
|
|
|
{
|
|
|
|
for (i = 0; i < compile_info->option_count; ++i)
|
|
|
|
{
|
|
|
|
const struct vkd3d_shader_compile_option *option = &compile_info->options[i];
|
|
|
|
|
|
|
|
if (option->name == VKD3D_SHADER_COMPILE_OPTION_FORMATTING)
|
|
|
|
formatting = option->value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (formatting & VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR)
|
|
|
|
compiler.colours = colours;
|
|
|
|
else
|
|
|
|
compiler.colours = no_colours;
|
2021-02-19 06:57:08 -08:00
|
|
|
if (formatting & VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT)
|
|
|
|
indent_str = " ";
|
|
|
|
else
|
|
|
|
indent_str = "";
|
2021-02-16 05:58:27 -08:00
|
|
|
|
2021-02-16 05:58:25 -08:00
|
|
|
buffer = &compiler.buffer;
|
|
|
|
vkd3d_string_buffer_init(buffer);
|
2018-06-05 04:52:56 -07:00
|
|
|
|
2023-02-22 19:47:03 -08:00
|
|
|
compiler.shader_version = *shader_version;
|
2021-02-16 05:58:24 -08:00
|
|
|
shader_version = &compiler.shader_version;
|
2021-02-19 06:57:07 -08:00
|
|
|
vkd3d_string_buffer_printf(buffer, "%s%s_%u_%u%s\n", compiler.colours.version,
|
|
|
|
shader_get_type_prefix(shader_version->type), shader_version->major,
|
|
|
|
shader_version->minor, compiler.colours.reset);
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2024-03-08 02:07:20 -08:00
|
|
|
/* The signatures we emit only make sense for DXBC shaders. D3DBC
|
|
|
|
* doesn't even have an explicit concept of signature. */
|
|
|
|
if (formatting & VKD3D_SHADER_COMPILE_OPTION_FORMATTING_IO_SIGNATURES && shader_version->major >= 4)
|
2024-01-17 14:30:06 -08:00
|
|
|
{
|
2024-03-01 04:36:11 -08:00
|
|
|
if ((result = dump_signatures(&compiler, program)) < 0)
|
2024-01-17 14:30:06 -08:00
|
|
|
{
|
|
|
|
vkd3d_string_buffer_cleanup(buffer);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-19 06:57:08 -08:00
|
|
|
indent = 0;
|
2024-01-16 07:40:30 -08:00
|
|
|
for (i = 0; i < program->instructions.count; ++i)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2024-01-16 07:40:30 -08:00
|
|
|
struct vkd3d_shader_instruction *ins = &program->instructions.elements[i];
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2024-04-24 11:34:42 -07:00
|
|
|
switch (ins->opcode)
|
2021-02-19 06:57:08 -08:00
|
|
|
{
|
|
|
|
case VKD3DSIH_ELSE:
|
|
|
|
case VKD3DSIH_ENDIF:
|
|
|
|
case VKD3DSIH_ENDLOOP:
|
|
|
|
case VKD3DSIH_ENDSWITCH:
|
2022-11-09 16:24:50 -08:00
|
|
|
if (indent)
|
|
|
|
--indent;
|
2021-02-19 06:57:08 -08:00
|
|
|
break;
|
|
|
|
|
2024-02-29 15:01:55 -08:00
|
|
|
case VKD3DSIH_LABEL:
|
2024-04-08 14:45:11 -07:00
|
|
|
case VKD3DSIH_HS_DECLS:
|
|
|
|
case VKD3DSIH_HS_CONTROL_POINT_PHASE:
|
|
|
|
case VKD3DSIH_HS_FORK_PHASE:
|
|
|
|
case VKD3DSIH_HS_JOIN_PHASE:
|
2024-02-29 15:01:55 -08:00
|
|
|
indent = 0;
|
|
|
|
break;
|
|
|
|
|
2021-02-19 06:57:08 -08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-01-19 18:08:22 -08:00
|
|
|
for (j = 0; j < indent; ++j)
|
2021-02-19 06:57:08 -08:00
|
|
|
{
|
|
|
|
vkd3d_string_buffer_printf(buffer, "%s", indent_str);
|
|
|
|
}
|
|
|
|
|
2023-01-19 18:08:22 -08:00
|
|
|
shader_dump_instruction(&compiler, ins);
|
2021-02-19 06:57:08 -08:00
|
|
|
|
2024-04-24 11:34:42 -07:00
|
|
|
switch (ins->opcode)
|
2021-02-19 06:57:08 -08:00
|
|
|
{
|
|
|
|
case VKD3DSIH_ELSE:
|
|
|
|
case VKD3DSIH_IF:
|
2023-11-30 02:31:29 -08:00
|
|
|
case VKD3DSIH_IFC:
|
2021-02-19 06:57:08 -08:00
|
|
|
case VKD3DSIH_LOOP:
|
|
|
|
case VKD3DSIH_SWITCH:
|
2024-02-29 15:01:55 -08:00
|
|
|
case VKD3DSIH_LABEL:
|
2021-02-19 06:57:08 -08:00
|
|
|
++indent;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|
|
|
|
|
2024-01-10 07:16:23 -08:00
|
|
|
vkd3d_shader_code_from_string_buffer(out, buffer);
|
2020-09-24 18:26:36 -07:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-01-16 07:40:30 -08:00
|
|
|
void vkd3d_shader_trace(const struct vsir_program *program)
|
2020-09-24 18:26:36 -07:00
|
|
|
{
|
2020-10-15 08:44:44 -07:00
|
|
|
const char *p, *q, *end;
|
2020-09-24 18:26:36 -07:00
|
|
|
struct vkd3d_shader_code code;
|
|
|
|
|
2024-03-11 07:23:57 -07:00
|
|
|
if (d3d_asm_compile(program, NULL, &code, VSIR_ASM_FLAG_DUMP_TYPES) != VKD3D_OK)
|
2020-09-24 18:26:36 -07:00
|
|
|
return;
|
|
|
|
|
2020-10-15 08:44:44 -07:00
|
|
|
end = (const char *)code.code + code.size;
|
|
|
|
for (p = code.code; p < end; p = q)
|
2018-05-29 03:50:32 -07:00
|
|
|
{
|
2020-10-15 08:44:44 -07:00
|
|
|
if (!(q = memchr(p, '\n', end - p)))
|
|
|
|
q = end;
|
2018-05-29 03:50:32 -07:00
|
|
|
else
|
|
|
|
++q;
|
|
|
|
TRACE(" %.*s", (int)(q - p), p);
|
|
|
|
}
|
|
|
|
|
2020-09-24 18:26:36 -07:00
|
|
|
vkd3d_shader_free_shader_code(&code);
|
2018-05-29 03:50:32 -07:00
|
|
|
}
|