mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
vulkan: fix shader crash
This commit is contained in:
@@ -1131,6 +1131,8 @@ void Graphics::beginFrame()
|
|||||||
|
|
||||||
Vulkan::resetShaderSwitches();
|
Vulkan::resetShaderSwitches();
|
||||||
|
|
||||||
|
for (const auto shader : usedShadersInFrame)
|
||||||
|
shader->newFrame();
|
||||||
usedShadersInFrame.clear();
|
usedShadersInFrame.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2478,9 +2480,9 @@ void Graphics::setComputeShader(Shader *shader)
|
|||||||
computeShader = shader;
|
computeShader = shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<Shader*> &Graphics::getUsedShadersInFrame()
|
void Graphics::markShaderUsed(Shader *shader)
|
||||||
{
|
{
|
||||||
return usedShadersInFrame;
|
usedShadersInFrame.insert(shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkSampler Graphics::getCachedSampler(const SamplerState &samplerState)
|
VkSampler Graphics::getCachedSampler(const SamplerState &samplerState)
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ public:
|
|||||||
graphics::Texture *getDefaultTexture() const;
|
graphics::Texture *getDefaultTexture() const;
|
||||||
VkSampler getCachedSampler(const SamplerState &sampler);
|
VkSampler getCachedSampler(const SamplerState &sampler);
|
||||||
void setComputeShader(Shader *computeShader);
|
void setComputeShader(Shader *computeShader);
|
||||||
std::set<Shader*> &getUsedShadersInFrame();
|
void markShaderUsed(Shader*);
|
||||||
graphics::Shader::BuiltinUniformData getCurrentBuiltinUniformData();
|
graphics::Shader::BuiltinUniformData getCurrentBuiltinUniformData();
|
||||||
const OptionalDeviceFeatures &getEnabledOptionalDeviceExtensions() const;
|
const OptionalDeviceFeatures &getEnabledOptionalDeviceExtensions() const;
|
||||||
VkSampleCountFlagBits getMsaaCount(int requestedMsaa) const;
|
VkSampleCountFlagBits getMsaaCount(int requestedMsaa) const;
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ bool Shader::loadVolatile()
|
|||||||
currentFrame = 0;
|
currentFrame = 0;
|
||||||
currentUsedUniformStreamBuffersCount = 0;
|
currentUsedUniformStreamBuffersCount = 0;
|
||||||
currentUsedDescriptorSetsCount = 0;
|
currentUsedDescriptorSetsCount = 0;
|
||||||
|
newFrame();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -384,7 +385,7 @@ void Shader::cmdPushDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBind
|
|||||||
for (const auto &u : uniformInfos)
|
for (const auto &u : uniformInfos)
|
||||||
{
|
{
|
||||||
if (updatedUniforms.find(u.second.location) == updatedUniforms.end())
|
if (updatedUniforms.find(u.second.location) == updatedUniforms.end())
|
||||||
updateUniform(&u.second, u.second.count);
|
updateUniform(&u.second, u.second.count, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
vkCmdBindDescriptorSets(commandBuffer, bindPoint, pipelineLayout, 0, 1, ¤tDescriptorSet, 0, nullptr);
|
vkCmdBindDescriptorSets(commandBuffer, bindPoint, pipelineLayout, 0, 1, ¤tDescriptorSet, 0, nullptr);
|
||||||
@@ -406,12 +407,7 @@ Shader::~Shader()
|
|||||||
|
|
||||||
void Shader::attach()
|
void Shader::attach()
|
||||||
{
|
{
|
||||||
auto &usedShadersInFrame = vgfx->getUsedShadersInFrame();
|
vgfx->markShaderUsed(this);
|
||||||
if (usedShadersInFrame.find(this) == usedShadersInFrame.end())
|
|
||||||
{
|
|
||||||
newFrame();
|
|
||||||
usedShadersInFrame.insert(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isCompute)
|
if (!isCompute)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user