mirror of
https://github.com/Retropex/dolphin.git
synced 2025-05-28 13:02:37 +02:00
VideoCommon/ShaderGenCommon: Make template functions regular functions
These are only ever used with ShaderCode instances and nothing else. Given that, we can convert these helper functions to expect that type of object as an argument and remove the need for templates, improving compiler throughput a marginal amount, as the template instantiation process doesn't need to be performed. We can also move the definitions of these functions into the cpp file, which allows us to remove a few inclusions from the ShaderGenCommon header. This uncovered a few instances of indirect inclusions being relied upon in other source files. One other benefit is this allows changes to be made to the definitions of the functions without needing to recompile all translation units that make use of these functions, making change testing a little quicker. Moving the definitions into the cpp file also allows us to completely hide DefineOutputMember() from external view, given it's only ever used inside of GenerateVSOutputMembers().
This commit is contained in:
parent
e3506ff4ef
commit
86f8768268
@ -2,9 +2,6 @@
|
|||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
|
|
||||||
@ -15,6 +12,7 @@
|
|||||||
#include "VideoBackends/D3D/DXTexture.h"
|
#include "VideoBackends/D3D/DXTexture.h"
|
||||||
#include "VideoBackends/D3D/Render.h"
|
#include "VideoBackends/D3D/Render.h"
|
||||||
#include "VideoBackends/D3D/VertexManager.h"
|
#include "VideoBackends/D3D/VertexManager.h"
|
||||||
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
namespace DX11
|
namespace DX11
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "VideoCommon/VertexLoaderManager.h"
|
#include "VideoCommon/VertexLoaderManager.h"
|
||||||
#include "VideoCommon/VertexShaderManager.h"
|
#include "VideoCommon/VertexShaderManager.h"
|
||||||
#include "VideoCommon/VideoBackendBase.h"
|
#include "VideoCommon/VideoBackendBase.h"
|
||||||
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
namespace OGL
|
namespace OGL
|
||||||
{
|
{
|
||||||
|
@ -10,10 +10,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
|
||||||
#include "Common/Atomic.h"
|
#include "Common/Atomic.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/GL/GLContext.h"
|
#include "Common/GL/GLContext.h"
|
||||||
@ -24,7 +21,6 @@
|
|||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
#include "Core/Config/GraphicsSettings.h"
|
#include "Core/Config/GraphicsSettings.h"
|
||||||
#include "Core/Core.h"
|
|
||||||
|
|
||||||
#include "VideoBackends/OGL/BoundingBox.h"
|
#include "VideoBackends/OGL/BoundingBox.h"
|
||||||
#include "VideoBackends/OGL/OGLPipeline.h"
|
#include "VideoBackends/OGL/OGLPipeline.h"
|
||||||
@ -32,22 +28,16 @@
|
|||||||
#include "VideoBackends/OGL/OGLTexture.h"
|
#include "VideoBackends/OGL/OGLTexture.h"
|
||||||
#include "VideoBackends/OGL/ProgramShaderCache.h"
|
#include "VideoBackends/OGL/ProgramShaderCache.h"
|
||||||
#include "VideoBackends/OGL/SamplerCache.h"
|
#include "VideoBackends/OGL/SamplerCache.h"
|
||||||
#include "VideoBackends/OGL/StreamBuffer.h"
|
|
||||||
#include "VideoBackends/OGL/VertexManager.h"
|
#include "VideoBackends/OGL/VertexManager.h"
|
||||||
|
|
||||||
#include "VideoCommon/BPFunctions.h"
|
#include "VideoCommon/BPFunctions.h"
|
||||||
#include "VideoCommon/DriverDetails.h"
|
#include "VideoCommon/DriverDetails.h"
|
||||||
#include "VideoCommon/FramebufferManager.h"
|
#include "VideoCommon/FramebufferManager.h"
|
||||||
#include "VideoCommon/IndexGenerator.h"
|
|
||||||
#include "VideoCommon/OnScreenDisplay.h"
|
#include "VideoCommon/OnScreenDisplay.h"
|
||||||
#include "VideoCommon/PixelEngine.h"
|
|
||||||
#include "VideoCommon/PostProcessing.h"
|
#include "VideoCommon/PostProcessing.h"
|
||||||
#include "VideoCommon/RenderState.h"
|
#include "VideoCommon/RenderState.h"
|
||||||
#include "VideoCommon/ShaderGenCommon.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/VertexShaderManager.h"
|
|
||||||
#include "VideoCommon/VideoBackendBase.h"
|
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
#include "VideoCommon/XFMemory.h"
|
|
||||||
|
|
||||||
namespace OGL
|
namespace OGL
|
||||||
{
|
{
|
||||||
|
@ -55,6 +55,7 @@ Make AA apply instantly during gameplay if possible
|
|||||||
|
|
||||||
#include "VideoCommon/FramebufferManager.h"
|
#include "VideoCommon/FramebufferManager.h"
|
||||||
#include "VideoCommon/TextureCacheBase.h"
|
#include "VideoCommon/TextureCacheBase.h"
|
||||||
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
namespace OGL
|
namespace OGL
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "VideoBackends/Vulkan/VKTexture.h"
|
#include "VideoBackends/Vulkan/VKTexture.h"
|
||||||
#include "VideoBackends/Vulkan/VertexFormat.h"
|
#include "VideoBackends/Vulkan/VertexFormat.h"
|
||||||
#include "VideoBackends/Vulkan/VulkanContext.h"
|
#include "VideoBackends/Vulkan/VulkanContext.h"
|
||||||
#include "VideoCommon/Statistics.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
|
|
||||||
namespace Vulkan
|
namespace Vulkan
|
||||||
{
|
{
|
||||||
|
@ -3,9 +3,8 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "VideoCommon/FramebufferManager.h"
|
#include "VideoCommon/FramebufferManager.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "VideoCommon/FramebufferShaderGen.h"
|
|
||||||
#include "VideoCommon/VertexManagerBase.h"
|
|
||||||
|
|
||||||
#include "Common/ChunkFile.h"
|
#include "Common/ChunkFile.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
@ -17,7 +16,10 @@
|
|||||||
#include "VideoCommon/AbstractStagingTexture.h"
|
#include "VideoCommon/AbstractStagingTexture.h"
|
||||||
#include "VideoCommon/AbstractTexture.h"
|
#include "VideoCommon/AbstractTexture.h"
|
||||||
#include "VideoCommon/DriverDetails.h"
|
#include "VideoCommon/DriverDetails.h"
|
||||||
|
#include "VideoCommon/FramebufferShaderGen.h"
|
||||||
#include "VideoCommon/RenderBase.h"
|
#include "VideoCommon/RenderBase.h"
|
||||||
|
#include "VideoCommon/VertexManagerBase.h"
|
||||||
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
// Maximum number of pixels poked in one batch * 6
|
// Maximum number of pixels poked in one batch * 6
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include "VideoCommon/FramebufferManager.h"
|
#include "VideoCommon/FramebufferManager.h"
|
||||||
#include "VideoCommon/TextureDecoder.h"
|
#include "VideoCommon/TextureDecoder.h"
|
||||||
#include "VideoCommon/VertexShaderGen.h"
|
#include "VideoCommon/VertexShaderGen.h"
|
||||||
|
#include "VideoCommon/VideoCommon.h"
|
||||||
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
namespace FramebufferShaderGen
|
namespace FramebufferShaderGen
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
|
|||||||
"};\n");
|
"};\n");
|
||||||
|
|
||||||
out.Write("struct VS_OUTPUT {\n");
|
out.Write("struct VS_OUTPUT {\n");
|
||||||
GenerateVSOutputMembers<ShaderCode>(out, ApiType, uid_data->numTexGens, host_config, "");
|
GenerateVSOutputMembers(out, ApiType, uid_data->numTexGens, host_config, "");
|
||||||
out.Write("};\n");
|
out.Write("};\n");
|
||||||
|
|
||||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||||
@ -100,13 +100,13 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
|
|||||||
out.Write("#define InstanceID gl_InvocationID\n");
|
out.Write("#define InstanceID gl_InvocationID\n");
|
||||||
|
|
||||||
out.Write("VARYING_LOCATION(0) in VertexData {\n");
|
out.Write("VARYING_LOCATION(0) in VertexData {\n");
|
||||||
GenerateVSOutputMembers<ShaderCode>(out, ApiType, uid_data->numTexGens, host_config,
|
GenerateVSOutputMembers(out, ApiType, uid_data->numTexGens, host_config,
|
||||||
GetInterpolationQualifier(msaa, ssaa, true, true));
|
GetInterpolationQualifier(msaa, ssaa, true, true));
|
||||||
out.Write("} vs[%d];\n", vertex_in);
|
out.Write("} vs[%d];\n", vertex_in);
|
||||||
|
|
||||||
out.Write("VARYING_LOCATION(0) out VertexData {\n");
|
out.Write("VARYING_LOCATION(0) out VertexData {\n");
|
||||||
GenerateVSOutputMembers<ShaderCode>(out, ApiType, uid_data->numTexGens, host_config,
|
GenerateVSOutputMembers(out, ApiType, uid_data->numTexGens, host_config,
|
||||||
GetInterpolationQualifier(msaa, ssaa, true, false));
|
GetInterpolationQualifier(msaa, ssaa, true, false));
|
||||||
|
|
||||||
if (stereo)
|
if (stereo)
|
||||||
out.Write("\tflat int layer;\n");
|
out.Write("\tflat int layer;\n");
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "VideoCommon/RenderBase.h"
|
#include "VideoCommon/RenderBase.h"
|
||||||
#include "VideoCommon/ShaderCache.h"
|
#include "VideoCommon/ShaderCache.h"
|
||||||
#include "VideoCommon/VertexManagerBase.h"
|
#include "VideoCommon/VertexManagerBase.h"
|
||||||
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
namespace VideoCommon
|
namespace VideoCommon
|
||||||
|
@ -15,14 +15,19 @@
|
|||||||
#include "VideoCommon/Statistics.h"
|
#include "VideoCommon/Statistics.h"
|
||||||
#include "VideoCommon/VertexLoaderManager.h"
|
#include "VideoCommon/VertexLoaderManager.h"
|
||||||
#include "VideoCommon/VertexManagerBase.h"
|
#include "VideoCommon/VertexManagerBase.h"
|
||||||
|
#include "VideoCommon/VideoCommon.h"
|
||||||
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
#include "imgui.h"
|
#include <imgui.h>
|
||||||
|
|
||||||
std::unique_ptr<VideoCommon::ShaderCache> g_shader_cache;
|
std::unique_ptr<VideoCommon::ShaderCache> g_shader_cache;
|
||||||
|
|
||||||
namespace VideoCommon
|
namespace VideoCommon
|
||||||
{
|
{
|
||||||
ShaderCache::ShaderCache() = default;
|
ShaderCache::ShaderCache() : m_api_type{APIType::Nothing}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ShaderCache::~ShaderCache()
|
ShaderCache::~ShaderCache()
|
||||||
{
|
{
|
||||||
ClearCaches();
|
ClearCaches();
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
class NativeVertexFormat;
|
class NativeVertexFormat;
|
||||||
enum class AbstractTextureFormat : u32;
|
enum class AbstractTextureFormat : u32;
|
||||||
|
enum class APIType;
|
||||||
enum class TextureFormat;
|
enum class TextureFormat;
|
||||||
enum class TLUTFormat;
|
enum class TLUTFormat;
|
||||||
|
|
||||||
@ -191,7 +192,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Configuration bits.
|
// Configuration bits.
|
||||||
APIType m_api_type = APIType::Nothing;
|
APIType m_api_type;
|
||||||
ShaderHostConfig m_host_config = {};
|
ShaderHostConfig m_host_config = {};
|
||||||
std::unique_ptr<AsyncShaderCompiler> m_async_shader_compiler;
|
std::unique_ptr<AsyncShaderCompiler> m_async_shader_compiler;
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "VideoCommon/VideoCommon.h"
|
||||||
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
ShaderHostConfig ShaderHostConfig::GetCurrent()
|
ShaderHostConfig ShaderHostConfig::GetCurrent()
|
||||||
{
|
{
|
||||||
@ -84,3 +86,100 @@ std::string GetDiskShaderCacheFileName(APIType api_type, const char* type, bool
|
|||||||
filename += ".cache";
|
filename += ".cache";
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DefineOutputMember(ShaderCode& object, APIType api_type, std::string_view qualifier,
|
||||||
|
std::string_view type, std::string_view name, int var_index,
|
||||||
|
std::string_view semantic = {}, int semantic_index = -1)
|
||||||
|
{
|
||||||
|
object.WriteFmt("\t{} {} {}", qualifier, type, name);
|
||||||
|
|
||||||
|
if (var_index != -1)
|
||||||
|
object.WriteFmt("{}", var_index);
|
||||||
|
|
||||||
|
if (api_type == APIType::D3D && !semantic.empty())
|
||||||
|
{
|
||||||
|
if (semantic_index != -1)
|
||||||
|
object.WriteFmt(" : {}{}", semantic, semantic_index);
|
||||||
|
else
|
||||||
|
object.WriteFmt(" : {}", semantic);
|
||||||
|
}
|
||||||
|
|
||||||
|
object.WriteFmt(";\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenerateVSOutputMembers(ShaderCode& object, APIType api_type, u32 texgens,
|
||||||
|
const ShaderHostConfig& host_config, std::string_view qualifier)
|
||||||
|
{
|
||||||
|
DefineOutputMember(object, api_type, qualifier, "float4", "pos", -1, "SV_Position");
|
||||||
|
DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 0, "COLOR", 0);
|
||||||
|
DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 1, "COLOR", 1);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < texgens; ++i)
|
||||||
|
DefineOutputMember(object, api_type, qualifier, "float3", "tex", i, "TEXCOORD", i);
|
||||||
|
|
||||||
|
if (!host_config.fast_depth_calc)
|
||||||
|
DefineOutputMember(object, api_type, qualifier, "float4", "clipPos", -1, "TEXCOORD", texgens);
|
||||||
|
|
||||||
|
if (host_config.per_pixel_lighting)
|
||||||
|
{
|
||||||
|
DefineOutputMember(object, api_type, qualifier, "float3", "Normal", -1, "TEXCOORD",
|
||||||
|
texgens + 1);
|
||||||
|
DefineOutputMember(object, api_type, qualifier, "float3", "WorldPos", -1, "TEXCOORD",
|
||||||
|
texgens + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (host_config.backend_geometry_shaders)
|
||||||
|
{
|
||||||
|
DefineOutputMember(object, api_type, qualifier, "float", "clipDist", 0, "SV_ClipDistance", 0);
|
||||||
|
DefineOutputMember(object, api_type, qualifier, "float", "clipDist", 1, "SV_ClipDistance", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssignVSOutputMembers(ShaderCode& object, std::string_view a, std::string_view b, u32 texgens,
|
||||||
|
const ShaderHostConfig& host_config)
|
||||||
|
{
|
||||||
|
object.WriteFmt("\t{}.pos = {}.pos;\n", a, b);
|
||||||
|
object.WriteFmt("\t{}.colors_0 = {}.colors_0;\n", a, b);
|
||||||
|
object.WriteFmt("\t{}.colors_1 = {}.colors_1;\n", a, b);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < texgens; ++i)
|
||||||
|
object.WriteFmt("\t{}.tex{} = {}.tex{};\n", a, i, b, i);
|
||||||
|
|
||||||
|
if (!host_config.fast_depth_calc)
|
||||||
|
object.WriteFmt("\t{}.clipPos = {}.clipPos;\n", a, b);
|
||||||
|
|
||||||
|
if (host_config.per_pixel_lighting)
|
||||||
|
{
|
||||||
|
object.WriteFmt("\t{}.Normal = {}.Normal;\n", a, b);
|
||||||
|
object.WriteFmt("\t{}.WorldPos = {}.WorldPos;\n", a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (host_config.backend_geometry_shaders)
|
||||||
|
{
|
||||||
|
object.WriteFmt("\t{}.clipDist0 = {}.clipDist0;\n", a, b);
|
||||||
|
object.WriteFmt("\t{}.clipDist1 = {}.clipDist1;\n", a, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* GetInterpolationQualifier(bool msaa, bool ssaa, bool in_glsl_interface_block, bool in)
|
||||||
|
{
|
||||||
|
if (!msaa)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// Without GL_ARB_shading_language_420pack support, the interpolation qualifier must be
|
||||||
|
// "centroid in" and not "centroid", even within an interface block.
|
||||||
|
if (in_glsl_interface_block && !g_ActiveConfig.backend_info.bSupportsBindingLayout)
|
||||||
|
{
|
||||||
|
if (!ssaa)
|
||||||
|
return in ? "centroid in" : "centroid out";
|
||||||
|
else
|
||||||
|
return in ? "sample in" : "sample out";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!ssaa)
|
||||||
|
return "centroid";
|
||||||
|
else
|
||||||
|
return "sample";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <map>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -16,8 +15,8 @@
|
|||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
#include "VideoCommon/VideoCommon.h"
|
|
||||||
#include "VideoCommon/VideoConfig.h"
|
enum class APIType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common interface for classes that need to go through the shader generation path
|
* Common interface for classes that need to go through the shader generation path
|
||||||
@ -193,82 +192,11 @@ union ShaderHostConfig
|
|||||||
std::string GetDiskShaderCacheFileName(APIType api_type, const char* type, bool include_gameid,
|
std::string GetDiskShaderCacheFileName(APIType api_type, const char* type, bool include_gameid,
|
||||||
bool include_host_config, bool include_api = true);
|
bool include_host_config, bool include_api = true);
|
||||||
|
|
||||||
template <class T>
|
void GenerateVSOutputMembers(ShaderCode& object, APIType api_type, u32 texgens,
|
||||||
void DefineOutputMember(T& object, APIType api_type, std::string_view qualifier,
|
const ShaderHostConfig& host_config, std::string_view qualifier);
|
||||||
std::string_view type, std::string_view name, int var_index,
|
|
||||||
std::string_view semantic = {}, int semantic_index = -1)
|
|
||||||
{
|
|
||||||
object.WriteFmt("\t{} {} {}", qualifier, type, name);
|
|
||||||
|
|
||||||
if (var_index != -1)
|
void AssignVSOutputMembers(ShaderCode& object, std::string_view a, std::string_view b, u32 texgens,
|
||||||
object.WriteFmt("{}", var_index);
|
const ShaderHostConfig& host_config);
|
||||||
|
|
||||||
if (api_type == APIType::D3D && !semantic.empty())
|
|
||||||
{
|
|
||||||
if (semantic_index != -1)
|
|
||||||
object.WriteFmt(" : {}{}", semantic, semantic_index);
|
|
||||||
else
|
|
||||||
object.WriteFmt(" : {}", semantic);
|
|
||||||
}
|
|
||||||
|
|
||||||
object.WriteFmt(";\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void GenerateVSOutputMembers(T& object, APIType api_type, u32 texgens,
|
|
||||||
const ShaderHostConfig& host_config, std::string_view qualifier)
|
|
||||||
{
|
|
||||||
DefineOutputMember(object, api_type, qualifier, "float4", "pos", -1, "SV_Position");
|
|
||||||
DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 0, "COLOR", 0);
|
|
||||||
DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 1, "COLOR", 1);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < texgens; ++i)
|
|
||||||
DefineOutputMember(object, api_type, qualifier, "float3", "tex", i, "TEXCOORD", i);
|
|
||||||
|
|
||||||
if (!host_config.fast_depth_calc)
|
|
||||||
DefineOutputMember(object, api_type, qualifier, "float4", "clipPos", -1, "TEXCOORD", texgens);
|
|
||||||
|
|
||||||
if (host_config.per_pixel_lighting)
|
|
||||||
{
|
|
||||||
DefineOutputMember(object, api_type, qualifier, "float3", "Normal", -1, "TEXCOORD",
|
|
||||||
texgens + 1);
|
|
||||||
DefineOutputMember(object, api_type, qualifier, "float3", "WorldPos", -1, "TEXCOORD",
|
|
||||||
texgens + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (host_config.backend_geometry_shaders)
|
|
||||||
{
|
|
||||||
DefineOutputMember(object, api_type, qualifier, "float", "clipDist", 0, "SV_ClipDistance", 0);
|
|
||||||
DefineOutputMember(object, api_type, qualifier, "float", "clipDist", 1, "SV_ClipDistance", 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void AssignVSOutputMembers(T& object, std::string_view a, std::string_view b, u32 texgens,
|
|
||||||
const ShaderHostConfig& host_config)
|
|
||||||
{
|
|
||||||
object.WriteFmt("\t{}.pos = {}.pos;\n", a, b);
|
|
||||||
object.WriteFmt("\t{}.colors_0 = {}.colors_0;\n", a, b);
|
|
||||||
object.WriteFmt("\t{}.colors_1 = {}.colors_1;\n", a, b);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < texgens; ++i)
|
|
||||||
object.WriteFmt("\t{}.tex{} = {}.tex{};\n", a, i, b, i);
|
|
||||||
|
|
||||||
if (!host_config.fast_depth_calc)
|
|
||||||
object.WriteFmt("\t{}.clipPos = {}.clipPos;\n", a, b);
|
|
||||||
|
|
||||||
if (host_config.per_pixel_lighting)
|
|
||||||
{
|
|
||||||
object.WriteFmt("\t{}.Normal = {}.Normal;\n", a, b);
|
|
||||||
object.WriteFmt("\t{}.WorldPos = {}.WorldPos;\n", a, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (host_config.backend_geometry_shaders)
|
|
||||||
{
|
|
||||||
object.WriteFmt("\t{}.clipDist0 = {}.clipDist0;\n", a, b);
|
|
||||||
object.WriteFmt("\t{}.clipDist1 = {}.clipDist1;\n", a, b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We use the flag "centroid" to fix some MSAA rendering bugs. With MSAA, the
|
// We use the flag "centroid" to fix some MSAA rendering bugs. With MSAA, the
|
||||||
// pixel shader will be executed for each pixel which has at least one passed sample.
|
// pixel shader will be executed for each pixel which has at least one passed sample.
|
||||||
@ -278,29 +206,8 @@ void AssignVSOutputMembers(T& object, std::string_view a, std::string_view b, u3
|
|||||||
// As a workaround, we interpolate at the centroid of the coveraged pixel, which
|
// As a workaround, we interpolate at the centroid of the coveraged pixel, which
|
||||||
// is always inside the primitive.
|
// is always inside the primitive.
|
||||||
// Without MSAA, this flag is defined to have no effect.
|
// Without MSAA, this flag is defined to have no effect.
|
||||||
inline const char* GetInterpolationQualifier(bool msaa, bool ssaa,
|
const char* GetInterpolationQualifier(bool msaa, bool ssaa, bool in_glsl_interface_block = false,
|
||||||
bool in_glsl_interface_block = false, bool in = false)
|
bool in = false);
|
||||||
{
|
|
||||||
if (!msaa)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
// Without GL_ARB_shading_language_420pack support, the interpolation qualifier must be
|
|
||||||
// "centroid in" and not "centroid", even within an interface block.
|
|
||||||
if (in_glsl_interface_block && !g_ActiveConfig.backend_info.bSupportsBindingLayout)
|
|
||||||
{
|
|
||||||
if (!ssaa)
|
|
||||||
return in ? "centroid in" : "centroid out";
|
|
||||||
else
|
|
||||||
return in ? "sample in" : "sample out";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!ssaa)
|
|
||||||
return "centroid";
|
|
||||||
else
|
|
||||||
return "sample";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constant variable names
|
// Constant variable names
|
||||||
#define I_COLORS "color"
|
#define I_COLORS "color"
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
#include "VideoCommon/UberShaderCommon.h"
|
#include "VideoCommon/UberShaderCommon.h"
|
||||||
#include "VideoCommon/NativeVertexFormat.h"
|
#include "VideoCommon/NativeVertexFormat.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/ShaderGenCommon.h"
|
||||||
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/XFMemory.h"
|
#include "VideoCommon/XFMemory.h"
|
||||||
|
|
||||||
namespace UberShader
|
namespace UberShader
|
||||||
|
@ -9,8 +9,11 @@
|
|||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include "VideoCommon/ShaderGenCommon.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "VideoCommon/VideoCommon.h"
|
|
||||||
|
class ShaderCode;
|
||||||
|
enum class APIType;
|
||||||
|
union ShaderHostConfig;
|
||||||
|
|
||||||
namespace UberShader
|
namespace UberShader
|
||||||
{
|
{
|
||||||
|
@ -3,10 +3,15 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "VideoCommon/UberShaderPixel.h"
|
#include "VideoCommon/UberShaderPixel.h"
|
||||||
|
|
||||||
#include "VideoCommon/BPMemory.h"
|
#include "VideoCommon/BPMemory.h"
|
||||||
#include "VideoCommon/DriverDetails.h"
|
#include "VideoCommon/DriverDetails.h"
|
||||||
#include "VideoCommon/NativeVertexFormat.h"
|
#include "VideoCommon/NativeVertexFormat.h"
|
||||||
|
#include "VideoCommon/PixelShaderGen.h"
|
||||||
|
#include "VideoCommon/ShaderGenCommon.h"
|
||||||
#include "VideoCommon/UberShaderCommon.h"
|
#include "VideoCommon/UberShaderCommon.h"
|
||||||
|
#include "VideoCommon/VideoCommon.h"
|
||||||
|
#include "VideoCommon/VideoConfig.h"
|
||||||
#include "VideoCommon/XFMemory.h"
|
#include "VideoCommon/XFMemory.h"
|
||||||
|
|
||||||
namespace UberShader
|
namespace UberShader
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "VideoCommon/PixelShaderGen.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "VideoCommon/ShaderGenCommon.h"
|
||||||
|
|
||||||
|
enum class APIType;
|
||||||
|
|
||||||
namespace UberShader
|
namespace UberShader
|
||||||
{
|
{
|
||||||
|
@ -3,11 +3,12 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "VideoCommon/UberShaderVertex.h"
|
#include "VideoCommon/UberShaderVertex.h"
|
||||||
|
|
||||||
#include "VideoCommon/DriverDetails.h"
|
#include "VideoCommon/DriverDetails.h"
|
||||||
#include "VideoCommon/NativeVertexFormat.h"
|
#include "VideoCommon/NativeVertexFormat.h"
|
||||||
#include "VideoCommon/UberShaderCommon.h"
|
#include "VideoCommon/UberShaderCommon.h"
|
||||||
#include "VideoCommon/VertexShaderGen.h"
|
#include "VideoCommon/VertexShaderGen.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/XFMemory.h"
|
#include "VideoCommon/XFMemory.h"
|
||||||
|
|
||||||
namespace UberShader
|
namespace UberShader
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "VideoCommon/VertexLoaderManager.h"
|
#include "VideoCommon/VertexLoaderManager.h"
|
||||||
#include "VideoCommon/VertexShaderManager.h"
|
#include "VideoCommon/VertexShaderManager.h"
|
||||||
#include "VideoCommon/VideoBackendBase.h"
|
#include "VideoCommon/VideoBackendBase.h"
|
||||||
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
#include "VideoCommon/XFMemory.h"
|
#include "VideoCommon/XFMemory.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user