2017-06-16 13:38:21 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Józef Kucia 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
|
2017-06-16 13:38:21 -07:00
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following copyright and
|
|
|
|
* permission notice:
|
|
|
|
*
|
|
|
|
* Copyright 2002-2003 The wine-d3d team
|
|
|
|
* Copyright 2002-2003 2004 Jason Edmeades
|
|
|
|
* Copyright 2002-2003 Raphael Junqueira
|
|
|
|
* Copyright 2005 Oliver Stieber
|
|
|
|
* Copyright 2006 Stefan Dösinger
|
|
|
|
* Copyright 2006-2011, 2013 Stefan Dösinger for CodeWeavers
|
|
|
|
* Copyright 2007 Henri Verbeet
|
2017-06-16 13:38:21 -07:00
|
|
|
* Copyright 2008-2009 Henri Verbeet for CodeWeavers
|
2017-06-16 13:38:21 -07:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2017-06-16 13:38:21 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VKD3D_SHADER_PRIVATE_H
|
|
|
|
#define __VKD3D_SHADER_PRIVATE_H
|
|
|
|
|
2017-06-27 04:16:47 -07:00
|
|
|
#define NONAMELESSUNION
|
2017-06-16 13:38:21 -07:00
|
|
|
#include "vkd3d_common.h"
|
|
|
|
#include "vkd3d_memory.h"
|
|
|
|
#include "vkd3d_shader.h"
|
|
|
|
#include "list.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdbool.h>
|
2017-09-11 13:35:16 -07:00
|
|
|
#include <string.h>
|
|
|
|
#include <strings.h>
|
2017-06-16 13:38:21 -07:00
|
|
|
|
|
|
|
#define VKD3D_VEC4_SIZE 4
|
|
|
|
|
2017-06-16 13:38:21 -07:00
|
|
|
enum VKD3D_SHADER_INSTRUCTION_HANDLER
|
|
|
|
{
|
|
|
|
VKD3DSIH_ABS,
|
|
|
|
VKD3DSIH_ADD,
|
|
|
|
VKD3DSIH_AND,
|
|
|
|
VKD3DSIH_ATOMIC_AND,
|
|
|
|
VKD3DSIH_ATOMIC_CMP_STORE,
|
|
|
|
VKD3DSIH_ATOMIC_IADD,
|
|
|
|
VKD3DSIH_ATOMIC_IMAX,
|
|
|
|
VKD3DSIH_ATOMIC_IMIN,
|
|
|
|
VKD3DSIH_ATOMIC_OR,
|
|
|
|
VKD3DSIH_ATOMIC_UMAX,
|
|
|
|
VKD3DSIH_ATOMIC_UMIN,
|
|
|
|
VKD3DSIH_ATOMIC_XOR,
|
|
|
|
VKD3DSIH_BEM,
|
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D3DSPR_THREADGROUPID,
|
|
|
|
VKD3DSPR_LOCALTHREADID,
|
|
|
|
VKD3DSPR_LOCALTHREADINDEX,
|
|
|
|
VKD3DSPR_IDXTEMP,
|
|
|
|
VKD3DSPR_STREAM,
|
|
|
|
VKD3DSPR_FUNCTIONBODY,
|
|
|
|
VKD3DSPR_FUNCTIONPOINTER,
|
|
|
|
VKD3DSPR_COVERAGE,
|
|
|
|
VKD3DSPR_SAMPLEMASK,
|
|
|
|
VKD3DSPR_GSINSTID,
|
2018-05-29 03:50:31 -07:00
|
|
|
VKD3DSPR_DEPTHOUTGE,
|
|
|
|
VKD3DSPR_DEPTHOUTLE,
|
|
|
|
VKD3DSPR_RASTERIZER,
|
2018-04-13 03:37:37 -07:00
|
|
|
|
|
|
|
VKD3DSPR_INVALID = ~0u,
|
2017-06-16 13:38:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_shader_resource_type
|
|
|
|
{
|
|
|
|
VKD3D_SHADER_RESOURCE_NONE,
|
|
|
|
VKD3D_SHADER_RESOURCE_BUFFER,
|
|
|
|
VKD3D_SHADER_RESOURCE_TEXTURE_1D,
|
|
|
|
VKD3D_SHADER_RESOURCE_TEXTURE_2D,
|
|
|
|
VKD3D_SHADER_RESOURCE_TEXTURE_2DMS,
|
|
|
|
VKD3D_SHADER_RESOURCE_TEXTURE_3D,
|
|
|
|
VKD3D_SHADER_RESOURCE_TEXTURE_CUBE,
|
|
|
|
VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY,
|
|
|
|
VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY,
|
|
|
|
VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY,
|
|
|
|
VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_data_type
|
|
|
|
{
|
|
|
|
VKD3D_DATA_FLOAT,
|
|
|
|
VKD3D_DATA_INT,
|
|
|
|
VKD3D_DATA_RESOURCE,
|
|
|
|
VKD3D_DATA_SAMPLER,
|
|
|
|
VKD3D_DATA_UAV,
|
|
|
|
VKD3D_DATA_UINT,
|
|
|
|
VKD3D_DATA_UNORM,
|
|
|
|
VKD3D_DATA_SNORM,
|
|
|
|
VKD3D_DATA_OPAQUE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_immconst_type
|
|
|
|
{
|
|
|
|
VKD3D_IMMCONST_SCALAR,
|
|
|
|
VKD3D_IMMCONST_VEC4,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_shader_src_modifier
|
|
|
|
{
|
|
|
|
VKD3DSPSM_NONE = 0,
|
|
|
|
VKD3DSPSM_NEG = 1,
|
|
|
|
VKD3DSPSM_BIAS = 2,
|
|
|
|
VKD3DSPSM_BIASNEG = 3,
|
|
|
|
VKD3DSPSM_SIGN = 4,
|
|
|
|
VKD3DSPSM_SIGNNEG = 5,
|
|
|
|
VKD3DSPSM_COMP = 6,
|
|
|
|
VKD3DSPSM_X2 = 7,
|
|
|
|
VKD3DSPSM_X2NEG = 8,
|
|
|
|
VKD3DSPSM_DZ = 9,
|
|
|
|
VKD3DSPSM_DW = 10,
|
|
|
|
VKD3DSPSM_ABS = 11,
|
|
|
|
VKD3DSPSM_ABSNEG = 12,
|
|
|
|
VKD3DSPSM_NOT = 13,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define VKD3DSP_WRITEMASK_0 0x1u /* .x r */
|
|
|
|
#define VKD3DSP_WRITEMASK_1 0x2u /* .y g */
|
|
|
|
#define VKD3DSP_WRITEMASK_2 0x4u /* .z b */
|
|
|
|
#define VKD3DSP_WRITEMASK_3 0x8u /* .w a */
|
|
|
|
#define VKD3DSP_WRITEMASK_ALL 0xfu /* all */
|
|
|
|
|
|
|
|
enum vkd3d_shader_dst_modifier
|
|
|
|
{
|
|
|
|
VKD3DSPDM_NONE = 0,
|
|
|
|
VKD3DSPDM_SATURATE = 1,
|
|
|
|
VKD3DSPDM_PARTIALPRECISION = 2,
|
|
|
|
VKD3DSPDM_MSAMPCENTROID = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_shader_interpolation_mode
|
|
|
|
{
|
|
|
|
VKD3DSIM_CONSTANT = 1,
|
|
|
|
VKD3DSIM_LINEAR = 2,
|
|
|
|
VKD3DSIM_LINEAR_CENTROID = 3,
|
|
|
|
VKD3DSIM_LINEAR_NOPERSPECTIVE = 4,
|
|
|
|
VKD3DSIM_LINEAR_NOPERSPECTIVE_CENTROID = 5,
|
|
|
|
VKD3DSIM_LINEAR_SAMPLE = 6,
|
|
|
|
VKD3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE = 7,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_shader_global_flags
|
|
|
|
{
|
2018-10-11 06:33:33 -07:00
|
|
|
VKD3DSGF_REFACTORING_ALLOWED = 0x01,
|
|
|
|
VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL = 0x04,
|
|
|
|
VKD3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS = 0x08,
|
|
|
|
VKD3DSGF_ENABLE_MINIMUM_PRECISION = 0x20
|
2017-06-16 13:38:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_shader_sync_flags
|
|
|
|
{
|
|
|
|
VKD3DSSF_THREAD_GROUP = 0x1,
|
|
|
|
VKD3DSSF_GROUP_SHARED_MEMORY = 0x2,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_shader_uav_flags
|
|
|
|
{
|
|
|
|
VKD3DSUF_GLOBALLY_COHERENT = 0x2,
|
|
|
|
VKD3DSUF_ORDER_PRESERVING_COUNTER = 0x100,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_tessellator_domain
|
|
|
|
{
|
|
|
|
VKD3D_TESSELLATOR_DOMAIN_LINE = 1,
|
|
|
|
VKD3D_TESSELLATOR_DOMAIN_TRIANGLE = 2,
|
|
|
|
VKD3D_TESSELLATOR_DOMAIN_QUAD = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_tessellator_output_primitive
|
|
|
|
{
|
|
|
|
VKD3D_TESSELLATOR_OUTPUT_POINT = 1,
|
|
|
|
VKD3D_TESSELLATOR_OUTPUT_LINE = 2,
|
|
|
|
VKD3D_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3,
|
|
|
|
VKD3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_tessellator_partitioning
|
|
|
|
{
|
|
|
|
VKD3D_TESSELLATOR_PARTITIONING_INTEGER = 1,
|
|
|
|
VKD3D_TESSELLATOR_PARTITIONING_POW2 = 2,
|
|
|
|
VKD3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3,
|
|
|
|
VKD3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4,
|
|
|
|
};
|
|
|
|
|
2018-05-29 03:50:32 -07:00
|
|
|
|
2018-06-05 04:52:57 -07:00
|
|
|
#define VKD3DSI_NONE 0x0
|
|
|
|
#define VKD3DSI_TEXLD_PROJECT 0x1
|
|
|
|
#define VKD3DSI_INDEXED_DYNAMIC 0x4
|
|
|
|
#define VKD3DSI_RESINFO_RCP_FLOAT 0x1
|
|
|
|
#define VKD3DSI_RESINFO_UINT 0x2
|
|
|
|
#define VKD3DSI_SAMPLE_INFO_UINT 0x1
|
2017-06-16 13:38:21 -07:00
|
|
|
#define VKD3DSI_SAMPLER_COMPARISON_MODE 0x1
|
|
|
|
|
2018-05-29 03:50:30 -07:00
|
|
|
#define VKD3DSI_PRECISE_X 0x100
|
|
|
|
#define VKD3DSI_PRECISE_Y 0x200
|
|
|
|
#define VKD3DSI_PRECISE_Z 0x400
|
|
|
|
#define VKD3DSI_PRECISE_W 0x800
|
|
|
|
#define VKD3DSI_PRECISE_XYZW (VKD3DSI_PRECISE_X | VKD3DSI_PRECISE_Y \
|
|
|
|
| VKD3DSI_PRECISE_Z | VKD3DSI_PRECISE_W)
|
|
|
|
#define VKD3DSI_PRECISE_SHIFT 8
|
|
|
|
|
2017-06-16 13:38:21 -07:00
|
|
|
enum vkd3d_shader_rel_op
|
|
|
|
{
|
|
|
|
VKD3D_SHADER_REL_OP_GT = 1,
|
|
|
|
VKD3D_SHADER_REL_OP_EQ = 2,
|
|
|
|
VKD3D_SHADER_REL_OP_GE = 3,
|
|
|
|
VKD3D_SHADER_REL_OP_LT = 4,
|
|
|
|
VKD3D_SHADER_REL_OP_NE = 5,
|
|
|
|
VKD3D_SHADER_REL_OP_LE = 6,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_shader_conditional_op
|
|
|
|
{
|
|
|
|
VKD3D_SHADER_CONDITIONAL_OP_NZ = 0,
|
|
|
|
VKD3D_SHADER_CONDITIONAL_OP_Z = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
#define VKD3D_SM1_VS 0xfffeu
|
|
|
|
#define VKD3D_SM1_PS 0xffffu
|
|
|
|
#define VKD3D_SM4_PS 0x0000u
|
|
|
|
#define VKD3D_SM4_VS 0x0001u
|
|
|
|
#define VKD3D_SM4_GS 0x0002u
|
|
|
|
#define VKD3D_SM5_HS 0x0003u
|
|
|
|
#define VKD3D_SM5_DS 0x0004u
|
|
|
|
#define VKD3D_SM5_CS 0x0005u
|
|
|
|
|
|
|
|
/* Shader version tokens, and shader end tokens */
|
|
|
|
#define VKD3DPS_VERSION(major, minor) ((VKD3D_SM1_PS << 16) | ((major) << 8) | (minor))
|
|
|
|
#define VKD3DVS_VERSION(major, minor) ((VKD3D_SM1_VS << 16) | ((major) << 8) | (minor))
|
|
|
|
|
|
|
|
#define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
|
|
|
|
#define MAX_REG_OUTPUT 32
|
|
|
|
|
|
|
|
enum vkd3d_shader_type
|
|
|
|
{
|
|
|
|
VKD3D_SHADER_TYPE_PIXEL,
|
|
|
|
VKD3D_SHADER_TYPE_VERTEX,
|
|
|
|
VKD3D_SHADER_TYPE_GEOMETRY,
|
|
|
|
VKD3D_SHADER_TYPE_HULL,
|
|
|
|
VKD3D_SHADER_TYPE_DOMAIN,
|
|
|
|
VKD3D_SHADER_TYPE_GRAPHICS_COUNT,
|
|
|
|
|
|
|
|
VKD3D_SHADER_TYPE_COMPUTE = VKD3D_SHADER_TYPE_GRAPHICS_COUNT,
|
|
|
|
VKD3D_SHADER_TYPE_COUNT,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_version
|
|
|
|
{
|
|
|
|
enum vkd3d_shader_type type;
|
|
|
|
BYTE major;
|
|
|
|
BYTE minor;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_immediate_constant_buffer
|
|
|
|
{
|
|
|
|
unsigned int vec4_count;
|
|
|
|
DWORD data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_indexable_temp
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
unsigned int register_idx;
|
|
|
|
unsigned int register_size;
|
|
|
|
unsigned int component_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_register_index
|
|
|
|
{
|
|
|
|
const struct vkd3d_shader_src_param *rel_addr;
|
|
|
|
unsigned int offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_register
|
|
|
|
{
|
|
|
|
enum vkd3d_shader_register_type type;
|
|
|
|
enum vkd3d_data_type data_type;
|
|
|
|
struct vkd3d_shader_register_index idx[2];
|
|
|
|
enum vkd3d_immconst_type immconst_type;
|
|
|
|
union
|
|
|
|
{
|
2018-05-29 03:50:32 -07:00
|
|
|
DWORD immconst_uint[VKD3D_VEC4_SIZE];
|
|
|
|
float immconst_float[VKD3D_VEC4_SIZE];
|
2017-06-16 13:38:21 -07:00
|
|
|
unsigned fp_body_idx;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_dst_param
|
|
|
|
{
|
|
|
|
struct vkd3d_shader_register reg;
|
|
|
|
DWORD write_mask;
|
|
|
|
DWORD modifiers;
|
|
|
|
DWORD shift;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_src_param
|
|
|
|
{
|
|
|
|
struct vkd3d_shader_register reg;
|
|
|
|
DWORD swizzle;
|
|
|
|
enum vkd3d_shader_src_modifier modifiers;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_index_range
|
|
|
|
{
|
|
|
|
struct vkd3d_shader_dst_param first_register;
|
|
|
|
unsigned int last_register;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_decl_usage
|
|
|
|
{
|
|
|
|
VKD3D_DECL_USAGE_POSITION = 0,
|
|
|
|
VKD3D_DECL_USAGE_BLEND_WEIGHT = 1,
|
|
|
|
VKD3D_DECL_USAGE_BLEND_INDICES = 2,
|
|
|
|
VKD3D_DECL_USAGE_NORMAL = 3,
|
|
|
|
VKD3D_DECL_USAGE_PSIZE = 4,
|
|
|
|
VKD3D_DECL_USAGE_TEXCOORD = 5,
|
|
|
|
VKD3D_DECL_USAGE_TANGENT = 6,
|
|
|
|
VKD3D_DECL_USAGE_BINORMAL = 7,
|
|
|
|
VKD3D_DECL_USAGE_TESS_FACTOR = 8,
|
|
|
|
VKD3D_DECL_USAGE_POSITIONT = 9,
|
|
|
|
VKD3D_DECL_USAGE_COLOR = 10,
|
|
|
|
VKD3D_DECL_USAGE_FOG = 11,
|
|
|
|
VKD3D_DECL_USAGE_DEPTH = 12,
|
|
|
|
VKD3D_DECL_USAGE_SAMPLE = 13
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_semantic
|
|
|
|
{
|
|
|
|
enum vkd3d_decl_usage usage;
|
2018-02-15 06:43:53 -08:00
|
|
|
unsigned int usage_idx;
|
2017-06-16 13:38:21 -07:00
|
|
|
enum vkd3d_shader_resource_type resource_type;
|
|
|
|
enum vkd3d_data_type resource_data_type;
|
|
|
|
struct vkd3d_shader_dst_param reg;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_shader_input_sysval_semantic
|
|
|
|
{
|
|
|
|
VKD3D_SIV_NONE = 0,
|
|
|
|
VKD3D_SIV_POSITION = 1,
|
|
|
|
VKD3D_SIV_CLIP_DISTANCE = 2,
|
|
|
|
VKD3D_SIV_CULL_DISTANCE = 3,
|
|
|
|
VKD3D_SIV_RENDER_TARGET_ARRAY_INDEX = 4,
|
|
|
|
VKD3D_SIV_VIEWPORT_ARRAY_INDEX = 5,
|
|
|
|
VKD3D_SIV_VERTEX_ID = 6,
|
|
|
|
VKD3D_SIV_PRIMITIVE_ID = 7,
|
|
|
|
VKD3D_SIV_INSTANCE_ID = 8,
|
|
|
|
VKD3D_SIV_IS_FRONT_FACE = 9,
|
|
|
|
VKD3D_SIV_SAMPLE_INDEX = 10,
|
|
|
|
VKD3D_SIV_QUAD_U0_TESS_FACTOR = 11,
|
|
|
|
VKD3D_SIV_QUAD_V0_TESS_FACTOR = 12,
|
|
|
|
VKD3D_SIV_QUAD_U1_TESS_FACTOR = 13,
|
|
|
|
VKD3D_SIV_QUAD_V1_TESS_FACTOR = 14,
|
|
|
|
VKD3D_SIV_QUAD_U_INNER_TESS_FACTOR = 15,
|
|
|
|
VKD3D_SIV_QUAD_V_INNER_TESS_FACTOR = 16,
|
|
|
|
VKD3D_SIV_TRIANGLE_U_TESS_FACTOR = 17,
|
|
|
|
VKD3D_SIV_TRIANGLE_V_TESS_FACTOR = 18,
|
|
|
|
VKD3D_SIV_TRIANGLE_W_TESS_FACTOR = 19,
|
|
|
|
VKD3D_SIV_TRIANGLE_INNER_TESS_FACTOR = 20,
|
|
|
|
VKD3D_SIV_LINE_DETAIL_TESS_FACTOR = 21,
|
|
|
|
VKD3D_SIV_LINE_DENSITY_TESS_FACTOR = 22,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_desc
|
|
|
|
{
|
|
|
|
const DWORD *byte_code;
|
|
|
|
size_t byte_code_size;
|
|
|
|
struct vkd3d_shader_signature input_signature;
|
|
|
|
struct vkd3d_shader_signature output_signature;
|
|
|
|
struct vkd3d_shader_signature patch_constant_signature;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_register_semantic
|
|
|
|
{
|
|
|
|
struct vkd3d_shader_dst_param reg;
|
|
|
|
enum vkd3d_shader_input_sysval_semantic sysval_semantic;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_structured_resource
|
|
|
|
{
|
|
|
|
struct vkd3d_shader_dst_param reg;
|
|
|
|
unsigned int byte_stride;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_tgsm
|
|
|
|
{
|
|
|
|
unsigned int size;
|
|
|
|
unsigned int stride;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_tgsm_raw
|
|
|
|
{
|
|
|
|
struct vkd3d_shader_dst_param reg;
|
|
|
|
unsigned int byte_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_tgsm_structured
|
|
|
|
{
|
|
|
|
struct vkd3d_shader_dst_param reg;
|
|
|
|
unsigned int byte_stride;
|
|
|
|
unsigned int structure_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_thread_group_size
|
|
|
|
{
|
|
|
|
unsigned int x, y, z;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_function_table_pointer
|
|
|
|
{
|
|
|
|
unsigned int index;
|
|
|
|
unsigned int array_size;
|
|
|
|
unsigned int body_count;
|
|
|
|
unsigned int table_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_texel_offset
|
|
|
|
{
|
|
|
|
signed char u, v, w;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vkd3d_primitive_type
|
|
|
|
{
|
|
|
|
VKD3D_PT_UNDEFINED = 0,
|
|
|
|
VKD3D_PT_POINTLIST = 1,
|
|
|
|
VKD3D_PT_LINELIST = 2,
|
|
|
|
VKD3D_PT_LINESTRIP = 3,
|
|
|
|
VKD3D_PT_TRIANGLELIST = 4,
|
|
|
|
VKD3D_PT_TRIANGLESTRIP = 5,
|
|
|
|
VKD3D_PT_TRIANGLEFAN = 6,
|
|
|
|
VKD3D_PT_LINELIST_ADJ = 10,
|
|
|
|
VKD3D_PT_LINESTRIP_ADJ = 11,
|
|
|
|
VKD3D_PT_TRIANGLELIST_ADJ = 12,
|
|
|
|
VKD3D_PT_TRIANGLESTRIP_ADJ = 13,
|
|
|
|
VKD3D_PT_PATCH = 14,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_primitive_type
|
|
|
|
{
|
|
|
|
enum vkd3d_primitive_type type;
|
|
|
|
unsigned int patch_vertex_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vkd3d_shader_instruction
|
|
|
|
{
|
|
|
|
const struct vkd3d_shader_context *ctx;
|
|
|
|
enum VKD3D_SHADER_INSTRUCTION_HANDLER handler_idx;
|
|
|
|
DWORD flags;
|
|
|
|
unsigned int dst_count;
|
|
|
|
unsigned int src_count;
|
|
|
|
const struct vkd3d_shader_dst_param *dst;
|
|
|
|
const struct vkd3d_shader_src_param *src;
|
|
|
|
struct vkd3d_shader_texel_offset texel_offset;
|
2018-05-29 03:50:32 -07:00
|
|
|
bool coissue;
|
|
|
|
const struct vkd3d_shader_src_param *predicate;
|
2017-06-16 13:38:21 -07:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct vkd3d_shader_semantic semantic;
|
|
|
|
struct vkd3d_shader_register_semantic register_semantic;
|
|
|
|
struct vkd3d_shader_primitive_type primitive_type;
|
|
|
|
struct vkd3d_shader_dst_param dst;
|
|
|
|
struct vkd3d_shader_src_param src;
|
|
|
|
unsigned int count;
|
|
|
|
unsigned int index;
|
|
|
|
const struct vkd3d_shader_immediate_constant_buffer *icb;
|
|
|
|
struct vkd3d_shader_structured_resource structured_resource;
|
|
|
|
struct vkd3d_shader_tgsm_raw tgsm_raw;
|
|
|
|
struct vkd3d_shader_tgsm_structured tgsm_structured;
|
|
|
|
struct vkd3d_shader_thread_group_size thread_group_size;
|
|
|
|
enum vkd3d_tessellator_domain tessellator_domain;
|
|
|
|
enum vkd3d_tessellator_output_primitive tessellator_output_primitive;
|
|
|
|
enum vkd3d_tessellator_partitioning tessellator_partitioning;
|
|
|
|
float max_tessellation_factor;
|
|
|
|
struct vkd3d_shader_index_range index_range;
|
|
|
|
struct vkd3d_shader_indexable_temp indexable_temp;
|
|
|
|
struct vkd3d_shader_function_table_pointer fp;
|
|
|
|
} declaration;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline BOOL vkd3d_shader_instruction_has_texel_offset(const struct vkd3d_shader_instruction *ins)
|
|
|
|
{
|
|
|
|
return ins->texel_offset.u || ins->texel_offset.v || ins->texel_offset.w;
|
|
|
|
}
|
|
|
|
|
2018-07-18 03:05:42 -07:00
|
|
|
static inline bool vkd3d_shader_register_is_input(const struct vkd3d_shader_register *reg)
|
|
|
|
{
|
|
|
|
return reg->type == VKD3DSPR_INPUT || reg->type == VKD3DSPR_INCONTROLPOINT;
|
|
|
|
}
|
|
|
|
|
2018-05-29 03:50:32 -07:00
|
|
|
void vkd3d_shader_trace(void *data) DECLSPEC_HIDDEN;
|
|
|
|
|
2017-06-16 13:38:21 -07:00
|
|
|
void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
|
|
|
|
const struct vkd3d_shader_signature *output_signature) DECLSPEC_HIDDEN;
|
|
|
|
void shader_sm4_free(void *data) DECLSPEC_HIDDEN;
|
|
|
|
void shader_sm4_read_header(void *data, const DWORD **ptr,
|
|
|
|
struct vkd3d_shader_version *shader_version) DECLSPEC_HIDDEN;
|
|
|
|
void shader_sm4_read_instruction(void *data, const DWORD **ptr,
|
|
|
|
struct vkd3d_shader_instruction *ins) DECLSPEC_HIDDEN;
|
|
|
|
BOOL shader_sm4_is_end(void *data, const DWORD **ptr) DECLSPEC_HIDDEN;
|
|
|
|
|
2018-11-12 15:23:33 -08:00
|
|
|
int shader_extract_from_dxbc(const void *dxbc, size_t dxbc_length,
|
2017-06-16 13:38:21 -07:00
|
|
|
struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
|
|
|
|
void free_shader_desc(struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
|
|
|
|
|
2018-11-12 15:23:33 -08:00
|
|
|
int shader_parse_input_signature(const void *dxbc, size_t dxbc_length,
|
2017-09-11 13:35:16 -07:00
|
|
|
struct vkd3d_shader_signature *signature) DECLSPEC_HIDDEN;
|
|
|
|
|
2017-06-19 09:05:53 -07:00
|
|
|
struct vkd3d_dxbc_compiler;
|
|
|
|
|
2017-07-10 06:33:34 -07:00
|
|
|
struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader_version *shader_version,
|
2017-07-26 04:45:25 -07:00
|
|
|
const struct vkd3d_shader_desc *shader_desc, uint32_t compiler_options,
|
2017-08-21 03:41:07 -07:00
|
|
|
const struct vkd3d_shader_interface *shader_interface,
|
2018-05-24 04:08:35 -07:00
|
|
|
const struct vkd3d_shader_compile_arguments *compile_args,
|
2017-08-21 03:41:07 -07:00
|
|
|
const struct vkd3d_shader_scan_info *scan_info) DECLSPEC_HIDDEN;
|
2018-10-26 06:06:53 -07:00
|
|
|
int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler,
|
2017-06-19 09:05:53 -07:00
|
|
|
const struct vkd3d_shader_instruction *instruction) DECLSPEC_HIDDEN;
|
2018-02-15 06:43:52 -08:00
|
|
|
int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
|
2017-06-19 09:05:53 -07:00
|
|
|
struct vkd3d_shader_code *spirv) DECLSPEC_HIDDEN;
|
|
|
|
void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler) DECLSPEC_HIDDEN;
|
|
|
|
|
2017-06-20 04:34:44 -07:00
|
|
|
static inline enum vkd3d_component_type vkd3d_component_type_from_data_type(
|
|
|
|
enum vkd3d_data_type data_type)
|
|
|
|
{
|
|
|
|
switch (data_type)
|
|
|
|
{
|
|
|
|
case VKD3D_DATA_FLOAT:
|
|
|
|
return VKD3D_TYPE_FLOAT;
|
|
|
|
case VKD3D_DATA_UINT:
|
|
|
|
return VKD3D_TYPE_UINT;
|
|
|
|
case VKD3D_DATA_INT:
|
|
|
|
return VKD3D_TYPE_INT;
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled data type %#x.\n", data_type);
|
|
|
|
return VKD3D_TYPE_UINT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-17 07:25:29 -07:00
|
|
|
static inline enum vkd3d_data_type vkd3d_data_type_from_component_type(
|
|
|
|
enum vkd3d_component_type component_type)
|
|
|
|
{
|
|
|
|
switch (component_type)
|
|
|
|
{
|
|
|
|
case VKD3D_TYPE_FLOAT:
|
|
|
|
return VKD3D_DATA_FLOAT;
|
|
|
|
case VKD3D_TYPE_UINT:
|
|
|
|
return VKD3D_DATA_UINT;
|
|
|
|
case VKD3D_TYPE_INT:
|
|
|
|
return VKD3D_DATA_INT;
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled component type %#x.\n", component_type);
|
|
|
|
return VKD3D_DATA_FLOAT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-20 04:34:44 -07:00
|
|
|
static inline unsigned int vkd3d_write_mask_get_component_idx(DWORD write_mask)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2017-08-18 05:52:40 -07:00
|
|
|
assert(write_mask);
|
2017-06-20 04:34:44 -07:00
|
|
|
for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
|
|
|
|
{
|
|
|
|
if (write_mask & (VKD3DSP_WRITEMASK_0 << i))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Invalid write mask %#x.\n", write_mask);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int vkd3d_write_mask_component_count(DWORD write_mask)
|
|
|
|
{
|
2017-08-18 05:52:40 -07:00
|
|
|
assert(write_mask);
|
2018-10-30 07:22:51 -07:00
|
|
|
return vkd3d_popcount(write_mask & VKD3DSP_WRITEMASK_ALL);
|
2017-06-20 04:34:44 -07:00
|
|
|
}
|
|
|
|
|
2018-06-26 05:41:44 -07:00
|
|
|
static inline unsigned int vkd3d_write_mask_from_component_count(unsigned int component_count)
|
|
|
|
{
|
|
|
|
assert(component_count <= 4);
|
|
|
|
return (VKD3DSP_WRITEMASK_0 << component_count) - 1;
|
|
|
|
}
|
|
|
|
|
2017-06-20 04:34:44 -07:00
|
|
|
static inline unsigned int vkd3d_swizzle_get_component(DWORD swizzle,
|
|
|
|
unsigned int idx)
|
|
|
|
{
|
2018-05-24 04:08:34 -07:00
|
|
|
return (swizzle >> VKD3D_SWIZZLE_SHIFT(idx)) & VKD3D_SWIZZLE_MASK;
|
2017-06-20 04:34:44 -07:00
|
|
|
}
|
|
|
|
|
2018-10-31 07:26:46 -07:00
|
|
|
static inline unsigned int vkd3d_compact_swizzle(unsigned int swizzle, unsigned int write_mask)
|
|
|
|
{
|
|
|
|
unsigned int i, compacted_swizzle = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
|
|
|
|
{
|
|
|
|
if (write_mask & (VKD3DSP_WRITEMASK_0 << i))
|
|
|
|
{
|
|
|
|
compacted_swizzle <<= VKD3D_SWIZZLE_SHIFT(1);
|
|
|
|
compacted_swizzle |= vkd3d_swizzle_get_component(swizzle, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return compacted_swizzle;
|
|
|
|
}
|
|
|
|
|
2017-06-20 05:14:44 -07:00
|
|
|
#define VKD3D_DXBC_MAX_SOURCE_COUNT 6
|
2018-04-11 04:21:41 -07:00
|
|
|
#define VKD3D_DXBC_HEADER_SIZE (8 * sizeof(uint32_t))
|
2017-06-20 05:14:44 -07:00
|
|
|
|
2017-06-16 13:38:21 -07:00
|
|
|
#endif /* __VKD3D_SHADER_PRIVATE_H */
|