Merge pull request #13622 from hrydgard/move-shader-writer

Move ShaderWriter to Common
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2020-11-04 11:44:08 +01:00
commit 28da9958e2
36 files changed
+160 -145

No files matched your search

+4 -2
View File
@@ -496,6 +496,10 @@ add_library(Common STATIC
Common/GPU/thin3d.cpp
Common/GPU/thin3d.h
Common/GPU/thin3d_create.h
Common/GPU/Shader.cpp
Common/GPU/Shader.h
Common/GPU/ShaderWriter.cpp
Common/GPU/ShaderWriter.h
Common/GPU/OpenGL/GLCommon.h
Common/GPU/OpenGL/GLDebugLog.cpp
Common/GPU/OpenGL/GLDebugLog.h
@@ -1356,8 +1360,6 @@ set(GPU_SOURCES
GPU/Common/ShaderUniforms.h
GPU/Common/ShaderCommon.cpp
GPU/Common/ShaderCommon.h
GPU/Common/ShaderWriter.cpp
GPU/Common/ShaderWriter.h
GPU/Common/ShaderTranslation.cpp
GPU/Common/ShaderTranslation.h
GPU/Common/SplineCommon.cpp
+4
View File
@@ -428,6 +428,8 @@
<ClInclude Include="GPU\OpenGL\GLSLProgram.h" />
<ClInclude Include="GPU\OpenGL\GLCommon.h" />
<ClInclude Include="GPU\OpenGL\GLDebugLog.h" />
<ClInclude Include="GPU\Shader.h" />
<ClInclude Include="GPU\ShaderWriter.h" />
<ClInclude Include="GPU\thin3d.h" />
<ClInclude Include="GPU\thin3d_create.h" />
<ClInclude Include="GPU\Vulkan\VulkanContext.h" />
@@ -749,6 +751,8 @@
<ClCompile Include="GPU\OpenGL\GLSLProgram.cpp" />
<ClCompile Include="GPU\OpenGL\GLDebugLog.cpp" />
<ClCompile Include="GPU\OpenGL\thin3d_gl.cpp" />
<ClCompile Include="GPU\Shader.cpp" />
<ClCompile Include="GPU\ShaderWriter.cpp" />
<ClCompile Include="GPU\thin3d.cpp" />
<ClCompile Include="GPU\Vulkan\thin3d_vulkan.cpp" />
<ClCompile Include="GPU\Vulkan\VulkanContext.cpp" />
+12
View File
@@ -375,6 +375,12 @@
<ClInclude Include="Data\Collections\ThreadSafeList.h">
<Filter>Data\Collections</Filter>
</ClInclude>
<ClInclude Include="GPU\Shader.h">
<Filter>GPU</Filter>
</ClInclude>
<ClInclude Include="GPU\ShaderWriter.h">
<Filter>GPU</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ABI.cpp" />
@@ -723,6 +729,12 @@
<ClCompile Include="Render\Text\draw_text_win.cpp">
<Filter>Render\Text</Filter>
</ClCompile>
<ClCompile Include="GPU\Shader.cpp">
<Filter>GPU</Filter>
</ClCompile>
<ClCompile Include="GPU\ShaderWriter.cpp">
<Filter>GPU</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Crypto">
+7 -5
View File
@@ -8,6 +8,7 @@
#include "Common/Math/math_util.h"
#include "Common/Math/lin/matrix4x4.h"
#include "Common/GPU/thin3d.h"
#include "Common/GPU/Shader.h"
#include "Common/GPU/OpenGL/DataFormatGL.h"
#include "Common/GPU/OpenGL/GLCommon.h"
#include "Common/GPU/OpenGL/GLDebugLog.h"
@@ -254,7 +255,7 @@ public:
private:
GLRenderManager *render_;
ShaderStage stage_;
ShaderLanguage language_ = ShaderLanguage::GLSL_ES_200;
ShaderLanguage language_ = GLSL_1xx;
GLRShader *shader_ = nullptr;
GLuint glstage_ = 0;
std::string source_; // So we can recompile in case of context loss.
@@ -345,10 +346,11 @@ public:
return caps_;
}
uint32_t GetSupportedShaderLanguages() const override {
if (gl_extensions.IsGLES)
return (uint32_t)ShaderLanguage::GLSL_ES_200 | (uint32_t)ShaderLanguage::GLSL_ES_300;
else
return (uint32_t)ShaderLanguage::GLSL_ES_200 | (uint32_t)ShaderLanguage::GLSL_410;
if (gl_extensions.GLES3) {
return (uint32_t)(ShaderLanguage::GLSL_3xx | ShaderLanguage::GLSL_1xx);
} else {
return (uint32_t)ShaderLanguage::GLSL_1xx;
}
}
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
+1
View File
@@ -0,0 +1 @@
#include "Common/GPU/Shader.h"
+43
View File
@@ -0,0 +1,43 @@
#pragma once
// GLSL_1xx and GLSL_3xx each cover a lot of sub variants. All the little quirks
// that differ are covered in ShaderLanguageDesc.
// Defined as a bitmask so stuff like GetSupportedShaderLanguages can return combinations.
enum ShaderLanguage {
GLSL_1xx = 1,
GLSL_3xx = 2,
GLSL_VULKAN = 4,
HLSL_D3D9 = 8,
HLSL_D3D11 = 16,
};
inline bool ShaderLanguageIsOpenGL(ShaderLanguage lang) {
return lang == GLSL_1xx || lang == GLSL_3xx;
}
enum class ShaderStage {
Vertex,
Fragment
};
struct ShaderLanguageDesc {
explicit ShaderLanguageDesc(ShaderLanguage lang);
int glslVersionNumber = 0;
ShaderLanguage shaderLanguage;
bool gles = false;
const char *varying_fs = nullptr;
const char *varying_vs = nullptr;
const char *attribute = nullptr;
const char *fragColor0 = nullptr;
const char *fragColor1 = nullptr;
const char *texture = nullptr;
const char *texelFetch = nullptr;
const char *lastFragData = nullptr;
const char *framebufferFetchExtension = nullptr;
const char *vsOutPrefix = "";
bool glslES30 = false;
bool bitwiseOps = false;
bool forceMatrix4x4 = false;
bool coefsFromBuffers = false;
};
@@ -1,4 +1,9 @@
#include "GPU/Common/ShaderWriter.h"
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include "Common/GPU/Shader.h"
#include "Common/GPU/ShaderWriter.h"
const char *vulkan_glsl_preamble_fs =
"#version 450\n"
@@ -1,9 +1,9 @@
#pragma once
#include <cstring>
#include "Common/Log.h"
#include "GPU/ge_constants.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/ShaderCommon.h"
#include "Common/GPU/Shader.h"
// Helps generate a shader compatible with all backends.
// Using #defines and magic in this class, we partially define our own shader language that basically looks
+5 -5
View File
@@ -101,7 +101,7 @@ bool RefCountedObject::ReleaseAssertLast() {
// The Vulkan ones can be re-used with modern GL later if desired, as they're just GLSL.
static const std::vector<ShaderSource> fsTexCol = {
{ShaderLanguage::GLSL_ES_200,
{ShaderLanguage::GLSL_1xx,
"#ifdef GL_ES\n"
"precision lowp float;\n"
"#endif\n"
@@ -145,7 +145,7 @@ static const std::vector<ShaderSource> fsTexCol = {
};
static const std::vector<ShaderSource> fsTexColRBSwizzle = {
{ShaderLanguage::GLSL_ES_200,
{GLSL_1xx,
"#ifdef GL_ES\n"
"precision lowp float;\n"
"#endif\n"
@@ -189,7 +189,7 @@ static const std::vector<ShaderSource> fsTexColRBSwizzle = {
};
static const std::vector<ShaderSource> fsCol = {
{ ShaderLanguage::GLSL_ES_200,
{ GLSL_1xx,
"#ifdef GL_ES\n"
"precision lowp float;\n"
"#endif\n"
@@ -226,7 +226,7 @@ static const std::vector<ShaderSource> fsCol = {
// ================================== VERTEX SHADERS
static const std::vector<ShaderSource> vsCol = {
{ ShaderLanguage::GLSL_ES_200,
{ GLSL_1xx,
"#if __VERSION__ >= 130\n"
"#define attribute in\n"
"#define varying out\n"
@@ -288,7 +288,7 @@ const UniformBufferDesc vsColBufDesc { sizeof(VsColUB), {
} };
static const std::vector<ShaderSource> vsTexCol = {
{ ShaderLanguage::GLSL_ES_200,
{ GLSL_1xx,
"#if __VERSION__ >= 130\n"
"#define attribute in\n"
"#define varying out\n"
+2 -10
View File
@@ -12,7 +12,8 @@
#include <string>
#include <vector>
#include "DataFormat.h"
#include "Common/GPU/DataFormat.h"
#include "Common/GPU/Shader.h"
namespace Lin {
class Matrix4x4;
@@ -203,15 +204,6 @@ enum class TextureAddressMode {
CLAMP_TO_BORDER,
};
enum class ShaderLanguage {
GLSL_ES_200 = 1,
GLSL_ES_300 = 2,
GLSL_410 = 4,
GLSL_VULKAN = 8,
HLSL_D3D9 = 32,
HLSL_D3D11 = 64,
};
enum FormatSupport {
FMT_RENDERTARGET = 1,
FMT_TEXTURE = 2,
+3 -3
View File
@@ -286,7 +286,7 @@ void GenerateDepalShaderFloat(char *buffer, GEBufferFormat pixelFormat, ShaderLa
float texel_offset = ((float)clutBase + 0.5f) / texturePixels;
sprintf(offset, " + %f", texel_offset);
if (lang == GLSL_140) {
if (lang == GLSL_1xx) {
if (gl_extensions.IsGLES) {
WRITE(p, "#version 100\n");
WRITE(p, "precision mediump float;\n");
@@ -318,10 +318,10 @@ void GenerateDepalShaderFloat(char *buffer, GEBufferFormat pixelFormat, ShaderLa
void GenerateDepalShader(char *buffer, GEBufferFormat pixelFormat, ShaderLanguage language) {
switch (language) {
case GLSL_140:
case GLSL_1xx:
GenerateDepalShaderFloat(buffer, pixelFormat, language);
break;
case GLSL_300:
case GLSL_3xx:
case GLSL_VULKAN:
case HLSL_D3D11:
GenerateDepalShader300(buffer, pixelFormat, language);
+3 -2
View File
@@ -18,8 +18,9 @@
#pragma once
#include <cstdint>
#include "Common/GPU/Shader.h"
#include "GPU/ge_constants.h"
#include "GPU/Common/ShaderCommon.h"
static const int DEPAL_TEXTURE_OLD_AGE = 120;
@@ -32,4 +33,4 @@ public:
protected:
uint32_t GenerateShaderID(uint32_t clutMode, GEBufferFormat pixelFormat) const;
uint32_t GetClutID(GEPaletteFormat clutFormat, uint32_t clutHash) const;
};
};
+1 -1
View File
@@ -21,13 +21,13 @@
#include "Common/Log.h"
#include "Common/StringUtils.h"
#include "Common/GPU/OpenGL/GLFeatures.h"
#include "Common/GPU/ShaderWriter.h"
#include "Core/Reporting.h"
#include "Core/Config.h"
#include "GPU/Common/GPUStateUtils.h"
#include "GPU/Common/ShaderId.h"
#include "GPU/Common/ShaderUniforms.h"
#include "GPU/Common/FragmentShaderGenerator.h"
#include "GPU/Common/ShaderWriter.h"
#include "GPU/ge_constants.h"
#include "GPU/GPUState.h"
+1 -1
View File
@@ -17,7 +17,7 @@
#pragma once
#include "GPU/Common/ShaderCommon.h"
#include "Common/GPU/Shader.h"
struct FShaderID;
+3 -25
View File
@@ -240,8 +240,8 @@ bool PresentationCommon::BuildPostShader(const ShaderInfo *shaderInfo, const Sha
}
std::string vsError, fsError;
Draw::ShaderModule *vs = CompileShaderModule(Draw::ShaderStage::VERTEX, GLSL_140, vsSourceGLSL, &vsError);
Draw::ShaderModule *fs = CompileShaderModule(Draw::ShaderStage::FRAGMENT, GLSL_140, fsSourceGLSL, &fsError);
Draw::ShaderModule *vs = CompileShaderModule(Draw::ShaderStage::VERTEX, GLSL_1xx, vsSourceGLSL, &vsError);
Draw::ShaderModule *fs = CompileShaderModule(Draw::ShaderStage::FRAGMENT, GLSL_1xx, fsSourceGLSL, &fsError);
// Don't worry, CompileShaderModule makes sure they get freed if one succeeded.
if (!fs || !vs) {
@@ -476,29 +476,7 @@ Draw::ShaderModule *PresentationCommon::CompileShaderModule(Draw::ShaderStage st
}
}
Draw::ShaderLanguage mappedLang;
// These aren't exact, unfortunately, but we just need the type Draw will accept.
switch (lang_) {
case GLSL_140:
mappedLang = Draw::ShaderLanguage::GLSL_ES_200;
break;
case GLSL_300:
mappedLang = Draw::ShaderLanguage::GLSL_410;
break;
case GLSL_VULKAN:
mappedLang = Draw::ShaderLanguage::GLSL_VULKAN;
break;
case HLSL_D3D9:
mappedLang = Draw::ShaderLanguage::HLSL_D3D9;
break;
case HLSL_D3D11:
mappedLang = Draw::ShaderLanguage::HLSL_D3D11;
break;
default:
mappedLang = Draw::ShaderLanguage::GLSL_ES_200;
break;
}
Draw::ShaderModule *shader = draw_->CreateShaderModule(stage, mappedLang, (const uint8_t *)translated.c_str(), translated.size(), "postshader");
Draw::ShaderModule *shader = draw_->CreateShaderModule(stage, lang_, (const uint8_t *)translated.c_str(), translated.size(), "postshader");
if (shader)
postShaderModules_.push_back(shader);
return shader;
+1 -1
View File
@@ -17,7 +17,7 @@
#pragma once
#include "GPU/Common/ShaderCommon.h"
#include "Common/GPU/Shader.h"
struct CardboardSettings {
bool enabled;
+4 -3
View File
@@ -4,7 +4,8 @@
#include "ext/glslang/SPIRV/GlslangToSpv.h"
#include "ShaderCommon.h"
#include "Common/GPU/Shader.h"
#include "GPU/Common/ShaderCommon.h"
void init_resources(TBuiltInResource &Resources) {
Resources.maxLights = 32;
@@ -104,7 +105,7 @@ void init_resources(TBuiltInResource &Resources) {
ShaderLanguageDesc::ShaderLanguageDesc(ShaderLanguage lang) {
shaderLanguage = lang;
switch (lang) {
case GLSL_140:
case GLSL_1xx:
// Just used in the shader test, and as a basis for the others in DetectShaderLanguage.
glslVersionNumber = 110;
attribute = "attribute";
@@ -119,7 +120,7 @@ ShaderLanguageDesc::ShaderLanguageDesc(ShaderLanguage lang) {
gles = false;
forceMatrix4x4 = true;
break;
case GLSL_300:
case GLSL_3xx:
// Just used in the shader test.
glslVersionNumber = 300; // GLSL ES 3.0
varying_vs = "out";
-39
View File
@@ -24,18 +24,6 @@ namespace Draw {
class DrawContext;
}
enum ShaderLanguage {
GLSL_140, // really covers a lot more. This set of languages is not good.
GLSL_300,
GLSL_VULKAN,
HLSL_D3D9,
HLSL_D3D11,
};
inline bool ShaderLanguageIsOpenGL(ShaderLanguage lang) {
return lang == GLSL_140 || lang == GLSL_300;
}
enum DebugShaderType {
SHADER_TYPE_VERTEX = 0,
SHADER_TYPE_FRAGMENT = 1,
@@ -52,11 +40,6 @@ enum DebugShaderStringType {
SHADER_STRING_STATS = 2,
};
enum class ShaderStage {
Vertex,
Fragment
};
// Shared between the backends. Not all are necessarily used by each backend, but this lets us share
// more code than before.
enum : uint64_t {
@@ -147,28 +130,6 @@ enum DoLightComputation {
LIGHT_FULL,
};
struct ShaderLanguageDesc {
explicit ShaderLanguageDesc(ShaderLanguage lang);
int glslVersionNumber = 0;
ShaderLanguage shaderLanguage;
bool gles = false;
const char *varying_fs = nullptr;
const char *varying_vs = nullptr;
const char *attribute = nullptr;
const char *fragColor0 = nullptr;
const char *fragColor1 = nullptr;
const char *texture = nullptr;
const char *texelFetch = nullptr;
const char *lastFragData = nullptr;
const char *framebufferFetchExtension = nullptr;
const char *vsOutPrefix = "";
bool glslES30 = false;
bool bitwiseOps = false;
bool forceMatrix4x4 = false;
bool coefsFromBuffers = false;
};
// PSP vertex format.
enum class PspAttributeLocation {
POSITION = 0,
+5 -4
View File
@@ -36,6 +36,7 @@
#include "Common/Log.h"
#include "Common/StringUtils.h"
#include "Common/GPU/Shader.h"
#include "GPU/Common/ShaderTranslation.h"
#include "ext/glslang/SPIRV/GlslangToSpv.h"
@@ -219,10 +220,10 @@ bool ConvertToVulkanGLSL(std::string *dest, TranslatedShaderMetadata *destMetada
}
bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShaderMetadata *destMetadata, std::string src, ShaderLanguage srcLang, Draw::ShaderStage stage, std::string *errorMessage) {
if (srcLang != GLSL_300 && srcLang != GLSL_140)
if (srcLang != GLSL_3xx && srcLang != GLSL_1xx)
return false;
if ((srcLang == GLSL_140 || srcLang == GLSL_300) && destLang == GLSL_VULKAN) {
if ((srcLang == GLSL_1xx || srcLang == GLSL_3xx) && destLang == GLSL_VULKAN) {
// Let's just mess about at the string level, no need to recompile.
bool result = ConvertToVulkanGLSL(dest, destMetadata, src, stage, errorMessage);
return result;
@@ -326,7 +327,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShade
return true;
}
#endif
case GLSL_140:
case GLSL_1xx:
{
spirv_cross::CompilerGLSL glsl(std::move(spirv));
// The SPIR-V is now parsed, and we can perform reflection on it.
@@ -351,7 +352,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShade
*dest = glsl.compile();
return true;
}
case GLSL_300:
case GLSL_3xx:
{
spirv_cross::CompilerGLSL glsl(std::move(spirv));
// The SPIR-V is now parsed, and we can perform reflection on it.
+2 -1
View File
@@ -18,7 +18,8 @@
#pragma once
#include <string>
#include "GPU/Common/ShaderCommon.h"
#include "Common/GPU/Shader.h"
#include "Common/GPU/thin3d.h"
struct TranslatedShaderMetadata {
+2 -2
View File
@@ -19,14 +19,14 @@
#include <cstdlib>
#include <locale.h>
#include "Common/GPU/OpenGL/GLFeatures.h"
#include "Common/StringUtils.h"
#include "Common/GPU/OpenGL/GLFeatures.h"
#include "Common/GPU/ShaderWriter.h"
#include "Core/Config.h"
#include "GPU/ge_constants.h"
#include "GPU/GPUState.h"
#include "GPU/Common/ShaderId.h"
#include "GPU/Common/ShaderUniforms.h"
#include "GPU/Common/ShaderWriter.h"
#include "GPU/Common/VertexDecoderCommon.h"
#include "GPU/Common/VertexShaderGenerator.h"
+3
View File
@@ -17,7 +17,10 @@
#pragma once
#include <cstdint>
#include "Common/CommonTypes.h"
#include "Common/GPU/Shader.h"
struct VShaderID;
+1 -1
View File
@@ -162,7 +162,7 @@ DepalShader *DepalShaderCacheGLES::GetDepalettizeShader(uint32_t clutMode, GEBuf
char *buffer = new char[2048];
GenerateDepalShader(buffer, pixelFormat, useGL3_ ? GLSL_300 : GLSL_140);
GenerateDepalShader(buffer, pixelFormat, useGL3_ ? GLSL_3xx : GLSL_1xx);
std::string src(buffer);
GLRShader *fragShader = render_->CreateShader(GL_FRAGMENT_SHADER, src, "depal");
+1 -1
View File
@@ -105,7 +105,7 @@ FramebufferManagerGLES::FramebufferManagerGLES(Draw::DrawContext *draw, GLRender
needGLESRebinds_ = true;
CreateDeviceObjects();
render_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
presentation_->SetLanguage(gl_extensions.IsCoreContext ? GLSL_300 : GLSL_140);
presentation_->SetLanguage(gl_extensions.IsCoreContext ? GLSL_3xx : GLSL_1xx);
}
void FramebufferManagerGLES::Init() {
+7 -6
View File
@@ -30,6 +30,7 @@
#include "Common/Math/math_util.h"
#include "Common/Math/lin/matrix4x4.h"
#include "Common/Profiler/Profiler.h"
#include "Common/GPU/Shader.h"
#include "Common/GPU/thin3d.h"
#include "Common/GPU/OpenGL/GLRenderManager.h"
@@ -571,7 +572,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu
}
ShaderManagerGLES::ShaderManagerGLES(Draw::DrawContext *draw)
: ShaderManagerCommon(draw), compat_(GLSL_140), fsCache_(16), vsCache_(16) {
: ShaderManagerCommon(draw), compat_(GLSL_1xx), fsCache_(16), vsCache_(16) {
render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
codeBuffer_ = new char[16384];
lastFSID_.set_invalid();
@@ -590,7 +591,7 @@ void ShaderManagerGLES::DetectShaderLanguage() {
if (compat.gles) {
if (gstate_c.Supports(GPU_SUPPORTS_GLSL_ES_300)) {
compat.shaderLanguage = ShaderLanguage::GLSL_300;
compat.shaderLanguage = ShaderLanguage::GLSL_3xx;
compat.glslVersionNumber = 300; // GLSL ES 3.0
compat.fragColor0 = "fragColor0";
compat.texture = "texture";
@@ -601,7 +602,7 @@ void ShaderManagerGLES::DetectShaderLanguage() {
compat.varying_fs = "in";
compat.attribute = "in";
} else {
compat.shaderLanguage = ShaderLanguage::GLSL_140;
compat.shaderLanguage = ShaderLanguage::GLSL_1xx;
compat.glslVersionNumber = 100; // GLSL ES 1.0
if (gl_extensions.EXT_gpu_shader4) {
compat.bitwiseOps = true;
@@ -615,7 +616,7 @@ void ShaderManagerGLES::DetectShaderLanguage() {
} else {
if (!gl_extensions.ForceGL2 || gl_extensions.IsCoreContext) {
if (gl_extensions.VersionGEThan(3, 3, 0)) {
compat.shaderLanguage = ShaderLanguage::GLSL_300;
compat.shaderLanguage = ShaderLanguage::GLSL_3xx;
compat.glslVersionNumber = 330;
compat.fragColor0 = "fragColor0";
compat.texture = "texture";
@@ -626,13 +627,13 @@ void ShaderManagerGLES::DetectShaderLanguage() {
compat.varying_fs = "in";
compat.attribute = "in";
} else if (gl_extensions.VersionGEThan(3, 0, 0)) {
compat.shaderLanguage = ShaderLanguage::GLSL_140;
compat.shaderLanguage = ShaderLanguage::GLSL_1xx;
compat.glslVersionNumber = 130;
compat.fragColor0 = "fragColor0";
compat.bitwiseOps = true;
compat.texelFetch = "texelFetch";
} else {
compat.shaderLanguage = ShaderLanguage::GLSL_140;
compat.shaderLanguage = ShaderLanguage::GLSL_1xx;
compat.glslVersionNumber = 110;
if (gl_extensions.EXT_gpu_shader4) {
compat.bitwiseOps = true;
-2
View File
@@ -351,7 +351,6 @@
<ClInclude Include="Common\ShaderId.h" />
<ClInclude Include="Common\ShaderTranslation.h" />
<ClInclude Include="Common\ShaderUniforms.h" />
<ClInclude Include="Common\ShaderWriter.h" />
<ClInclude Include="Common\SoftwareTransformCommon.h" />
<ClInclude Include="Common\SplineCommon.h" />
<ClInclude Include="Common\StencilCommon.h" />
@@ -489,7 +488,6 @@
<ClCompile Include="Common\ShaderId.cpp" />
<ClCompile Include="Common\ShaderTranslation.cpp" />
<ClCompile Include="Common\ShaderUniforms.cpp" />
<ClCompile Include="Common\ShaderWriter.cpp" />
<ClCompile Include="Common\SplineCommon.cpp" />
<ClCompile Include="Common\StencilCommon.cpp" />
<ClCompile Include="Common\TextureDecoderNEON.cpp">
-6
View File
@@ -270,9 +270,6 @@
<ClInclude Include="Common\VertexShaderGenerator.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\ShaderWriter.h">
<Filter>Common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Math3D.cpp">
@@ -542,8 +539,5 @@
<ClCompile Include="Common\VertexShaderGenerator.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="Common\ShaderWriter.cpp">
<Filter>Common</Filter>
</ClCompile>
</ItemGroup>
</Project>
+1 -1
View File
@@ -72,7 +72,7 @@ SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
switch (GetGPUBackend()) {
case GPUBackend::OPENGL:
presentation_->SetLanguage(gl_extensions.IsCoreContext ? GLSL_300 : GLSL_140);
presentation_->SetLanguage(gl_extensions.IsCoreContext ? GLSL_3xx : GLSL_1xx);
break;
case GPUBackend::DIRECT3D9:
ShaderTranslationInit();
+3 -2
View File
@@ -1,9 +1,10 @@
#include "GPUDriverTestScreen.h"
#include "Common/Data/Text/I18n.h"
#include "Common/UI/View.h"
#include "Common/GPU/Shader.h"
static const std::vector<Draw::ShaderSource> fsDiscard = {
{Draw::ShaderLanguage::GLSL_ES_200,
{ShaderLanguage::GLSL_1xx,
R"(
#ifdef GL_ES
precision lowp float;
@@ -23,7 +24,7 @@ static const std::vector<Draw::ShaderSource> fsDiscard = {
gl_FragColor = color;
})"
},
{Draw::ShaderLanguage::GLSL_VULKAN,
{ShaderLanguage::GLSL_VULKAN,
R"(#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
+4
View File
@@ -419,6 +419,8 @@
<ClInclude Include="..\..\Common\File\VFS\VFS.h" />
<ClInclude Include="..\..\Common\GPU\DataFormat.h" />
<ClInclude Include="..\..\Common\GPU\OpenGL\GLFeatures.h" />
<ClInclude Include="..\..\Common\GPU\Shader.h" />
<ClInclude Include="..\..\Common\GPU\ShaderWriter.h" />
<ClInclude Include="..\..\Common\GPU\thin3d.h" />
<ClInclude Include="..\..\Common\GPU\thin3d_create.h" />
<ClInclude Include="..\..\Common\Input\GestureDetector.h" />
@@ -536,6 +538,8 @@
<ClCompile Include="..\..\Common\File\VFS\VFS.cpp" />
<ClCompile Include="..\..\Common\GPU\D3D11\thin3d_d3d11.cpp" />
<ClCompile Include="..\..\Common\GPU\OpenGL\GLFeatures.cpp" />
<ClCompile Include="..\..\Common\GPU\Shader.cpp" />
<ClCompile Include="..\..\Common\GPU\ShaderWriter.cpp" />
<ClCompile Include="..\..\Common\GPU\thin3d.cpp" />
<ClCompile Include="..\..\Common\Input\GestureDetector.cpp" />
<ClCompile Include="..\..\Common\Input\InputState.cpp" />
+12
View File
@@ -363,6 +363,12 @@
<ClCompile Include="..\..\Common\Render\Text\draw_text_win.cpp">
<Filter>Render\Text</Filter>
</ClCompile>
<ClCompile Include="..\..\Common\GPU\Shader.cpp">
<Filter>GPU</Filter>
</ClCompile>
<ClCompile Include="..\..\Common\GPU\ShaderWriter.cpp">
<Filter>GPU</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="targetver.h" />
@@ -662,6 +668,12 @@
<ClInclude Include="..\..\Common\Data\Collections\ThreadSafeList.h">
<Filter>Data\Collections</Filter>
</ClInclude>
<ClInclude Include="..\..\Common\GPU\Shader.h">
<Filter>GPU</Filter>
</ClInclude>
<ClInclude Include="..\..\Common\GPU\ShaderWriter.h">
<Filter>GPU</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\ext\libpng17\CMakeLists.txt">
-2
View File
@@ -392,7 +392,6 @@
<ClInclude Include="..\..\GPU\Common\ShaderId.h" />
<ClInclude Include="..\..\GPU\Common\ShaderTranslation.h" />
<ClInclude Include="..\..\GPU\Common\ShaderUniforms.h" />
<ClInclude Include="..\..\GPU\Common\ShaderWriter.h" />
<ClInclude Include="..\..\GPU\Common\SoftwareLighting.h" />
<ClInclude Include="..\..\GPU\Common\SoftwareTransformCommon.h" />
<ClInclude Include="..\..\GPU\Common\SplineCommon.h" />
@@ -450,7 +449,6 @@
<ClCompile Include="..\..\GPU\Common\ShaderId.cpp" />
<ClCompile Include="..\..\GPU\Common\ShaderTranslation.cpp" />
<ClCompile Include="..\..\GPU\Common\ShaderUniforms.cpp" />
<ClCompile Include="..\..\GPU\Common\ShaderWriter.cpp" />
<ClCompile Include="..\..\GPU\Common\SoftwareTransformCommon.cpp" />
<ClCompile Include="..\..\GPU\Common\SplineCommon.cpp" />
<ClCompile Include="..\..\GPU\Common\StencilCommon.cpp" />
-2
View File
@@ -57,7 +57,6 @@
<ClCompile Include="..\..\GPU\Software\RasterizerRectangle.cpp" />
<ClCompile Include="..\..\GPU\Common\FragmentShaderGenerator.cpp" />
<ClCompile Include="..\..\GPU\Common\VertexShaderGenerator.cpp" />
<ClCompile Include="..\..\GPU\Common\ShaderWriter.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\GPU\Common\DepalettizeShaderCommon.h" />
@@ -115,6 +114,5 @@
<ClInclude Include="..\..\GPU\Software\RasterizerRectangle.h" />
<ClInclude Include="..\..\GPU\Common\FragmentShaderGenerator.h" />
<ClInclude Include="..\..\GPU\Common\VertexShaderGenerator.h" />
<ClInclude Include="..\..\GPU\Common\ShaderWriter.h" />
</ItemGroup>
</Project>
+2 -1
View File
@@ -252,6 +252,8 @@ EXEC_AND_LIB_FILES := \
$(SRC)/Common/File/DirListing.cpp \
$(SRC)/Common/File/FileDescriptor.cpp \
$(SRC)/Common/GPU/thin3d.cpp \
$(SRC)/Common/GPU/Shader.cpp \
$(SRC)/Common/GPU/ShaderWriter.cpp \
$(SRC)/Common/Render/DrawBuffer.cpp \
$(SRC)/Common/Render/TextureAtlas.cpp \
$(SRC)/Common/Render/Text/draw_text.cpp \
@@ -318,7 +320,6 @@ EXEC_AND_LIB_FILES := \
$(SRC)/GPU/Common/TextureCacheCommon.cpp.arm \
$(SRC)/GPU/Common/TextureScalerCommon.cpp.arm \
$(SRC)/GPU/Common/ShaderCommon.cpp \
$(SRC)/GPU/Common/ShaderWriter.cpp \
$(SRC)/GPU/Common/ShaderTranslation.cpp \
$(SRC)/GPU/Common/StencilCommon.cpp \
$(SRC)/GPU/Common/SplineCommon.cpp.arm \
+2 -1
View File
@@ -166,6 +166,8 @@ SOURCES_CXX += \
$(COMMONDIR)/File/FileDescriptor.cpp \
$(COMMONDIR)/File/DirListing.cpp \
$(COMMONDIR)/GPU/thin3d.cpp \
$(COMMONDIR)/GPU/Shader.cpp \
$(COMMONDIR)/GPU/ShaderWriter.cpp \
$(COMMONDIR)/GPU/OpenGL/thin3d_gl.cpp \
$(COMMONDIR)/GPU/OpenGL/GLDebugLog.cpp \
$(COMMONDIR)/GPU/OpenGL/GLSLProgram.cpp \
@@ -236,7 +238,6 @@ SOURCES_CXX += \
$(GPUCOMMONDIR)/ShaderCommon.cpp \
$(GPUCOMMONDIR)/ShaderUniforms.cpp \
$(GPUCOMMONDIR)/ShaderTranslation.cpp \
$(GPUCOMMONDIR)/ShaderWriter.cpp \
$(GPUCOMMONDIR)/GPUDebugInterface.cpp \
$(GPUCOMMONDIR)/DepalettizeShaderCommon.cpp \
$(GPUCOMMONDIR)/TransformCommon.cpp \
+12 -12
View File
@@ -26,14 +26,14 @@ bool GenerateFShader(FShaderID id, char *buffer, ShaderLanguage lang, std::strin
ShaderLanguageDesc compat(ShaderLanguage::GLSL_VULKAN);
return GenerateFragmentShader(id, buffer, compat, &uniformMask, errorString);
}
case ShaderLanguage::GLSL_140:
case ShaderLanguage::GLSL_1xx:
{
ShaderLanguageDesc compat(ShaderLanguage::GLSL_140);
ShaderLanguageDesc compat(ShaderLanguage::GLSL_1xx);
return GenerateFragmentShader(id, buffer, compat, &uniformMask, errorString);
}
case ShaderLanguage::GLSL_300:
case ShaderLanguage::GLSL_3xx:
{
ShaderLanguageDesc compat(ShaderLanguage::GLSL_140);
ShaderLanguageDesc compat(ShaderLanguage::GLSL_1xx);
return GenerateFragmentShader(id, buffer, compat, &uniformMask, errorString);
}
case ShaderLanguage::HLSL_D3D9:
@@ -60,14 +60,14 @@ bool GenerateVShader(VShaderID id, char *buffer, ShaderLanguage lang, std::strin
ShaderLanguageDesc compat(ShaderLanguage::GLSL_VULKAN);
return GenerateVertexShader(id, buffer, compat, &attrMask, &uniformMask, errorString);
}
case ShaderLanguage::GLSL_140:
case ShaderLanguage::GLSL_1xx:
{
ShaderLanguageDesc compat(ShaderLanguage::GLSL_140);
ShaderLanguageDesc compat(ShaderLanguage::GLSL_1xx);
return GenerateVertexShader(id, buffer, compat, &attrMask, &uniformMask, errorString);
}
case ShaderLanguage::GLSL_300:
case ShaderLanguage::GLSL_3xx:
{
ShaderLanguageDesc compat(ShaderLanguage::GLSL_140);
ShaderLanguageDesc compat(ShaderLanguage::GLSL_1xx);
return GenerateVertexShader(id, buffer, compat, &attrMask, &uniformMask, errorString);
}
case ShaderLanguage::HLSL_D3D9:
@@ -106,9 +106,9 @@ bool TestCompileShader(const char *buffer, ShaderLanguage lang, bool vertex, std
case ShaderLanguage::GLSL_VULKAN:
return GLSLtoSPV(vertex ? VK_SHADER_STAGE_VERTEX_BIT : VK_SHADER_STAGE_FRAGMENT_BIT, buffer, GLSLVariant::VULKAN, spirv, errorMessage);
case ShaderLanguage::GLSL_140:
case ShaderLanguage::GLSL_1xx:
return GLSLtoSPV(vertex ? VK_SHADER_STAGE_VERTEX_BIT : VK_SHADER_STAGE_FRAGMENT_BIT, buffer, GLSLVariant::GL140, spirv, errorMessage);
case ShaderLanguage::GLSL_300:
case ShaderLanguage::GLSL_3xx:
return GLSLtoSPV(vertex ? VK_SHADER_STAGE_VERTEX_BIT : VK_SHADER_STAGE_FRAGMENT_BIT, buffer, GLSLVariant::GLES300, spirv, errorMessage);
default:
return false;
@@ -151,8 +151,8 @@ bool TestShaderGenerators() {
ShaderLanguage::HLSL_D3D9,
ShaderLanguage::HLSL_D3D11,
ShaderLanguage::GLSL_VULKAN,
ShaderLanguage::GLSL_140,
ShaderLanguage::GLSL_300,
ShaderLanguage::GLSL_1xx,
ShaderLanguage::GLSL_3xx,
};
const int numLanguages = ARRAY_SIZE(languages);