mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Vulkan: Attempt at fixing dual source blending. Should work but doesn't.
This commit is contained in:
parent
432fbe30d1
commit
76d8a87b2f
5 changed files with 30 additions and 22 deletions
|
@ -41,6 +41,11 @@
|
|||
#include "GPU/ge_constants.h"
|
||||
#include "GPU/GPUState.h"
|
||||
|
||||
static const char *vulkan_glsl_preamble =
|
||||
"#version 400\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n"
|
||||
"#extension GL_ARB_shading_language_420pack : enable\n\n";
|
||||
|
||||
#define WRITE p+=sprintf
|
||||
|
||||
// Missing: Z depth range
|
||||
|
@ -49,9 +54,7 @@ bool GenerateVulkanGLSLFragmentShader(const ShaderID &id, char *buffer) {
|
|||
|
||||
const char *lastFragData = nullptr;
|
||||
|
||||
WRITE(p, "#version 140\n"); // GLSL ES
|
||||
WRITE(p, "#extension GL_ARB_separate_shader_objects : enable\n");
|
||||
WRITE(p, "#extension GL_ARB_shading_language_420pack : enable\n");
|
||||
WRITE(p, "%s", vulkan_glsl_preamble);
|
||||
|
||||
bool lmode = id.Bit(FS_BIT_LMODE);
|
||||
bool doTexture = id.Bit(FS_BIT_DO_TEXTURE);
|
||||
|
@ -116,9 +119,9 @@ bool GenerateVulkanGLSLFragmentShader(const ShaderID &id, char *buffer) {
|
|||
WRITE(p, "ivec3 roundAndScaleTo255iv(in vec3 x) { return ivec3(floor(x * 255.0 + 0.5)); }\n");
|
||||
}
|
||||
|
||||
WRITE(p, "layout (location = 0) out vec4 fragColor0;\n");
|
||||
WRITE(p, "layout (location = 0, index = 0) out vec4 fragColor0;\n");
|
||||
if (stencilToAlpha == REPLACE_ALPHA_DUALSOURCE) {
|
||||
WRITE(p, "layout (location = 1) out vec4 fragColor1;\n");
|
||||
WRITE(p, "layout (location = 0, index = 1) out vec4 fragColor1;\n");
|
||||
}
|
||||
|
||||
// PowerVR needs a custom modulo function. For some reason, this has far higher precision than the builtin one.
|
||||
|
|
|
@ -89,12 +89,13 @@ int SetupVertexAttribs(VkVertexInputAttributeDescription attrs[], const DecVtxFo
|
|||
return count;
|
||||
}
|
||||
|
||||
int SetupVertexAttribsPretransformed(VkVertexInputAttributeDescription attrs[]) {
|
||||
VertexAttribSetup(&attrs[0], DEC_FLOAT_4, 0, PspAttributeLocation::POSITION);
|
||||
VertexAttribSetup(&attrs[1], DEC_FLOAT_3, 16, PspAttributeLocation::TEXCOORD);
|
||||
VertexAttribSetup(&attrs[2], DEC_U8_4, 28, PspAttributeLocation::COLOR0);
|
||||
VertexAttribSetup(&attrs[3], DEC_U8_4, 32, PspAttributeLocation::COLOR1);
|
||||
return 4;
|
||||
int SetupVertexAttribsPretransformed(VkVertexInputAttributeDescription attrs[], const DecVtxFormat &decFmt) {
|
||||
int count = 0;
|
||||
VertexAttribSetup(&attrs[count++], DEC_FLOAT_4, 0, PspAttributeLocation::POSITION);
|
||||
VertexAttribSetup(&attrs[count++], DEC_FLOAT_3, 16, PspAttributeLocation::TEXCOORD);
|
||||
VertexAttribSetup(&attrs[count++], DEC_U8_4, 28, PspAttributeLocation::COLOR0);
|
||||
VertexAttribSetup(&attrs[count++], DEC_U8_4, 32, PspAttributeLocation::COLOR1);
|
||||
return count;
|
||||
}
|
||||
|
||||
static VulkanPipeline *CreateVulkanPipeline(VkDevice device, VkPipelineCache pipelineCache, VkPipelineLayout layout, VkRenderPass renderPass, const VulkanPipelineRasterStateKey &key, const VertexDecoder *vtxDec, VulkanVertexShader *vs, VulkanFragmentShader *fs, bool useHwTransform) {
|
||||
|
@ -212,7 +213,7 @@ static VulkanPipeline *CreateVulkanPipeline(VkDevice device, VkPipelineCache pip
|
|||
attributeCount = SetupVertexAttribs(attrs, vtxDec->decFmt);
|
||||
vertexStride = vtxDec->decFmt.stride;
|
||||
} else {
|
||||
attributeCount = SetupVertexAttribsPretransformed(attrs);
|
||||
attributeCount = SetupVertexAttribsPretransformed(attrs, vtxDec->decFmt);
|
||||
vertexStride = 36;
|
||||
}
|
||||
|
||||
|
|
|
@ -1266,6 +1266,8 @@ void TextureCacheVulkan::SetTexture() {
|
|||
gstate_c.textureFullAlpha = entry->GetAlphaStatus() == TexCacheEntry::STATUS_ALPHA_FULL;
|
||||
gstate_c.textureSimpleAlpha = entry->GetAlphaStatus() != TexCacheEntry::STATUS_ALPHA_UNKNOWN;
|
||||
}
|
||||
gstate_c.curTextureWidth = w;
|
||||
gstate_c.curTextureHeight = h;
|
||||
nextTexture_ = entry;
|
||||
VERBOSE_LOG(G3D, "Texture at %08x Found in Cache, applying", texaddr);
|
||||
return; //Done!
|
||||
|
|
|
@ -35,6 +35,11 @@
|
|||
#include "GPU/Vulkan/PipelineManagerVulkan.h"
|
||||
#include "GPU/Vulkan/ShaderManagerVulkan.h"
|
||||
|
||||
static const char *vulkan_glsl_preamble =
|
||||
"#version 400\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n"
|
||||
"#extension GL_ARB_shading_language_420pack : enable\n\n";
|
||||
|
||||
// "Varying" layout - must match fragment shader
|
||||
// color0 = 0
|
||||
// color1 = 1
|
||||
|
@ -102,9 +107,7 @@ bool GenerateVulkanGLSLVertexShader(const ShaderID &id, char *buffer) {
|
|||
|
||||
// #define USE_FOR_LOOP
|
||||
|
||||
WRITE(p, "#version 140\n"); // GLSL ES
|
||||
WRITE(p, "#extension GL_ARB_separate_shader_objects : enable\n");
|
||||
WRITE(p, "#extension GL_ARB_shading_language_420pack : enable\n");
|
||||
WRITE(p, "%s", vulkan_glsl_preamble);
|
||||
|
||||
bool highpFog = false;
|
||||
bool highpTexcoord = false;
|
||||
|
@ -184,7 +187,7 @@ bool GenerateVulkanGLSLVertexShader(const ShaderID &id, char *buffer) {
|
|||
if (hasColor) {
|
||||
WRITE(p, "layout (location = %d) in vec4 color0;\n", PspAttributeLocation::COLOR0);
|
||||
if (lmode && !useHWTransform) // only software transform supplies color1 as vertex data
|
||||
WRITE(p, "layout (location = %d) in vec3 color1;\n", PspAttributeLocation::COLOR0);
|
||||
WRITE(p, "layout (location = %d) in vec3 color1;\n", PspAttributeLocation::COLOR1);
|
||||
}
|
||||
|
||||
bool prescale = false;
|
||||
|
@ -302,9 +305,9 @@ bool GenerateVulkanGLSLVertexShader(const ShaderID &id, char *buffer) {
|
|||
|
||||
// TODO: Declare variables for dots for shade mapping if needed.
|
||||
|
||||
const char *ambientStr = (matUpdate & 1) && hasColor ? "color0" : "base.matambientalpha";
|
||||
const char *diffuseStr = (matUpdate & 2) && hasColor ? "color0.rgb" : "light.matdiffuse";
|
||||
const char *specularStr = (matUpdate & 4) && hasColor ? "color0.rgb" : "light.matspecular.rgb";
|
||||
const char *ambientStr = ((matUpdate & 1) && hasColor) ? "color0" : "base.matambientalpha";
|
||||
const char *diffuseStr = ((matUpdate & 2) && hasColor) ? "color0.rgb" : "light.matdiffuse";
|
||||
const char *specularStr = ((matUpdate & 4) && hasColor) ? "color0.rgb" : "light.matspecular.rgb";
|
||||
|
||||
bool diffuseIsZero = true;
|
||||
bool specularIsZero = true;
|
||||
|
|
|
@ -114,11 +114,10 @@ static VkBool32 VKAPI_CALL Vulkan_Dbg(VkDebugReportFlagsEXT msgFlags, VkDebugRep
|
|||
} else if (msgFlags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
|
||||
message << "DEBUG: ";
|
||||
}
|
||||
message << "[" << pLayerPrefix << "] " << ObjTypeToString(objType) << " Code " << msgCode << " : " << pMsg;
|
||||
message << "[" << pLayerPrefix << "] " << ObjTypeToString(objType) << " Code " << msgCode << " : " << pMsg << "\n";
|
||||
|
||||
#ifdef _WIN32
|
||||
OutputDebugStringA(message.str().c_str());
|
||||
OutputDebugStringA("\n");
|
||||
if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
|
||||
if (options->breakOnError) {
|
||||
DebugBreak();
|
||||
|
@ -132,7 +131,7 @@ static VkBool32 VKAPI_CALL Vulkan_Dbg(VkDebugReportFlagsEXT msgFlags, VkDebugRep
|
|||
}
|
||||
}
|
||||
#else
|
||||
std::cout << message << std::endl;
|
||||
std::cout << message;
|
||||
#endif
|
||||
|
||||
// false indicates that layer should not bail-out of an
|
||||
|
|
Loading…
Add table
Reference in a new issue