mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-17 04:39:34 +00:00
Remove the 0th descriptor set, move everything else back to 0
This commit is contained in:
parent
5406c4f97a
commit
26884150d7
@ -98,7 +98,7 @@ R"(#version 450
|
||||
)";
|
||||
|
||||
static const char *vulkanUboDecl = R"(
|
||||
layout (std140, set = 1, binding = 0) uniform Data {
|
||||
layout (std140, set = 0, binding = 0) uniform Data {
|
||||
vec2 u_texelDelta;
|
||||
vec2 u_pixelDelta;
|
||||
vec4 u_time;
|
||||
@ -187,11 +187,11 @@ bool ConvertToVulkanGLSL(std::string *dest, TranslatedShaderMetadata *destMetada
|
||||
continue;
|
||||
} else if (line.find("uniform sampler2D") == 0) {
|
||||
if (sscanf(line.c_str(), "uniform sampler2D sampler%d", &num) == 1)
|
||||
line = StringFromFormat("layout(set = 1, binding = %d) ", num + 1) + line;
|
||||
line = StringFromFormat("layout(set = 0, binding = %d) ", num + 1) + line;
|
||||
else if (line.find("sampler0") != line.npos)
|
||||
line = "layout(set = 1, binding = 1) " + line;
|
||||
line = "layout(set = 0, binding = 1) " + line;
|
||||
else
|
||||
line = "layout(set = 1, binding = 2) " + line;
|
||||
line = "layout(set = 0, binding = 2) " + 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)) {
|
||||
|
@ -326,7 +326,7 @@ void ShaderWriter::BeginFSMain(Slice<UniformDef> uniforms, Slice<VaryingDef> var
|
||||
}
|
||||
C("layout(location = 0, index = 0) out vec4 fragColor0;\n");
|
||||
if (!uniforms.is_empty()) {
|
||||
C("layout(std140, set = 1, binding = 0) uniform bufferVals {\n");
|
||||
C("layout(std140, set = 0, binding = 0) uniform bufferVals {\n");
|
||||
for (auto &uniform : uniforms) {
|
||||
F("%s %s;\n", uniform.type, uniform.name);
|
||||
}
|
||||
@ -480,9 +480,9 @@ void ShaderWriter::DeclareTexture2D(const SamplerDef &def) {
|
||||
case GLSL_VULKAN:
|
||||
// texBindingBase_ is used for the thin3d descriptor set layout, where they start at 1.
|
||||
if (def.flags & SamplerFlags::ARRAY_ON_VULKAN) {
|
||||
F("layout(set = 1, binding = %d) uniform sampler2DArray %s;\n", def.binding + texBindingBase_, def.name);
|
||||
F("layout(set = 0, binding = %d) uniform sampler2DArray %s;\n", def.binding + texBindingBase_, def.name);
|
||||
} else {
|
||||
F("layout(set = 1, binding = %d) uniform sampler2D %s;\n", def.binding + texBindingBase_, def.name);
|
||||
F("layout(set = 0, binding = %d) uniform sampler2D %s;\n", def.binding + texBindingBase_, def.name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1008,9 +1008,6 @@ void VulkanQueueRunner::LogRenderPass(const VKRStep &pass, bool verbose) {
|
||||
case VKRRenderCommand::DEBUG_ANNOTATION:
|
||||
INFO_LOG(G3D, " DebugAnnotation(%s)", cmd.debugAnnotation.annotation);
|
||||
break;
|
||||
case VKRRenderCommand::BIND_DESCRIPTOR_SET:
|
||||
INFO_LOG(G3D, " BindDescSet(%d)", cmd.bindDescSet.setNumber);
|
||||
break;
|
||||
|
||||
case VKRRenderCommand::NUM_RENDER_COMMANDS:
|
||||
break;
|
||||
@ -1456,7 +1453,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c
|
||||
|
||||
case VKRRenderCommand::DRAW_INDEXED:
|
||||
if (pipelineOK) {
|
||||
vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 1, 1, &c.drawIndexed.ds, c.drawIndexed.numUboOffsets, c.drawIndexed.uboOffsets);
|
||||
vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &c.drawIndexed.ds, c.drawIndexed.numUboOffsets, c.drawIndexed.uboOffsets);
|
||||
vkCmdBindIndexBuffer(cmd, c.drawIndexed.ibuffer, c.drawIndexed.ioffset, (VkIndexType)c.drawIndexed.indexType);
|
||||
VkDeviceSize voffset = c.drawIndexed.voffset;
|
||||
vkCmdBindVertexBuffers(cmd, 0, 1, &c.drawIndexed.vbuffer, &voffset);
|
||||
@ -1466,7 +1463,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c
|
||||
|
||||
case VKRRenderCommand::DRAW:
|
||||
if (pipelineOK) {
|
||||
vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 1, 1, &c.draw.ds, c.draw.numUboOffsets, c.draw.uboOffsets);
|
||||
vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &c.draw.ds, c.draw.numUboOffsets, c.draw.uboOffsets);
|
||||
if (c.draw.vbuffer) {
|
||||
vkCmdBindVertexBuffers(cmd, 0, 1, &c.draw.vbuffer, &c.draw.voffset);
|
||||
}
|
||||
@ -1516,10 +1513,6 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c
|
||||
}
|
||||
break;
|
||||
|
||||
case VKRRenderCommand::BIND_DESCRIPTOR_SET:
|
||||
vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, c.bindDescSet.pipelineLayout, c.bindDescSet.setNumber, 1, &c.bindDescSet.set, 0, nullptr);
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(G3D, "Unimpl queue command");
|
||||
break;
|
||||
|
@ -40,7 +40,6 @@ enum class VKRRenderCommand : uint8_t {
|
||||
PUSH_CONSTANTS,
|
||||
SELF_DEPENDENCY_BARRIER,
|
||||
DEBUG_ANNOTATION,
|
||||
BIND_DESCRIPTOR_SET,
|
||||
NUM_RENDER_COMMANDS,
|
||||
};
|
||||
|
||||
|
@ -238,16 +238,6 @@ public:
|
||||
compileMutex_.unlock();
|
||||
}
|
||||
|
||||
// Mainly used to bind the frame-global desc set.
|
||||
// Can be done before binding a pipeline, so not asserting on that.
|
||||
void BindDescriptorSet(int setNumber, VkDescriptorSet set, VkPipelineLayout pipelineLayout) {
|
||||
VkRenderData data{ VKRRenderCommand::BIND_DESCRIPTOR_SET };
|
||||
data.bindDescSet.setNumber = setNumber;
|
||||
data.bindDescSet.set = set;
|
||||
data.bindDescSet.pipelineLayout = pipelineLayout;
|
||||
curRenderStep_->commands.push_back(data);
|
||||
}
|
||||
|
||||
void BindPipeline(VKRGraphicsPipeline *pipeline, PipelineFlags flags, VkPipelineLayout pipelineLayout) {
|
||||
_dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER);
|
||||
_dbg_assert_(pipeline != nullptr);
|
||||
|
@ -524,7 +524,6 @@ private:
|
||||
int curIBufferOffset_ = 0;
|
||||
|
||||
VkDescriptorSetLayout descriptorSetLayout_ = VK_NULL_HANDLE;
|
||||
VkDescriptorSetLayout frameDescSetLayout_ = VK_NULL_HANDLE;
|
||||
VkPipelineLayout pipelineLayout_ = VK_NULL_HANDLE;
|
||||
VkPipelineCache pipelineCache_ = VK_NULL_HANDLE;
|
||||
AutoRef<VKFramebuffer> curFramebuffer_;
|
||||
@ -995,23 +994,12 @@ VKContext::VKContext(VulkanContext *vulkan)
|
||||
VkResult res = vkCreateDescriptorSetLayout(device_, &dsl, nullptr, &descriptorSetLayout_);
|
||||
_assert_(VK_SUCCESS == res);
|
||||
|
||||
VkDescriptorSetLayoutBinding frameBindings[1]{};
|
||||
frameBindings[0].descriptorCount = 1;
|
||||
frameBindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
frameBindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
frameBindings[0].binding = 0;
|
||||
|
||||
dsl.bindingCount = ARRAY_SIZE(frameBindings);
|
||||
dsl.pBindings = frameBindings;
|
||||
res = vkCreateDescriptorSetLayout(device_, &dsl, nullptr, &frameDescSetLayout_);
|
||||
_dbg_assert_(VK_SUCCESS == res);
|
||||
|
||||
vulkan_->SetDebugName(descriptorSetLayout_, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, "thin3d_d_layout");
|
||||
|
||||
VkPipelineLayoutCreateInfo pl = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO };
|
||||
pl.pPushConstantRanges = nullptr;
|
||||
pl.pushConstantRangeCount = 0;
|
||||
VkDescriptorSetLayout setLayouts[2] = { frameDescSetLayout_, descriptorSetLayout_ };
|
||||
VkDescriptorSetLayout setLayouts[1] = { descriptorSetLayout_ };
|
||||
pl.setLayoutCount = ARRAY_SIZE(setLayouts);
|
||||
pl.pSetLayouts = setLayouts;
|
||||
res = vkCreatePipelineLayout(device_, &pl, nullptr, &pipelineLayout_);
|
||||
@ -1033,7 +1021,6 @@ VKContext::~VKContext() {
|
||||
delete frame_[i].pushBuffer;
|
||||
}
|
||||
vulkan_->Delete().QueueDeleteDescriptorSetLayout(descriptorSetLayout_);
|
||||
vulkan_->Delete().QueueDeleteDescriptorSetLayout(frameDescSetLayout_);
|
||||
vulkan_->Delete().QueueDeletePipelineLayout(pipelineLayout_);
|
||||
vulkan_->Delete().QueueDeletePipelineCache(pipelineCache_);
|
||||
}
|
||||
@ -1772,8 +1759,6 @@ uint64_t VKContext::GetNativeObject(NativeObject obj, void *srcObject) {
|
||||
return (uint64_t)curFramebuffer_->GetFB()->color.texAllLayersView;
|
||||
case NativeObject::BOUND_FRAMEBUFFER_COLOR_IMAGEVIEW_RT:
|
||||
return (uint64_t)curFramebuffer_->GetFB()->GetRTView();
|
||||
case NativeObject::FRAME_DATA_DESC_SET_LAYOUT:
|
||||
return (uint64_t)frameDescSetLayout_;
|
||||
case NativeObject::THIN3D_PIPELINE_LAYOUT:
|
||||
return (uint64_t)pipelineLayout_;
|
||||
|
||||
|
@ -161,7 +161,7 @@ static const std::vector<ShaderSource> fsTexCol = {
|
||||
"layout(location = 0) in vec4 oColor0;\n"
|
||||
"layout(location = 1) in vec2 oTexCoord0;\n"
|
||||
"layout(location = 0) out vec4 fragColor0;\n"
|
||||
"layout(set = 1, binding = 1) uniform sampler2D Sampler0;\n"
|
||||
"layout(set = 0, binding = 1) uniform sampler2D Sampler0;\n"
|
||||
"void main() { fragColor0 = texture(Sampler0, oTexCoord0) * oColor0; }\n"
|
||||
}
|
||||
};
|
||||
@ -205,7 +205,7 @@ static const std::vector<ShaderSource> fsTexColRBSwizzle = {
|
||||
"layout(location = 0) in vec4 oColor0;\n"
|
||||
"layout(location = 1) in vec2 oTexCoord0;\n"
|
||||
"layout(location = 0) out vec4 fragColor0\n;"
|
||||
"layout(set = 1, binding = 1) uniform sampler2D Sampler0;\n"
|
||||
"layout(set = 0, binding = 1) uniform sampler2D Sampler0;\n"
|
||||
"void main() { fragColor0 = texture(Sampler0, oTexCoord0).bgra * oColor0; }\n"
|
||||
}
|
||||
};
|
||||
@ -294,7 +294,7 @@ static const std::vector<ShaderSource> vsCol = {
|
||||
R"(#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
layout (std140, set = 1, binding = 0) uniform bufferVals {
|
||||
layout (std140, set = 0, binding = 0) uniform bufferVals {
|
||||
mat4 WorldViewProj;
|
||||
vec2 TintSaturation;
|
||||
} myBufferVals;
|
||||
@ -440,7 +440,7 @@ VS_OUTPUT main(VS_INPUT input) {
|
||||
R"(#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
layout (std140, set = 1, binding = 0) uniform bufferVals {
|
||||
layout (std140, set = 0, binding = 0) uniform bufferVals {
|
||||
mat4 WorldViewProj;
|
||||
vec2 TintSaturation;
|
||||
} myBufferVals;
|
||||
|
@ -251,7 +251,6 @@ enum class NativeObject {
|
||||
TEXTURE_VIEW,
|
||||
NULL_IMAGEVIEW,
|
||||
NULL_IMAGEVIEW_ARRAY,
|
||||
FRAME_DATA_DESC_SET_LAYOUT,
|
||||
THIN3D_PIPELINE_LAYOUT,
|
||||
};
|
||||
|
||||
|
@ -191,21 +191,21 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
||||
WRITE(p, "layout (depth_unchanged) out float gl_FragDepth;\n");
|
||||
}
|
||||
|
||||
WRITE(p, "layout (std140, set = 1, binding = %d) uniform baseUBO {\n%s};\n", DRAW_BINDING_DYNUBO_BASE, ub_baseStr);
|
||||
WRITE(p, "layout (std140, set = 0, binding = %d) uniform baseUBO {\n%s};\n", DRAW_BINDING_DYNUBO_BASE, ub_baseStr);
|
||||
if (doTexture) {
|
||||
WRITE(p, "layout (set = 1, binding = %d) uniform %s%s tex;\n", DRAW_BINDING_TEXTURE, texture3D ? "sampler3D" : "sampler2D", arrayTexture ? "Array" : "");
|
||||
WRITE(p, "layout (set = 0, binding = %d) uniform %s%s tex;\n", DRAW_BINDING_TEXTURE, texture3D ? "sampler3D" : "sampler2D", arrayTexture ? "Array" : "");
|
||||
}
|
||||
|
||||
if (readFramebufferTex) {
|
||||
// The framebuffer texture is always bound as an array.
|
||||
p.F("layout (set = 1, binding = %d) uniform sampler2DArray fbotex;\n", DRAW_BINDING_2ND_TEXTURE);
|
||||
p.F("layout (set = 0, binding = %d) uniform sampler2DArray fbotex;\n", DRAW_BINDING_2ND_TEXTURE);
|
||||
} else if (fetchFramebuffer) {
|
||||
p.F("layout (input_attachment_index = 0, set = 1, binding = %d) uniform subpassInput inputColor;\n", DRAW_BINDING_INPUT_ATTACHMENT);
|
||||
p.F("layout (input_attachment_index = 0, set = 0, binding = %d) uniform subpassInput inputColor;\n", DRAW_BINDING_INPUT_ATTACHMENT);
|
||||
*fragmentShaderFlags |= FragmentShaderFlags::INPUT_ATTACHMENT;
|
||||
}
|
||||
|
||||
if (shaderDepalMode != ShaderDepalMode::OFF) {
|
||||
WRITE(p, "layout (set = 1, binding = %d) uniform sampler2D pal;\n", DRAW_BINDING_DEPAL_TEXTURE);
|
||||
WRITE(p, "layout (set = 0, binding = %d) uniform sampler2D pal;\n", DRAW_BINDING_DEPAL_TEXTURE);
|
||||
}
|
||||
|
||||
// Note: the precision qualifiers must match the vertex shader!
|
||||
|
@ -61,7 +61,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu
|
||||
|
||||
if (compat.shaderLanguage == GLSL_VULKAN) {
|
||||
WRITE(p, "\n");
|
||||
WRITE(p, "layout (std140, set = 1, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr);
|
||||
WRITE(p, "layout (std140, set = 0, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr);
|
||||
} else if (compat.shaderLanguage == HLSL_D3D11) {
|
||||
WRITE(p, "cbuffer base : register(b0) {\n%s};\n", ub_baseStr);
|
||||
}
|
||||
|
@ -72,10 +72,6 @@ void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bo
|
||||
maxValues[3] = NAN;
|
||||
}
|
||||
|
||||
void FrameUpdateUniforms(UB_Frame *ub, bool useBufferedRendering) {
|
||||
ub->rotation = useBufferedRendering ? 0 : (float)g_display_rotation;
|
||||
}
|
||||
|
||||
void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipViewport, bool useBufferedRendering) {
|
||||
if (dirtyUniforms & DIRTY_TEXENV) {
|
||||
Uint8x3ToFloat3(ub->texEnvColor, gstate.texenvcolor);
|
||||
@ -143,6 +139,8 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
|
||||
flippedMatrix = flippedMatrix * g_display_rot_matrix;
|
||||
}
|
||||
CopyMatrix4x4(ub->proj, flippedMatrix.getReadPtr());
|
||||
|
||||
ub->rotation = useBufferedRendering ? 0 : (float)g_display_rotation;
|
||||
}
|
||||
|
||||
if (dirtyUniforms & DIRTY_PROJTHROUGHMATRIX) {
|
||||
@ -194,7 +192,7 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
|
||||
}
|
||||
|
||||
if (dirtyUniforms & DIRTY_STENCILREPLACEVALUE) {
|
||||
ub->stencil = (float)gstate.getStencilTestRef() / 255.0;
|
||||
ub->stencil = (float)gstate.getStencilTestRef() * (1.0 / 255.0);
|
||||
}
|
||||
|
||||
// Note - this one is not in lighting but in transformCommon as it has uses beyond lighting
|
||||
|
@ -36,7 +36,7 @@ struct alignas(16) UB_VS_FS_Base {
|
||||
float fogColor[3]; uint32_t alphaColorRef;
|
||||
float texEnvColor[3]; uint32_t colorTestMask;
|
||||
float blendFixA[3]; float stencil;
|
||||
float blendFixB[3]; float padUnused;
|
||||
float blendFixB[3]; float rotation;
|
||||
float texClamp[4];
|
||||
float texClampOffset[2]; float fogCoef[2];
|
||||
// VR stuff is to go here, later. For normal drawing, we can then get away
|
||||
@ -61,7 +61,7 @@ R"( mat4 u_proj;
|
||||
vec3 u_fogcolor; uint u_alphacolorref;
|
||||
vec3 u_texenv; uint u_alphacolormask;
|
||||
vec3 u_blendFixA; float u_stencilReplaceValue;
|
||||
vec3 u_blendFixB; float u_padUnused;
|
||||
vec3 u_blendFixB; float u_rotation;
|
||||
vec4 u_texclamp;
|
||||
vec2 u_texclampoff;
|
||||
vec2 u_fogcoef;
|
||||
@ -130,22 +130,10 @@ static const char * const ub_vs_bonesStr =
|
||||
R"( mat3x4 u_bone0; mat3x4 u_bone1; mat3x4 u_bone2; mat3x4 u_bone3; mat3x4 u_bone4; mat3x4 u_bone5; mat3x4 u_bone6; mat3x4 u_bone7; mat3x4 u_bone8;
|
||||
)";
|
||||
|
||||
|
||||
static const char * const ub_frameStr =
|
||||
R"(
|
||||
float u_rotation;
|
||||
)";
|
||||
|
||||
// Frame-global uniforms.
|
||||
struct UB_Frame {
|
||||
float rotation; // This is only used when using software transform, and non-buffered, to support native screen rotation.
|
||||
};
|
||||
|
||||
void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bool hasNegZ);
|
||||
|
||||
void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipViewport, bool useBufferedRendering);
|
||||
void LightUpdateUniforms(UB_VS_Lights *ub, uint64_t dirtyUniforms);
|
||||
void BoneUpdateUniforms(UB_VS_Bones *ub, uint64_t dirtyUniforms);
|
||||
void FrameUpdateUniforms(UB_Frame *ub, bool useBufferedRendering);
|
||||
|
||||
uint32_t PackLightControlBits();
|
||||
|
@ -251,15 +251,11 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
|
||||
if (compat.shaderLanguage == GLSL_VULKAN) {
|
||||
WRITE(p, "\n");
|
||||
|
||||
if (!useHWTransform) {
|
||||
WRITE(p, "layout (std140, set = 0, binding = 0) uniform frameVars {\n%s};\n", ub_frameStr);
|
||||
}
|
||||
|
||||
WRITE(p, "layout (std140, set = 1, binding = %d) uniform baseVars {\n%s};\n", DRAW_BINDING_DYNUBO_BASE, ub_baseStr);
|
||||
WRITE(p, "layout (std140, set = 0, binding = %d) uniform baseVars {\n%s};\n", DRAW_BINDING_DYNUBO_BASE, ub_baseStr);
|
||||
if (enableLighting || doShadeMapping)
|
||||
WRITE(p, "layout (std140, set = 1, binding = %d) uniform lightVars {\n%s};\n", DRAW_BINDING_DYNUBO_LIGHT, ub_vs_lightsStr);
|
||||
WRITE(p, "layout (std140, set = 0, binding = %d) uniform lightVars {\n%s};\n", DRAW_BINDING_DYNUBO_LIGHT, ub_vs_lightsStr);
|
||||
if (enableBones)
|
||||
WRITE(p, "layout (std140, set = 1, binding = %d) uniform boneVars {\n%s};\n", DRAW_BINDING_DYNUBO_BONE, ub_vs_bonesStr);
|
||||
WRITE(p, "layout (std140, set = 0, binding = %d) uniform boneVars {\n%s};\n", DRAW_BINDING_DYNUBO_BONE, ub_vs_bonesStr);
|
||||
|
||||
if (enableBones) {
|
||||
WRITE(p, "%s", boneWeightDecl[numBoneWeights]);
|
||||
@ -637,7 +633,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
|
||||
WRITE(p, " vec4 tex;\n");
|
||||
WRITE(p, " vec4 col;\n");
|
||||
WRITE(p, "};\n");
|
||||
WRITE(p, "layout (std430, set = 1, binding = %d) readonly buffer s_tess_data {\n", DRAW_BINDING_TESS_STORAGE_BUF);
|
||||
WRITE(p, "layout (std430, set = 0, binding = %d) readonly buffer s_tess_data {\n", DRAW_BINDING_TESS_STORAGE_BUF);
|
||||
WRITE(p, " TessData tess_data[];\n");
|
||||
WRITE(p, "};\n");
|
||||
|
||||
@ -645,10 +641,10 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
|
||||
WRITE(p, " vec4 basis;\n");
|
||||
WRITE(p, " vec4 deriv;\n");
|
||||
WRITE(p, "};\n");
|
||||
WRITE(p, "layout (std430, set = 1, binding = %d) readonly buffer s_tess_weights_u {\n", DRAW_BINDING_TESS_STORAGE_BUF_WU);
|
||||
WRITE(p, "layout (std430, set = 0, binding = %d) readonly buffer s_tess_weights_u {\n", DRAW_BINDING_TESS_STORAGE_BUF_WU);
|
||||
WRITE(p, " TessWeight tess_weights_u[];\n");
|
||||
WRITE(p, "};\n");
|
||||
WRITE(p, "layout (std430, set = 1, binding = %d) readonly buffer s_tess_weights_v {\n", DRAW_BINDING_TESS_STORAGE_BUF_WV);
|
||||
WRITE(p, "layout (std430, set = 0, binding = %d) readonly buffer s_tess_weights_v {\n", DRAW_BINDING_TESS_STORAGE_BUF_WV);
|
||||
WRITE(p, " TessWeight tess_weights_v[];\n");
|
||||
WRITE(p, "};\n");
|
||||
} else if (ShaderLanguageIsOpenGL(compat.shaderLanguage)) {
|
||||
|
@ -176,8 +176,7 @@ void DrawEngineVulkan::InitDeviceObjects() {
|
||||
VkPipelineLayoutCreateInfo pl{ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO };
|
||||
pl.pPushConstantRanges = nullptr;
|
||||
pl.pushConstantRangeCount = 0;
|
||||
VkDescriptorSetLayout frameDescSetLayout = (VkDescriptorSetLayout)draw_->GetNativeObject(Draw::NativeObject::FRAME_DATA_DESC_SET_LAYOUT);
|
||||
VkDescriptorSetLayout layouts[2] = { frameDescSetLayout, descriptorSetLayout_};
|
||||
VkDescriptorSetLayout layouts[1] = { descriptorSetLayout_};
|
||||
pl.setLayoutCount = ARRAY_SIZE(layouts);
|
||||
pl.pSetLayouts = layouts;
|
||||
pl.flags = 0;
|
||||
@ -310,8 +309,6 @@ void DrawEngineVulkan::BeginFrame() {
|
||||
frame->pushVertex->Begin(vulkan);
|
||||
frame->pushIndex->Begin(vulkan);
|
||||
|
||||
frame->frameDescSetUpdated = false;
|
||||
|
||||
tessDataTransferVulkan->SetPushBuffer(frame->pushUBO);
|
||||
|
||||
DirtyAllUBOs();
|
||||
@ -547,7 +544,8 @@ void MarkUnreliable(VertexArrayInfoVulkan *vai) {
|
||||
|
||||
void DrawEngineVulkan::Invalidate(InvalidationCallbackFlags flags) {
|
||||
if (flags & InvalidationCallbackFlags::COMMAND_BUFFER_STATE) {
|
||||
GetCurFrame().frameDescSetUpdated = false;
|
||||
// Nothing here anymore (removed the "frame descriptor set"
|
||||
// If we add back "seldomly-changing" descriptors, we might use this again.
|
||||
}
|
||||
if (flags & InvalidationCallbackFlags::RENDER_PASS_STATE) {
|
||||
// If have a new render pass, dirty our dynamic state so it gets re-set.
|
||||
@ -1007,32 +1005,6 @@ void DrawEngineVulkan::DoFlush() {
|
||||
}
|
||||
|
||||
void DrawEngineVulkan::UpdateUBOs(FrameData *frame) {
|
||||
if (!frame->frameDescSetUpdated) {
|
||||
// Push frame global constants.
|
||||
UB_Frame frameConstants{};
|
||||
FrameUpdateUniforms(&frameConstants, framebufferManager_->UseBufferedRendering());
|
||||
|
||||
VkDescriptorBufferInfo frameConstantsBufInfo;
|
||||
frame->pushUBO->PushUBOData(frameConstants, &frameConstantsBufInfo);
|
||||
|
||||
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
|
||||
VulkanRenderManager *renderManager = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
VkDescriptorSetLayout frameDescSetLayout = (VkDescriptorSetLayout)draw_->GetNativeObject(Draw::NativeObject::FRAME_DATA_DESC_SET_LAYOUT);
|
||||
|
||||
VkDescriptorSet frameDescSet = frame->descPool.Allocate(1, &frameDescSetLayout, "frame_desc_set");
|
||||
|
||||
VkWriteDescriptorSet descWrite{ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET };
|
||||
descWrite.descriptorCount = 1;
|
||||
descWrite.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
descWrite.dstBinding = 0;
|
||||
descWrite.dstSet = frameDescSet;
|
||||
descWrite.pBufferInfo = &frameConstantsBufInfo;
|
||||
vkUpdateDescriptorSets(vulkan->GetDevice(), 1, &descWrite, 0, nullptr);
|
||||
renderManager->BindDescriptorSet(0, frameDescSet, pipelineLayout_);
|
||||
|
||||
frame->frameDescSetUpdated = true;
|
||||
}
|
||||
|
||||
if ((dirtyUniforms_ & DIRTY_BASE_UNIFORMS) || baseBuf == VK_NULL_HANDLE) {
|
||||
baseUBOOffset = shaderManager_->PushBaseBuffer(frame->pushUBO, &baseBuf);
|
||||
dirtyUniforms_ &= ~DIRTY_BASE_UNIFORMS;
|
||||
|
@ -272,8 +272,6 @@ private:
|
||||
VulkanPushBuffer *pushVertex = nullptr;
|
||||
VulkanPushBuffer *pushIndex = nullptr;
|
||||
|
||||
bool frameDescSetUpdated = false;
|
||||
|
||||
// We do rolling allocation and reset instead of caching across frames. That we might do later.
|
||||
DenseHashMap<DescriptorSetKey, VkDescriptorSet, (VkDescriptorSet)VK_NULL_HANDLE> descSets;
|
||||
|
||||
|
@ -65,9 +65,9 @@ const char *uploadShader = R"(
|
||||
// hardware vendors.
|
||||
layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
uniform layout(set = 1, binding = 0, rgba8) writeonly image2D img;
|
||||
uniform layout(set = 0, binding = 0, rgba8) writeonly image2D img;
|
||||
|
||||
layout(std430, set = 1, binding = 1) buffer Buf {
|
||||
layout(std430, set = 0, binding = 1) buffer Buf {
|
||||
uint data[];
|
||||
} buf;
|
||||
|
||||
|
@ -106,8 +106,7 @@ void VulkanComputeShaderManager::InitDeviceObjects(Draw::DrawContext *draw) {
|
||||
VkPipelineLayoutCreateInfo pl = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO };
|
||||
pl.pPushConstantRanges = &push;
|
||||
pl.pushConstantRangeCount = 1;
|
||||
VkDescriptorSetLayout frameDescSetLayout = (VkDescriptorSetLayout)draw->GetNativeObject(Draw::NativeObject::FRAME_DATA_DESC_SET_LAYOUT);
|
||||
VkDescriptorSetLayout setLayouts[2] = { frameDescSetLayout, descriptorSetLayout_ };
|
||||
VkDescriptorSetLayout setLayouts[1] = { descriptorSetLayout_ };
|
||||
pl.setLayoutCount = ARRAY_SIZE(setLayouts);
|
||||
pl.pSetLayouts = setLayouts;
|
||||
pl.flags = 0;
|
||||
|
@ -44,7 +44,7 @@ static const std::vector<Draw::ShaderSource> fsDiscard = {
|
||||
layout(location = 0) in vec4 oColor0;
|
||||
layout(location = 1) in vec2 oTexCoord0;
|
||||
layout(location = 0) out vec4 fragColor0;
|
||||
layout(set = 1, binding = 1) uniform sampler2D Sampler0;
|
||||
layout(set = 0, binding = 1) uniform sampler2D Sampler0;
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, oTexCoord0) * oColor0;
|
||||
if (color.a <= 0.0)
|
||||
@ -86,7 +86,7 @@ static const std::vector<Draw::ShaderSource> fsAdrenoLogicTest = {
|
||||
layout(location = 0) in vec4 oColor0;
|
||||
layout(location = 1) in highp vec2 oTexCoord0;
|
||||
layout(location = 0) out vec4 fragColor0;
|
||||
layout(set = 1, binding = 1) uniform sampler2D Sampler0;
|
||||
layout(set = 0, binding = 1) uniform sampler2D Sampler0;
|
||||
void main() {
|
||||
vec4 v = texture(Sampler0, oTexCoord0).aaaa * oColor0;
|
||||
if (v.r < 0.2 && v.g < 0.2 && v.b < 0.2) discard;
|
||||
@ -117,7 +117,7 @@ static const std::vector<Draw::ShaderSource> vsAdrenoLogicTest = {
|
||||
"#version 450\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n"
|
||||
"#extension GL_ARB_shading_language_420pack : enable\n"
|
||||
"layout (std140, set = 1, binding = 0) uniform bufferVals {\n"
|
||||
"layout (std140, set = 0, binding = 0) uniform bufferVals {\n"
|
||||
" mat4 WorldViewProj;\n"
|
||||
"} myBufferVals;\n"
|
||||
"layout (location = 0) in vec4 pos;\n"
|
||||
@ -173,7 +173,7 @@ static const std::vector<Draw::ShaderSource> fsFlat = {
|
||||
"layout(location = 0) flat in lowp vec4 oColor0;\n"
|
||||
"layout(location = 1) in highp vec2 oTexCoord0;\n"
|
||||
"layout(location = 0) out vec4 fragColor0;\n"
|
||||
"layout(set = 1, binding = 1) uniform sampler2D Sampler0;\n"
|
||||
"layout(set = 0, binding = 1) uniform sampler2D Sampler0;\n"
|
||||
"void main() { fragColor0 = texture(Sampler0, oTexCoord0) * oColor0; }\n"
|
||||
}
|
||||
};
|
||||
@ -214,7 +214,7 @@ static const std::vector<Draw::ShaderSource> vsFlat = {
|
||||
"#version 450\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n"
|
||||
"#extension GL_ARB_shading_language_420pack : enable\n"
|
||||
"layout (std140, set = 1, binding = 0) uniform bufferVals {\n"
|
||||
"layout (std140, set = 0, binding = 0) uniform bufferVals {\n"
|
||||
" mat4 WorldViewProj;\n"
|
||||
"} myBufferVals;\n"
|
||||
"layout (location = 0) in vec4 pos;\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user