2013-10-07 14:02:24 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2013-10-07 14:02:24 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2013-10-07 14:02:24 +00:00
|
|
|
|
2017-08-27 17:56:16 +00:00
|
|
|
#include <array>
|
|
|
|
|
2014-10-21 06:01:38 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
2013-10-07 14:02:24 +00:00
|
|
|
// all constant buffer attributes must be 16 bytes aligned, so this are the only allowed components:
|
2017-08-27 17:56:16 +00:00
|
|
|
using float4 = std::array<float, 4>;
|
|
|
|
using uint4 = std::array<u32, 4>;
|
|
|
|
using int4 = std::array<s32, 4>;
|
2013-10-07 14:02:24 +00:00
|
|
|
|
2021-02-11 02:11:31 +00:00
|
|
|
enum class DstBlendFactor : u32;
|
2021-09-01 22:13:56 +00:00
|
|
|
enum class SrcBlendFactor : u32;
|
|
|
|
enum class ZTexOp : u32;
|
2021-08-03 03:39:34 +00:00
|
|
|
enum class LogicOp : u32;
|
2021-02-11 02:11:31 +00:00
|
|
|
|
2022-11-11 01:30:49 +00:00
|
|
|
struct alignas(16) PixelShaderConstants
|
2013-10-07 14:02:24 +00:00
|
|
|
{
|
2017-08-27 17:56:16 +00:00
|
|
|
std::array<int4, 4> colors;
|
|
|
|
std::array<int4, 4> kcolors;
|
2013-10-10 18:36:55 +00:00
|
|
|
int4 alpha;
|
2021-07-24 22:58:55 +00:00
|
|
|
std::array<uint4, 8> texdims;
|
2017-08-27 17:56:16 +00:00
|
|
|
std::array<int4, 2> zbias;
|
|
|
|
std::array<int4, 2> indtexscale;
|
|
|
|
std::array<int4, 6> indtexmtx;
|
2013-10-27 12:10:00 +00:00
|
|
|
int4 fogcolor;
|
2014-03-03 18:23:46 +00:00
|
|
|
int4 fogi;
|
2018-02-03 07:01:34 +00:00
|
|
|
float4 fogf;
|
|
|
|
std::array<float4, 3> fogrange;
|
2014-12-25 07:34:22 +00:00
|
|
|
float4 zslope;
|
2018-02-03 07:01:34 +00:00
|
|
|
std::array<float, 2> efbscale; // .xy
|
2017-07-20 05:25:24 +00:00
|
|
|
|
2021-08-09 04:11:50 +00:00
|
|
|
// Constants from here onwards are only used in ubershaders, other than pack2.
|
2017-08-27 17:56:16 +00:00
|
|
|
u32 genmode; // .z
|
|
|
|
u32 alphaTest; // .w
|
|
|
|
u32 fogParam3; // .x
|
|
|
|
u32 fogRangeBase; // .y
|
|
|
|
u32 dstalpha; // .z
|
2021-09-01 22:13:56 +00:00
|
|
|
ZTexOp ztex_op; // .w
|
2017-08-27 17:56:16 +00:00
|
|
|
u32 late_ztest; // .x (bool)
|
|
|
|
u32 rgba6_format; // .y (bool)
|
|
|
|
u32 dither; // .z (bool)
|
|
|
|
u32 bounding_box; // .w (bool)
|
|
|
|
std::array<uint4, 16> pack1; // .xy - combiners, .z - tevind, .w - iref
|
2021-08-09 04:11:50 +00:00
|
|
|
std::array<uint4, 8> pack2; // .x - tevorder, .y - tevksel, .z/.w - SamplerState tm0/tm1
|
2017-08-27 17:56:16 +00:00
|
|
|
std::array<int4, 32> konst; // .rgba
|
2017-12-26 20:30:22 +00:00
|
|
|
// The following are used in ubershaders when using shader_framebuffer_fetch blending
|
|
|
|
u32 blend_enable;
|
2021-02-11 02:11:31 +00:00
|
|
|
SrcBlendFactor blend_src_factor;
|
|
|
|
SrcBlendFactor blend_src_factor_alpha;
|
|
|
|
DstBlendFactor blend_dst_factor;
|
|
|
|
DstBlendFactor blend_dst_factor_alpha;
|
2017-12-26 20:30:22 +00:00
|
|
|
u32 blend_subtract;
|
|
|
|
u32 blend_subtract_alpha;
|
2021-08-03 03:39:34 +00:00
|
|
|
// For shader_framebuffer_fetch logic ops:
|
|
|
|
u32 logic_op_enable; // bool
|
|
|
|
LogicOp logic_op_mode;
|
2023-01-07 18:30:29 +00:00
|
|
|
// For custom shaders...
|
|
|
|
u32 time_ms;
|
2013-10-07 14:02:24 +00:00
|
|
|
};
|
|
|
|
|
2022-11-11 01:30:49 +00:00
|
|
|
struct alignas(16) VertexShaderConstants
|
2013-10-07 14:02:24 +00:00
|
|
|
{
|
2017-07-20 05:25:27 +00:00
|
|
|
u32 components; // .x
|
|
|
|
u32 xfmem_dualTexInfo; // .y
|
|
|
|
u32 xfmem_numColorChans; // .z
|
2021-02-23 03:03:06 +00:00
|
|
|
u32 missing_color_hex; // .w, used for change detection but not directly by shaders
|
|
|
|
float4 missing_color_value;
|
2017-07-20 05:25:27 +00:00
|
|
|
|
2017-08-27 17:56:16 +00:00
|
|
|
std::array<float4, 6> posnormalmatrix;
|
|
|
|
std::array<float4, 4> projection;
|
|
|
|
std::array<int4, 4> materials;
|
2014-05-30 14:17:30 +00:00
|
|
|
struct Light
|
|
|
|
{
|
|
|
|
int4 color;
|
|
|
|
float4 cosatt;
|
|
|
|
float4 distatt;
|
|
|
|
float4 pos;
|
|
|
|
float4 dir;
|
2017-08-27 17:56:16 +00:00
|
|
|
};
|
|
|
|
std::array<Light, 8> lights;
|
|
|
|
std::array<float4, 24> texmatrices;
|
|
|
|
std::array<float4, 64> transformmatrices;
|
|
|
|
std::array<float4, 32> normalmatrices;
|
|
|
|
std::array<float4, 64> posttransformmatrices;
|
2014-10-25 00:59:02 +00:00
|
|
|
float4 pixelcentercorrection;
|
2017-08-27 17:56:16 +00:00
|
|
|
std::array<float, 2> viewport; // .xy
|
|
|
|
std::array<float, 2> pad2; // .zw
|
2017-07-20 05:25:27 +00:00
|
|
|
|
2017-08-27 17:56:16 +00:00
|
|
|
// .x - texMtxInfo, .y - postMtxInfo, [0..1].z = color, [0..1].w = alpha
|
|
|
|
std::array<uint4, 8> xfmem_pack1;
|
2022-04-14 05:03:34 +00:00
|
|
|
|
|
|
|
float4 cached_tangent;
|
|
|
|
float4 cached_binormal;
|
2022-06-18 06:09:35 +00:00
|
|
|
// For UberShader vertex loader
|
|
|
|
u32 vertex_stride;
|
2022-08-03 06:13:55 +00:00
|
|
|
std::array<u32, 3> vertex_offset_normals;
|
2022-06-18 06:09:35 +00:00
|
|
|
u32 vertex_offset_position;
|
|
|
|
u32 vertex_offset_posmtx;
|
2022-08-03 06:13:55 +00:00
|
|
|
std::array<u32, 2> vertex_offset_colors;
|
|
|
|
std::array<u32, 8> vertex_offset_texcoords;
|
2013-10-07 14:02:24 +00:00
|
|
|
};
|
2014-05-30 14:17:30 +00:00
|
|
|
|
2022-07-23 05:47:04 +00:00
|
|
|
enum class VSExpand : u32
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
Point,
|
|
|
|
Line,
|
|
|
|
};
|
|
|
|
|
2022-11-11 01:30:49 +00:00
|
|
|
struct alignas(16) GeometryShaderConstants
|
2014-12-14 20:23:13 +00:00
|
|
|
{
|
|
|
|
float4 stereoparams;
|
2014-12-15 23:21:07 +00:00
|
|
|
float4 lineptparams;
|
|
|
|
int4 texoffset;
|
2022-07-23 05:47:04 +00:00
|
|
|
VSExpand vs_expand; // Used by VS point/line expansion in ubershaders
|
|
|
|
u32 pad[3];
|
2014-12-14 20:23:13 +00:00
|
|
|
};
|