From 93e148fed6c3478388f2f648928c73b103b54947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 1 Nov 2017 23:35:06 +0100 Subject: [PATCH 1/2] Vulkan: Implement post-processing. The Vulkan backend is now "feature-complete", and GL is now legacy :P Bit hacky but works. --- GPU/Common/FramebufferCommon.h | 2 +- GPU/Common/ShaderTranslation.cpp | 87 ++++++++++++++++- GPU/Vulkan/FramebufferVulkan.cpp | 122 +++++++++++++++++++----- GPU/Vulkan/FramebufferVulkan.h | 13 ++- GPU/Vulkan/GPU_Vulkan.cpp | 2 +- GPU/Vulkan/VulkanUtil.cpp | 7 +- GPU/Vulkan/VulkanUtil.h | 2 +- ext/native/base/logging.h | 1 + ext/native/thin3d/VulkanQueueRunner.h | 2 +- ext/native/thin3d/VulkanRenderManager.h | 2 +- 10 files changed, 199 insertions(+), 41 deletions(-) diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index 75224a0cc5..0b1a4125aa 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -69,7 +69,7 @@ class VulkanFBO; struct PostShaderUniforms { float texelDelta[2]; float pixelDelta[2]; float time[4]; - bool video; + float video; }; struct VirtualFramebuffer { diff --git a/GPU/Common/ShaderTranslation.cpp b/GPU/Common/ShaderTranslation.cpp index 512f5201b0..399910f18c 100644 --- a/GPU/Common/ShaderTranslation.cpp +++ b/GPU/Common/ShaderTranslation.cpp @@ -83,7 +83,22 @@ cbuffer data : register(b0) { float2 u_texelDelta; float2 u_pixelDelta; float4 u_time; - bool u_video; + float u_video; +}; +)"; + +static const char *vulkanPrologue = +R"(#version 430 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable +)"; + +static const char *pushconstantBufferDecl = R"( +layout(push_constant) uniform data { + vec2 u_texelDelta; + vec2 u_pixelDelta; + vec4 u_time; + float u_video; }; )"; @@ -112,10 +127,74 @@ std::string Postprocess(std::string code, ShaderLanguage lang, Draw::ShaderStage return output; } +bool ConvertToVulkanGLSL(std::string *dest, TranslatedShaderMetadata *destMetadata, std::string src, Draw::ShaderStage stage, std::string *errorMessage) { + std::stringstream out; + + static struct { + Draw::ShaderStage stage; + const char *needle; + const char *replacement; + } replacements[] = { + { Draw::ShaderStage::VERTEX, "attribute vec4 a_position;", "layout(location = 0) in vec4 a_position;" }, + { Draw::ShaderStage::VERTEX, "attribute vec2 a_texcoord0;", "layout(location = 1) in vec2 a_texcoord0;"}, + { Draw::ShaderStage::VERTEX, "varying vec2 v_position;", "layout(location = 0) out vec2 v_position;" }, + { Draw::ShaderStage::FRAGMENT, "varying vec2 v_position;", "layout(location = 0) in vec2 v_position;" }, + { Draw::ShaderStage::FRAGMENT, "texture2D(", "texture(" }, + { Draw::ShaderStage::FRAGMENT, "gl_FragColor", "fragColor0" }, + }; + + out << vulkanPrologue; + if (stage == Draw::ShaderStage::FRAGMENT) { + out << "layout (location = 0) out vec4 fragColor0;\n"; + } + // Output the uniform buffer. + out << pushconstantBufferDecl; + + // Alright, now let's go through it line by line and zap the single uniforms + // and perform replacements. + std::string line; + std::stringstream instream(src); + while (std::getline(instream, line)) { + char buffer[256]; + int vecSize, num; + if (line.find("uniform bool") != std::string::npos) { + continue; + } else if (line.find("uniform sampler2D") == 0) { + line = "layout(set = 0, binding = 0) " + line; + } else if (line.find("uniform ") != std::string::npos) { + continue; + } else if (2 == sscanf(line.c_str(), "varying vec%d v_texcoord%d;", &vecSize, &num)) { + if (stage == Draw::ShaderStage::FRAGMENT) { + line = StringFromFormat("layout(location = %d) in vec%d v_texcoord%d;", num, vecSize, num); + } else { + line = StringFromFormat("layout(location = %d) out vec%d v_texcoord%d;", num, vecSize, num); + } + } + for (int i = 0; i < ARRAY_SIZE(replacements); i++) { + if (replacements[i].stage == stage) + line = ReplaceAll(line, replacements[i].needle, replacements[i].replacement); + } + out << line << "\n"; + } + + // DUMPLOG(src.c_str()); + // ILOG("---->"); + // DUMPLOG(LineNumberString(out.str()).c_str()); + + *dest = out.str(); + return true; +} + 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) return false; + if (srcLang == GLSL_140 || srcLang == GLSL_300 && 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; + } + #if PPSSPP_PLATFORM(UWP) return false; #endif @@ -126,8 +205,8 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShade TBuiltInResource Resources; init_resources(Resources); - // Enable SPIR-V and Vulkan rules when parsing GLSL - EShMessages messages = EShMessages::EShMsgDefault; // (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules); + // Don't enable SPIR-V and Vulkan rules when parsing GLSL. Our postshaders are written in oldschool GLES 2.0. + EShMessages messages = EShMessages::EShMsgDefault; EShLanguage shaderStage = GetLanguage(stage); glslang::TShader shader(shaderStage); @@ -166,8 +245,6 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShade // Alright, step 1 done. Now let's take this SPIR-V shader and output in our desired format. switch (destLang) { - case GLSL_VULKAN: - return false; // TODO #ifdef _WIN32 case HLSL_DX9: { diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index 9cb3019553..4f2653f75d 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -23,6 +23,8 @@ #include "base/timeutil.h" #include "math/lin/matrix4x4.h" #include "math/dataconv.h" +#include "i18n/i18n.h" +#include "ext/native/file/vfs.h" #include "ext/native/thin3d/thin3d.h" #include "Common/Vulkan/VulkanContext.h" @@ -39,6 +41,7 @@ #include "GPU/ge_constants.h" #include "GPU/GPUState.h" +#include "GPU/Common/ShaderTranslation.h" #include "GPU/Common/PostShader.h" #include "GPU/Common/TextureDecoder.h" #include "GPU/Common/FramebufferCommon.h" @@ -155,6 +158,12 @@ void FramebufferManagerVulkan::DestroyDeviceObjects() { vulkan_->Delete().QueueDeleteSampler(linearSampler_); if (nearestSampler_ != VK_NULL_HANDLE) vulkan_->Delete().QueueDeleteSampler(nearestSampler_); + + if (postVs_) + vulkan_->Delete().QueueDeleteShaderModule(postVs_); + if (postFs_) + vulkan_->Delete().QueueDeleteShaderModule(postFs_); + pipelinePostShader_ = VK_NULL_HANDLE; // actual pipeline should get destroyed by vulkan2d. } void FramebufferManagerVulkan::NotifyClear(bool clearColor, bool clearAlpha, bool clearDepth, uint32_t color, float depth) { @@ -180,28 +189,6 @@ void FramebufferManagerVulkan::NotifyClear(bool clearColor, bool clearAlpha, boo } } -void FramebufferManagerVulkan::UpdatePostShaderUniforms(int bufferWidth, int bufferHeight, int renderWidth, int renderHeight) { - float u_delta = 1.0f / renderWidth; - float v_delta = 1.0f / renderHeight; - float u_pixel_delta = u_delta; - float v_pixel_delta = v_delta; - if (postShaderAtOutputResolution_) { - float x, y, w, h; - CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, ROTATION_LOCKED_HORIZONTAL); - u_pixel_delta = (1.0f / w) * (480.0f / bufferWidth); - v_pixel_delta = (1.0f / h) * (272.0f / bufferHeight); - } - - postUniforms_.texelDelta[0] = u_delta; - postUniforms_.texelDelta[1] = v_delta; - postUniforms_.pixelDelta[0] = u_pixel_delta; - postUniforms_.pixelDelta[1] = v_pixel_delta; - int flipCount = __DisplayGetFlipCount(); - int vCount = __DisplayGetVCount(); - float time[4] = { time_now(), (vCount % 60) * 1.0f / 60.0f, (float)vCount, (float)(flipCount % 60) }; - memcpy(postUniforms_.time, time, 4 * sizeof(float)); -} - void FramebufferManagerVulkan::Init() { FramebufferManagerCommon::Init(); // Workaround for upscaling shaders where we force x1 resolution without saving it @@ -349,6 +336,9 @@ void FramebufferManagerVulkan::DrawActiveTexture(float x, float y, float w, floa VkBuffer vbuffer; VkDeviceSize offset = push_->Push(vtx, sizeof(vtx), &vbuffer); renderManager->BindPipeline(cur2DPipeline_); + if (cur2DPipeline_ == pipelinePostShader_) { + renderManager->PushConstants(vulkan2D_->GetPipelineLayout(), VK_SHADER_STAGE_FRAGMENT_BIT | VK_SHADER_STAGE_VERTEX_BIT, 0, (int)sizeof(postShaderUniforms_), &postShaderUniforms_); + } renderManager->Draw(vulkan2D_->GetPipelineLayout(), descSet, 0, nullptr, vbuffer, offset, 4); } @@ -358,7 +348,23 @@ void FramebufferManagerVulkan::Bind2DShader() { } void FramebufferManagerVulkan::BindPostShader(const PostShaderUniforms &uniforms) { - Bind2DShader(); + if (!pipelinePostShader_) { + if (usePostShader_) { + CompilePostShader(); + } + if (!usePostShader_) { + SetNumExtraFBOs(0); + Bind2DShader(); + return; + } else { + SetNumExtraFBOs(1); + } + } + + postShaderUniforms_ = uniforms; + // VulkanRenderManager *renderManager = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); + cur2DPipeline_ = pipelinePostShader_; + gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE); } @@ -626,4 +632,74 @@ void FramebufferManagerVulkan::Resized() { if (UpdateSize()) { DestroyAllFBOs(); } + + // Might have a new post shader - let's compile it. + CompilePostShader(); } + +void FramebufferManagerVulkan::CompilePostShader() { + if (postVs_) { + vulkan_->Delete().QueueDeleteShaderModule(postVs_); + postVs_ = nullptr; + } + if (postFs_) { + vulkan_->Delete().QueueDeleteShaderModule(postFs_); + postFs_ = nullptr; + } + + const ShaderInfo *shaderInfo = nullptr; + if (g_Config.sPostShaderName == "Off") { + usePostShader_ = false; + return; + } + + usePostShader_ = false; + + ReloadAllPostShaderInfo(); + shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName); + std::string errorVSX, errorFSX; + std::string vsSource; + std::string fsSource; + if (shaderInfo) { + postShaderAtOutputResolution_ = shaderInfo->outputResolution; + size_t sz; + char *vs = (char *)VFSReadFile(shaderInfo->vertexShaderFile.c_str(), &sz); + if (!vs) + return; + char *fs = (char *)VFSReadFile(shaderInfo->fragmentShaderFile.c_str(), &sz); + if (!fs) { + free(vs); + return; + } + std::string vsSourceGLSL = vs; + std::string fsSourceGLSL = fs; + free(vs); + free(fs); + TranslatedShaderMetadata metaVS, metaFS; + if (!TranslateShader(&vsSource, GLSL_VULKAN, &metaVS, vsSourceGLSL, GLSL_140, Draw::ShaderStage::VERTEX, &errorVSX)) + return; + if (!TranslateShader(&fsSource, GLSL_VULKAN, &metaFS, fsSourceGLSL, GLSL_140, Draw::ShaderStage::FRAGMENT, &errorFSX)) + return; + } else { + return; + } + I18NCategory *gr = GetI18NCategory("Graphics"); + + // TODO: Delete the old pipeline? + + std::string errorVS; + std::string errorFS; + postVs_ = CompileShaderModule(vulkan_, VK_SHADER_STAGE_VERTEX_BIT, vsSource.c_str(), &errorVS); + postFs_ = CompileShaderModule(vulkan_, VK_SHADER_STAGE_FRAGMENT_BIT, fsSource.c_str(), &errorFS); + + VkRenderPass backbufferRP = (VkRenderPass)draw_->GetNativeObject(Draw::NativeObject::BACKBUFFER_RENDERPASS); + + if (postVs_ && postFs_) { + pipelinePostShader_ = vulkan2D_->GetPipeline(backbufferRP, postVs_, postFs_, true, Vulkan2D::VK2DDepthStencilMode::NONE); + } else { + ELOG("Failed to compile."); + } + + + usePostShader_ = true; +} \ No newline at end of file diff --git a/GPU/Vulkan/FramebufferVulkan.h b/GPU/Vulkan/FramebufferVulkan.h index 98ac4d9e25..49538dfa99 100644 --- a/GPU/Vulkan/FramebufferVulkan.h +++ b/GPU/Vulkan/FramebufferVulkan.h @@ -86,6 +86,7 @@ public: void NotifyClear(bool clearColor, bool clearAlpha, bool clearDepth, uint32_t color, float depth); protected: + void CompilePostShader(); void Bind2DShader() override; void BindPostShader(const PostShaderUniforms &uniforms) override; void SetViewport2D(int x, int y, int w, int h) override; @@ -100,8 +101,6 @@ private: // The returned texture does not need to be free'd, might be returned from a pool (currently single entry) void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height, float &u1, float &v1) override; - void UpdatePostShaderUniforms(int bufferWidth, int bufferHeight, int renderWidth, int renderHeight); - void InitDeviceObjects(); void DestroyDeviceObjects(); @@ -130,16 +129,20 @@ private: VkPipelineCache pipelineCache2D_; // Basic shaders - VkShaderModule fsBasicTex_; - VkShaderModule vsBasicTex_; + VkShaderModule fsBasicTex_ = VK_NULL_HANDLE; + VkShaderModule vsBasicTex_ = VK_NULL_HANDLE; VkShaderModule stencilVs_ = VK_NULL_HANDLE; VkShaderModule stencilFs_ = VK_NULL_HANDLE; + VkPipeline cur2DPipeline_ = VK_NULL_HANDLE; // Postprocessing - VkPipeline pipelinePostShader_; + VkShaderModule postVs_ = VK_NULL_HANDLE; + VkShaderModule postFs_ = VK_NULL_HANDLE; + VkPipeline pipelinePostShader_ = VK_NULL_HANDLE; + PostShaderUniforms postShaderUniforms_; VkSampler linearSampler_; VkSampler nearestSampler_; diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 8eeb0d33fb..b09f060cf6 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -95,11 +95,11 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw) drawEngine_.SetFramebufferManager(framebufferManagerVulkan_); drawEngine_.SetShaderManager(shaderManagerVulkan_); drawEngine_.SetPipelineManager(pipelineManager_); + framebufferManagerVulkan_->SetVulkan2D(&vulkan2D_); framebufferManagerVulkan_->Init(); framebufferManagerVulkan_->SetTextureCache(textureCacheVulkan_); framebufferManagerVulkan_->SetDrawEngine(&drawEngine_); framebufferManagerVulkan_->SetShaderManager(shaderManagerVulkan_); - framebufferManagerVulkan_->SetVulkan2D(&vulkan2D_); textureCacheVulkan_->SetDepalShaderCache(&depalShaderCache_); textureCacheVulkan_->SetFramebufferManager(framebufferManagerVulkan_); textureCacheVulkan_->SetShaderManager(shaderManagerVulkan_); diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index 662f5196c1..fa41eb4bfc 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -63,12 +63,13 @@ void Vulkan2D::DestroyDeviceObjects() { void Vulkan2D::InitDeviceObjects() { pipelineCache_ = vulkan_->CreatePipelineCache(); - // All resources we need for PSP drawing. Usually only bindings 0 and 2-4 are populated. VkDescriptorSetLayoutBinding bindings[2] = {}; + // Texture. bindings[0].descriptorCount = 1; bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; bindings[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; bindings[0].binding = 0; + // In depal, this second texture is used for the palette. bindings[1].descriptorCount = 1; bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; bindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; @@ -98,8 +99,8 @@ void Vulkan2D::InitDeviceObjects() { VkPushConstantRange push = {}; push.offset = 0; - push.size = 16; - push.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; + push.size = 48; + push.stageFlags = VK_SHADER_STAGE_VERTEX_BIT|VK_SHADER_STAGE_FRAGMENT_BIT; VkPipelineLayoutCreateInfo pl = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; pl.pPushConstantRanges = &push; diff --git a/GPU/Vulkan/VulkanUtil.h b/GPU/Vulkan/VulkanUtil.h index 6a6f526236..32b0421e4b 100644 --- a/GPU/Vulkan/VulkanUtil.h +++ b/GPU/Vulkan/VulkanUtil.h @@ -104,7 +104,7 @@ private: VK2DDepthStencilMode depthStencilMode; bool readVertices; bool operator < (const PipelineKey &other) const { - return std::tie(vs, fs, rp, depthStencilMode, readVertices) < std::tie(other.vs, other.fs, other.rp, depthStencilMode, readVertices); + return std::tie(vs, fs, rp, depthStencilMode, readVertices) < std::tie(other.vs, other.fs, other.rp, other.depthStencilMode, other.readVertices); } }; diff --git a/ext/native/base/logging.h b/ext/native/base/logging.h index 3bbff36204..3425b9e942 100644 --- a/ext/native/base/logging.h +++ b/ext/native/base/logging.h @@ -88,6 +88,7 @@ const char *GetFn(const char *fn); OutputDebugStringUTF8(temp); \ } \ } while (false) +#define DUMPLOG(x) OutputDebugStringUTF8(x); #ifdef _DEBUG #define DLOG(...) XLOG_IMPL("D", __VA_ARGS__) diff --git a/ext/native/thin3d/VulkanQueueRunner.h b/ext/native/thin3d/VulkanQueueRunner.h index cbe5eec1cf..c49bb207ff 100644 --- a/ext/native/thin3d/VulkanQueueRunner.h +++ b/ext/native/thin3d/VulkanQueueRunner.h @@ -74,7 +74,7 @@ struct VkRenderData { VkShaderStageFlags stages; uint8_t offset; uint8_t size; - uint8_t data[32]; // Should be enough for now. + uint8_t data[40]; // Should be enough for now. } push; }; }; diff --git a/ext/native/thin3d/VulkanRenderManager.h b/ext/native/thin3d/VulkanRenderManager.h index 1c17b42ac4..818a44f41b 100644 --- a/ext/native/thin3d/VulkanRenderManager.h +++ b/ext/native/thin3d/VulkanRenderManager.h @@ -139,7 +139,7 @@ public: void PushConstants(VkPipelineLayout pipelineLayout, VkShaderStageFlags stages, int offset, int size, void *constants) { _dbg_assert_(G3D, curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); - assert(size + offset < 32); + assert(size + offset < 40); VkRenderData data{ VKRRenderCommand::PUSH_CONSTANTS }; data.push.pipelineLayout = pipelineLayout; data.push.stages = stages; From b8dc4d1fb8996ec88abdfc29323c24ceb7f637c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 12 Nov 2017 16:55:36 +0100 Subject: [PATCH 2/2] Buildfixes for Android --- CMakeLists.txt | 2 ++ GPU/Common/ShaderTranslation.cpp | 18 +++++++++++------- GPU/Common/ShaderTranslation.h | 4 ---- GPU/Vulkan/FramebufferVulkan.cpp | 2 -- android/jni/Android.mk | 1 + 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e8992b23f..8fac30bc8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1265,6 +1265,8 @@ set(GPU_SOURCES GPU/Common/ShaderUniforms.h GPU/Common/ShaderCommon.cpp GPU/Common/ShaderCommon.h + GPU/Common/ShaderTranslation.cpp + GPU/Common/ShaderTranslation.h GPU/Common/SplineCommon.cpp GPU/Common/SplineCommon.h GPU/Common/StencilCommon.cpp diff --git a/GPU/Common/ShaderTranslation.cpp b/GPU/Common/ShaderTranslation.cpp index 399910f18c..1a50efbaba 100644 --- a/GPU/Common/ShaderTranslation.cpp +++ b/GPU/Common/ShaderTranslation.cpp @@ -17,8 +17,6 @@ #include "ppsspp_config.h" -#if !defined(ANDROID) - #include #include #include @@ -34,6 +32,8 @@ #include "ShaderTranslation.h" #include "ext/glslang/SPIRV/GlslangToSpv.h" #include "thin3d/thin3d.h" + +#if !defined(ANDROID) #include "ext/SPIRV-Cross/spirv.hpp" #include "ext/SPIRV-Cross/spirv_common.hpp" #include "ext/SPIRV-Cross/spirv_cross.hpp" @@ -41,6 +41,7 @@ #ifdef _WIN32 #include "ext/SPIRV-Cross/spirv_hlsl.hpp" #endif +#endif extern void init_resources(TBuiltInResource &Resources); @@ -58,12 +59,12 @@ static EShLanguage GetLanguage(const Draw::ShaderStage stage) { void ShaderTranslationInit() { // TODO: We have TLS issues on UWP -#if !PPSSPP_PLATFORM(UWP) +#if !PPSSPP_PLATFORM(UWP) && !defined(ANDROID) glslang::InitializeProcess(); #endif } void ShaderTranslationShutdown() { -#if !PPSSPP_PLATFORM(UWP) +#if !PPSSPP_PLATFORM(UWP) && !defined(ANDROID) glslang::FinalizeProcess(); #endif } @@ -189,12 +190,16 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShade if (srcLang != GLSL_300 && srcLang != GLSL_140) return false; - if (srcLang == GLSL_140 || srcLang == GLSL_300 && destLang == GLSL_VULKAN) { + if ((srcLang == GLSL_140 || srcLang == GLSL_300) && 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; } +#if defined(ANDROID) + return false; +#else + #if PPSSPP_PLATFORM(UWP) return false; #endif @@ -304,6 +309,5 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShade default: return false; } -} - #endif +} diff --git a/GPU/Common/ShaderTranslation.h b/GPU/Common/ShaderTranslation.h index f382f4694a..5985623661 100644 --- a/GPU/Common/ShaderTranslation.h +++ b/GPU/Common/ShaderTranslation.h @@ -21,8 +21,6 @@ #include "GPU/Common/ShaderCommon.h" #include "thin3d/thin3d.h" -#ifndef ANDROID - struct TranslatedShaderMetadata { }; @@ -31,5 +29,3 @@ void ShaderTranslationInit(); void ShaderTranslationShutdown(); bool TranslateShader(std::string *dst, ShaderLanguage destLang, TranslatedShaderMetadata *destMetadata, std::string src, ShaderLanguage srcLang, Draw::ShaderStage stage, std::string *errorMessage); - -#endif \ No newline at end of file diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index 4f2653f75d..81fc286a22 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -640,11 +640,9 @@ void FramebufferManagerVulkan::Resized() { void FramebufferManagerVulkan::CompilePostShader() { if (postVs_) { vulkan_->Delete().QueueDeleteShaderModule(postVs_); - postVs_ = nullptr; } if (postFs_) { vulkan_->Delete().QueueDeleteShaderModule(postFs_); - postFs_ = nullptr; } const ShaderInfo *shaderInfo = nullptr; diff --git a/android/jni/Android.mk b/android/jni/Android.mk index f0f3c0ab12..252d8cffae 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -223,6 +223,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/GPU/Common/TextureCacheCommon.cpp.arm \ $(SRC)/GPU/Common/TextureScalerCommon.cpp.arm \ $(SRC)/GPU/Common/ShaderCommon.cpp \ + $(SRC)/GPU/Common/ShaderTranslation.cpp \ $(SRC)/GPU/Common/StencilCommon.cpp \ $(SRC)/GPU/Common/SplineCommon.cpp.arm \ $(SRC)/GPU/Common/DrawEngineCommon.cpp.arm \