diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2016-07-31 10:38:42 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-31 10:38:42 +0200 |
| commit | e281273cd7c7e173b9911ba0b8e01dd809cfd8ea (patch) | |
| tree | b70ab77109da2473b23bbe86fc7fc240e2d9a978 /Source/Core/VideoCommon/PixelShaderGen.cpp | |
| parent | a3438f916b8eb2123b8977ac334d104dd2640e5e (diff) | |
| parent | 14e0b48ae43c3625f8571dec88121c91d575c65c (diff) | |
Merge pull request #4047 from lioncash/enum-fwd
VideoCommon: Make API_TYPE an enum class
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 61802c2718..514ae76998 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -15,6 +15,7 @@ #include "VideoCommon/LightingShaderGen.h" #include "VideoCommon/PixelShaderGen.h" #include "VideoCommon/VertexLoaderManager.h" +#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" #include "VideoCommon/XFMemory.h" // for texture projection mode @@ -335,16 +336,16 @@ PixelShaderUid GetPixelShaderUid(DSTALPHA_MODE dstAlphaMode) } static void WriteStage(ShaderCode& out, const pixel_shader_uid_data* uid_data, int n, - API_TYPE ApiType); + APIType ApiType); static void WriteTevRegular(ShaderCode& out, const char* components, int bias, int op, int clamp, int shift); static void SampleTexture(ShaderCode& out, const char* texcoords, const char* texswap, int texmap, - bool stereo, API_TYPE ApiType); -static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_data, API_TYPE ApiType, + bool stereo, APIType ApiType); +static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_data, APIType ApiType, DSTALPHA_MODE dstAlphaMode, bool per_pixel_depth); static void WriteFog(ShaderCode& out, const pixel_shader_uid_data* uid_data); -ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, +ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, APIType ApiType, const pixel_shader_uid_data* uid_data) { ShaderCode out; @@ -379,7 +380,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, "int3 itrunc(float3 x) { return int3(trunc(x)); }\n" "int4 itrunc(float4 x) { return int4(trunc(x)); }\n\n"); - if (ApiType == API_OPENGL) + if (ApiType == APIType::OpenGL) { out.Write("SAMPLER_BINDING(0) uniform sampler2DArray samp[8];\n"); } @@ -392,7 +393,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, } out.Write("\n"); - if (ApiType == API_OPENGL) + if (ApiType == APIType::OpenGL) { out.Write("layout(std140%s) uniform PSBlock {\n", g_ActiveConfig.backend_info.bSupportsBindingLayout ? ", binding = 1" : ""); @@ -419,7 +420,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, { out.Write("%s", s_lighting_struct); - if (ApiType == API_OPENGL) + if (ApiType == APIType::OpenGL) { out.Write("layout(std140%s) uniform VSBlock {\n", g_ActiveConfig.backend_info.bSupportsBindingLayout ? ", binding = 2" : ""); @@ -434,7 +435,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, if (uid_data->bounding_box) { - if (ApiType == API_OPENGL) + if (ApiType == APIType::OpenGL) { out.Write("layout(std140, binding = 3) buffer BBox {\n" "\tint4 bbox_data;\n" @@ -487,7 +488,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, // ARB_image_load_store extension yet. // D3D11 also has a way to force the driver to enable early-z, so we're fine here. - if (ApiType == API_OPENGL) + if (ApiType == APIType::OpenGL) { // This is a #define which signals whatever early-z method the driver supports. out.Write("FORCE_EARLY_Z; \n"); @@ -509,7 +510,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, warn_once = false; } - if (ApiType == API_OPENGL) + if (ApiType == APIType::OpenGL) { out.Write("out vec4 ocol0;\n"); if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND) @@ -715,7 +716,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, out.Write("\tfloat2 screenpos = rawpos.xy * " I_EFBSCALE ".xy;\n"); // Opengl has reversed vertical screenspace coordinates - if (ApiType == API_OPENGL) + if (ApiType == APIType::OpenGL) out.Write("\tscreenpos.y = %i.0 - screenpos.y;\n", EFB_HEIGHT); out.Write("\tint zCoord = int(" I_ZSLOPE ".z + " I_ZSLOPE ".x * screenpos.x + " I_ZSLOPE @@ -735,7 +736,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, } else { - if (ApiType == API_D3D) + if (ApiType == APIType::D3D) out.Write("\tint zCoord = int((1.0 - rawpos.z) * 16777216.0);\n"); else out.Write("\tint zCoord = int(rawpos.z * 16777216.0);\n"); @@ -749,7 +750,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, // Note: z-textures are not written to depth buffer if early depth test is used if (uid_data->per_pixel_depth && uid_data->early_ztest) { - if (ApiType == API_D3D) + if (ApiType == APIType::D3D) out.Write("\tdepth = 1.0 - float(zCoord) / 16777216.0;\n"); else out.Write("\tdepth = float(zCoord) / 16777216.0;\n"); @@ -770,7 +771,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, if (uid_data->per_pixel_depth && uid_data->late_ztest) { - if (ApiType == API_D3D) + if (ApiType == APIType::D3D) out.Write("\tdepth = 1.0 - float(zCoord) / 16777216.0;\n"); else out.Write("\tdepth = float(zCoord) / 16777216.0;\n"); @@ -800,7 +801,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, if (uid_data->bounding_box) { - const char* atomic_op = ApiType == API_OPENGL ? "atomic" : "Interlocked"; + const char* atomic_op = ApiType == APIType::OpenGL ? "atomic" : "Interlocked"; out.Write("\tif(bbox_data[0] > int(rawpos.x)) %sMin(bbox_data[0], int(rawpos.x));\n" "\tif(bbox_data[1] < int(rawpos.x)) %sMax(bbox_data[1], int(rawpos.x));\n" "\tif(bbox_data[2] > int(rawpos.y)) %sMin(bbox_data[2], int(rawpos.y));\n" @@ -814,7 +815,7 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, } static void WriteStage(ShaderCode& out, const pixel_shader_uid_data* uid_data, int n, - API_TYPE ApiType) + APIType ApiType) { auto& stage = uid_data->stagehash[n]; out.Write("\n\t// TEV stage %d\n", n); @@ -1142,11 +1143,11 @@ static void WriteTevRegular(ShaderCode& out, const char* components, int bias, i } static void SampleTexture(ShaderCode& out, const char* texcoords, const char* texswap, int texmap, - bool stereo, API_TYPE ApiType) + bool stereo, APIType ApiType) { out.SetConstantsUsed(C_TEXDIMS + texmap, C_TEXDIMS + texmap); - if (ApiType == API_D3D) + if (ApiType == APIType::D3D) out.Write("iround(255.0 * Tex[%d].Sample(samp[%d], float3(%s.xy * " I_TEXDIMS "[%d].xy, %s))).%s;\n", texmap, texmap, texcoords, texmap, stereo ? "layer" : "0.0", texswap); @@ -1173,7 +1174,7 @@ static const char* tevAlphaFunclogicTable[] = { " == " // xnor }; -static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_data, API_TYPE ApiType, +static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_data, APIType ApiType, DSTALPHA_MODE dstAlphaMode, bool per_pixel_depth) { static const char* alphaRef[2] = {I_ALPHA ".r", I_ALPHA ".g"}; @@ -1204,13 +1205,13 @@ static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_dat if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND) out.Write("\t\tocol1 = float4(0.0, 0.0, 0.0, 0.0);\n"); if (per_pixel_depth) - out.Write("\t\tdepth = %s;\n", (ApiType == API_D3D) ? "0.0" : "1.0"); + out.Write("\t\tdepth = %s;\n", (ApiType == APIType::D3D) ? "0.0" : "1.0"); // ZCOMPLOC HACK: if (!uid_data->alpha_test_use_zcomploc_hack) { out.Write("\t\tdiscard;\n"); - if (ApiType != API_D3D) + if (ApiType != APIType::D3D) out.Write("\t\treturn;\n"); } |
