mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- the light storage buffer is not dynamic
This commit is contained in:
parent
6d1a85af3c
commit
188714dc14
4 changed files with 8 additions and 17 deletions
|
@ -44,7 +44,7 @@ FLightBuffer::FLightBuffer()
|
||||||
// Hack alert: On Intel's GL driver SSBO's perform quite worse than UBOs.
|
// Hack alert: On Intel's GL driver SSBO's perform quite worse than UBOs.
|
||||||
// We only want to disable using SSBOs for lights but not disable the feature entirely.
|
// We only want to disable using SSBOs for lights but not disable the feature entirely.
|
||||||
// Note that using an uniform buffer here will limit the number of lights per surface so it isn't done for NVidia and AMD.
|
// Note that using an uniform buffer here will limit the number of lights per surface so it isn't done for NVidia and AMD.
|
||||||
if (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER && !strstr(screen->gl_vendorstring, "Intel"))
|
if (screen->IsVulkan() || ((screen->hwcaps & RFL_SHADER_STORAGE_BUFFER) && !strstr(screen->gl_vendorstring, "Intel")))
|
||||||
{
|
{
|
||||||
mBufferType = true;
|
mBufferType = true;
|
||||||
mBlockAlign = 0;
|
mBlockAlign = 0;
|
||||||
|
|
|
@ -88,7 +88,7 @@ void VkRenderPassManager::CreateDynamicSetLayout()
|
||||||
{
|
{
|
||||||
DescriptorSetLayoutBuilder builder;
|
DescriptorSetLayoutBuilder builder;
|
||||||
builder.addBinding(0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT);
|
builder.addBinding(0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
builder.addBinding(1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
|
builder.addBinding(1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
builder.addBinding(2, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT);
|
builder.addBinding(2, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
builder.addBinding(3, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT);
|
builder.addBinding(3, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
builder.addBinding(4, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
|
builder.addBinding(4, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
|
@ -138,7 +138,7 @@ void VkRenderPassManager::CreateDescriptorPool()
|
||||||
{
|
{
|
||||||
DescriptorPoolBuilder builder;
|
DescriptorPoolBuilder builder;
|
||||||
builder.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 3);
|
builder.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 3);
|
||||||
builder.addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1);
|
builder.addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1);
|
||||||
builder.addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1);
|
builder.addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1);
|
||||||
builder.setMaxSets(1);
|
builder.setMaxSets(1);
|
||||||
DynamicDescriptorPool = builder.create(GetVulkanFrameBuffer()->device);
|
DynamicDescriptorPool = builder.create(GetVulkanFrameBuffer()->device);
|
||||||
|
@ -158,7 +158,7 @@ void VkRenderPassManager::UpdateDynamicSet()
|
||||||
|
|
||||||
WriteDescriptors update;
|
WriteDescriptors update;
|
||||||
update.addBuffer(DynamicSet.get(), 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->ViewpointUBO->mBuffer.get(), 0, sizeof(HWViewpointUniforms));
|
update.addBuffer(DynamicSet.get(), 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->ViewpointUBO->mBuffer.get(), 0, sizeof(HWViewpointUniforms));
|
||||||
update.addBuffer(DynamicSet.get(), 1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, fb->LightBufferSSO->mBuffer.get(), 0, fb->GetLightBufferBlockSize());
|
update.addBuffer(DynamicSet.get(), 1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->LightBufferSSO->mBuffer.get());
|
||||||
update.addBuffer(DynamicSet.get(), 2, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->MatricesUBO->mBuffer.get(), 0, sizeof(MatricesUBO));
|
update.addBuffer(DynamicSet.get(), 2, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->MatricesUBO->mBuffer.get(), 0, sizeof(MatricesUBO));
|
||||||
update.addBuffer(DynamicSet.get(), 3, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->StreamUBO->mBuffer.get(), 0, sizeof(StreamUBO));
|
update.addBuffer(DynamicSet.get(), 3, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->StreamUBO->mBuffer.get(), 0, sizeof(StreamUBO));
|
||||||
update.addCombinedImageSampler(DynamicSet.get(), 4, fb->GetBuffers()->ShadowmapView.get(), fb->GetBuffers()->ShadowmapSampler.get(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
update.addCombinedImageSampler(DynamicSet.get(), 4, fb->GetBuffers()->ShadowmapView.get(), fb->GetBuffers()->ShadowmapSampler.get(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||||
|
|
|
@ -374,7 +374,7 @@ void VkRenderState::ApplyPushConstants()
|
||||||
if (mMaterial.mMaterial && mMaterial.mMaterial->tex)
|
if (mMaterial.mMaterial && mMaterial.mMaterial->tex)
|
||||||
mPushConstants.uSpecularMaterial = { mMaterial.mMaterial->tex->Glossiness, mMaterial.mMaterial->tex->SpecularLevel };
|
mPushConstants.uSpecularMaterial = { mMaterial.mMaterial->tex->Glossiness, mMaterial.mMaterial->tex->SpecularLevel };
|
||||||
|
|
||||||
mPushConstants.uLightIndex = screen->mLights->BindUBO(mLightIndex);
|
mPushConstants.uLightIndex = mLightIndex;
|
||||||
mPushConstants.uDataIndex = mDataIndex;
|
mPushConstants.uDataIndex = mDataIndex;
|
||||||
|
|
||||||
auto fb = GetVulkanFrameBuffer();
|
auto fb = GetVulkanFrameBuffer();
|
||||||
|
@ -474,16 +474,15 @@ void VkRenderState::ApplyMaterial()
|
||||||
|
|
||||||
void VkRenderState::ApplyDynamicSet()
|
void VkRenderState::ApplyDynamicSet()
|
||||||
{
|
{
|
||||||
if (mViewpointOffset != mLastViewpointOffset || mLightBufferOffset != mLastLightBufferOffset || mMatricesOffset != mLastMatricesOffset || mStreamDataOffset != mLastStreamDataOffset)
|
if (mViewpointOffset != mLastViewpointOffset || mMatricesOffset != mLastMatricesOffset || mStreamDataOffset != mLastStreamDataOffset)
|
||||||
{
|
{
|
||||||
auto fb = GetVulkanFrameBuffer();
|
auto fb = GetVulkanFrameBuffer();
|
||||||
auto passManager = fb->GetRenderPassManager();
|
auto passManager = fb->GetRenderPassManager();
|
||||||
|
|
||||||
uint32_t offsets[4] = { mViewpointOffset, mLightBufferOffset, mMatricesOffset, mStreamDataOffset };
|
uint32_t offsets[3] = { mViewpointOffset, mMatricesOffset, mStreamDataOffset };
|
||||||
mCommandBuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, passManager->GetPipelineLayout(mRenderPassKey.NumTextureLayers), 0, passManager->DynamicSet.get(), 4, offsets);
|
mCommandBuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, passManager->GetPipelineLayout(mRenderPassKey.NumTextureLayers), 0, passManager->DynamicSet.get(), 3, offsets);
|
||||||
|
|
||||||
mLastViewpointOffset = mViewpointOffset;
|
mLastViewpointOffset = mViewpointOffset;
|
||||||
mLastLightBufferOffset = mLightBufferOffset;
|
|
||||||
mLastMatricesOffset = mMatricesOffset;
|
mLastMatricesOffset = mMatricesOffset;
|
||||||
mLastStreamDataOffset = mStreamDataOffset;
|
mLastStreamDataOffset = mStreamDataOffset;
|
||||||
}
|
}
|
||||||
|
@ -496,11 +495,6 @@ void VkRenderState::Bind(int bindingpoint, uint32_t offset)
|
||||||
mViewpointOffset = offset;
|
mViewpointOffset = offset;
|
||||||
mNeedApply = true;
|
mNeedApply = true;
|
||||||
}
|
}
|
||||||
else if (bindingpoint == LIGHTBUF_BINDINGPOINT)
|
|
||||||
{
|
|
||||||
mLightBufferOffset = offset;
|
|
||||||
mNeedApply = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VkRenderState::BeginFrame()
|
void VkRenderState::BeginFrame()
|
||||||
|
@ -518,7 +512,6 @@ void VkRenderState::EndRenderPass()
|
||||||
mRenderPassKey = {};
|
mRenderPassKey = {};
|
||||||
|
|
||||||
mLastViewpointOffset = 0xffffffff;
|
mLastViewpointOffset = 0xffffffff;
|
||||||
mLastLightBufferOffset = 0xffffffff;
|
|
||||||
mLastVertexBuffer = nullptr;
|
mLastVertexBuffer = nullptr;
|
||||||
mLastIndexBuffer = nullptr;
|
mLastIndexBuffer = nullptr;
|
||||||
mLastModelMatrixEnabled = true;
|
mLastModelMatrixEnabled = true;
|
||||||
|
|
|
@ -91,11 +91,9 @@ protected:
|
||||||
PushConstants mPushConstants = {};
|
PushConstants mPushConstants = {};
|
||||||
|
|
||||||
uint32_t mLastViewpointOffset = 0xffffffff;
|
uint32_t mLastViewpointOffset = 0xffffffff;
|
||||||
uint32_t mLastLightBufferOffset = 0xffffffff;
|
|
||||||
uint32_t mLastMatricesOffset = 0xffffffff;
|
uint32_t mLastMatricesOffset = 0xffffffff;
|
||||||
uint32_t mLastStreamDataOffset = 0xffffffff;
|
uint32_t mLastStreamDataOffset = 0xffffffff;
|
||||||
uint32_t mViewpointOffset = 0;
|
uint32_t mViewpointOffset = 0;
|
||||||
uint32_t mLightBufferOffset = 0;
|
|
||||||
uint32_t mMatricesOffset = 0;
|
uint32_t mMatricesOffset = 0;
|
||||||
uint32_t mDataIndex = -1;
|
uint32_t mDataIndex = -1;
|
||||||
uint32_t mStreamDataOffset = 0;
|
uint32_t mStreamDataOffset = 0;
|
||||||
|
|
Loading…
Reference in a new issue