Add GetDevice function instead of accessing device member directly

This commit is contained in:
Magnus Norddahl 2023-04-16 17:07:55 +02:00 committed by Christoph Oelckers
parent 3551e1e5e9
commit 9caa966f6f
16 changed files with 140 additions and 140 deletions

View file

@ -28,7 +28,7 @@
VkRaytrace::VkRaytrace(VulkanRenderDevice* fb) : fb(fb)
{
useRayQuery = fb->device->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME);
useRayQuery = fb->GetDevice()->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME);
NullMesh.MeshVertices.Push({ -1.0f, -1.0f, -1.0f });
NullMesh.MeshVertices.Push({ 1.0f, -1.0f, -1.0f });
@ -113,7 +113,7 @@ void VkRaytrace::CreateVertexAndIndexBuffers()
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)
.Size(vertices.size() * sizeof(FVector4))
.DebugName("vertexBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
indexBuffer = BufferBuilder()
.Usage(
@ -125,19 +125,19 @@ void VkRaytrace::CreateVertexAndIndexBuffers()
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)
.Size((size_t)Mesh->MeshElements.Size() * sizeof(uint32_t))
.DebugName("indexBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
nodesBuffer = BufferBuilder()
.Usage(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT)
.Size(sizeof(CollisionNodeBufferHeader) + nodes.size() * sizeof(CollisionNode))
.DebugName("nodesBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
transferBuffer = BufferTransfer()
.AddBuffer(vertexBuffer.get(), vertices.data(), vertices.size() * sizeof(FVector4))
.AddBuffer(indexBuffer.get(), Mesh->MeshElements.Data(), (size_t)Mesh->MeshElements.Size() * sizeof(uint32_t))
.AddBuffer(nodesBuffer.get(), &nodesHeader, sizeof(CollisionNodeBufferHeader), nodes.data(), nodes.size() * sizeof(CollisionNode))
.Execute(fb->device.get(), fb->GetCommands()->GetTransferCommands());
.Execute(fb->GetDevice(), fb->GetCommands()->GetTransferCommands());
PipelineBarrier()
.AddMemory(VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT)
@ -171,25 +171,26 @@ void VkRaytrace::CreateBottomLevelAccelerationStructure()
uint32_t maxPrimitiveCount = Mesh->MeshElements.Size() / 3;
VkAccelerationStructureBuildSizesInfoKHR sizeInfo = { VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR };
vkGetAccelerationStructureBuildSizesKHR(fb->device->device, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &buildInfo, &maxPrimitiveCount, &sizeInfo);
vkGetAccelerationStructureBuildSizesKHR(fb->GetDevice()->device, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &buildInfo, &maxPrimitiveCount, &sizeInfo);
blAccelStructBuffer = BufferBuilder()
.Usage(VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT)
.Size(sizeInfo.accelerationStructureSize)
.DebugName("blAccelStructBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
blAccelStruct = AccelerationStructureBuilder()
.Type(VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR)
.Buffer(blAccelStructBuffer.get(), sizeInfo.accelerationStructureSize)
.DebugName("blAccelStruct")
.Create(fb->device.get());
.Create(fb->GetDevice());
blScratchBuffer = BufferBuilder()
.Usage(VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)
.Size(sizeInfo.buildScratchSize)
.MinAlignment(fb->GetDevice()->PhysicalDevice.Properties.AccelerationStructure.minAccelerationStructureScratchOffsetAlignment)
.DebugName("blScratchBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
buildInfo.dstAccelerationStructure = blAccelStruct->accelstruct;
buildInfo.scratchData.deviceAddress = blScratchBuffer->GetDeviceAddress();
@ -217,7 +218,7 @@ void VkRaytrace::CreateTopLevelAccelerationStructure()
.Usage(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY)
.Size(sizeof(VkAccelerationStructureInstanceKHR))
.DebugName("tlTransferBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
auto data = (uint8_t*)tlTransferBuffer->Map(0, sizeof(VkAccelerationStructureInstanceKHR));
memcpy(data, &instance, sizeof(VkAccelerationStructureInstanceKHR));
@ -227,7 +228,7 @@ void VkRaytrace::CreateTopLevelAccelerationStructure()
.Usage(VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR | VK_BUFFER_USAGE_TRANSFER_DST_BIT)
.Size(sizeof(VkAccelerationStructureInstanceKHR))
.DebugName("tlInstanceBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
fb->GetCommands()->GetTransferCommands()->copyBuffer(tlTransferBuffer.get(), tlInstanceBuffer.get());
@ -255,25 +256,26 @@ void VkRaytrace::CreateTopLevelAccelerationStructure()
uint32_t maxInstanceCount = 1;
VkAccelerationStructureBuildSizesInfoKHR sizeInfo = { VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR };
vkGetAccelerationStructureBuildSizesKHR(fb->device->device, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &buildInfo, &maxInstanceCount, &sizeInfo);
vkGetAccelerationStructureBuildSizesKHR(fb->GetDevice()->device, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &buildInfo, &maxInstanceCount, &sizeInfo);
tlAccelStructBuffer = BufferBuilder()
.Usage(VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT)
.Size(sizeInfo.accelerationStructureSize)
.DebugName("tlAccelStructBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
tlAccelStruct = AccelerationStructureBuilder()
.Type(VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR)
.Buffer(tlAccelStructBuffer.get(), sizeInfo.accelerationStructureSize)
.DebugName("tlAccelStruct")
.Create(fb->device.get());
.Create(fb->GetDevice());
tlScratchBuffer = BufferBuilder()
.Usage(VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)
.Size(sizeInfo.buildScratchSize)
.MinAlignment(fb->GetDevice()->PhysicalDevice.Properties.AccelerationStructure.minAccelerationStructureScratchOffsetAlignment)
.DebugName("tlScratchBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
buildInfo.dstAccelerationStructure = tlAccelStruct->accelstruct;
buildInfo.scratchData.deviceAddress = tlScratchBuffer->GetDeviceAddress();

View file

@ -80,13 +80,13 @@ void VkHardwareBuffer::SetData(size_t size, const void *data, BufferUsageType us
.Usage(VK_BUFFER_USAGE_TRANSFER_DST_BIT | mBufferType, VMA_MEMORY_USAGE_GPU_ONLY)
.Size(bufsize)
.DebugName(usage == BufferUsageType::Static ? "VkHardwareBuffer.Static" : "VkHardwareBuffer.Stream")
.Create(fb->device.get());
.Create(fb->GetDevice());
mStaging = BufferBuilder()
.Usage(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY)
.Size(bufsize)
.DebugName(usage == BufferUsageType::Static ? "VkHardwareBuffer.Staging.Static" : "VkHardwareBuffer.Staging.Stream")
.Create(fb->device.get());
.Create(fb->GetDevice());
if (data)
{
@ -108,7 +108,7 @@ void VkHardwareBuffer::SetData(size_t size, const void *data, BufferUsageType us
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
.Size(bufsize)
.DebugName("VkHardwareBuffer.Persistent")
.Create(fb->device.get());
.Create(fb->GetDevice());
map = mBuffer->Map(0, bufsize);
if (data)
@ -125,7 +125,7 @@ void VkHardwareBuffer::SetData(size_t size, const void *data, BufferUsageType us
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
.Size(bufsize)
.DebugName("VkHardwareBuffer.Mappable")
.Create(fb->device.get());
.Create(fb->GetDevice());
if (data)
{
@ -176,7 +176,7 @@ void VkHardwareBuffer::Resize(size_t newsize)
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
.Size(newsize)
.DebugName("VkHardwareBuffer.Resized")
.Create(fb->device.get());
.Create(fb->GetDevice());
buffersize = newsize;
// Transfer data from old to new

View file

@ -40,24 +40,24 @@ extern FString gpuStatOutput;
VkCommandBufferManager::VkCommandBufferManager(VulkanRenderDevice* fb) : fb(fb)
{
mCommandPool = CommandPoolBuilder()
.QueueFamily(fb->device->GraphicsFamily)
.QueueFamily(fb->GetDevice()->GraphicsFamily)
.DebugName("mCommandPool")
.Create(fb->device.get());
.Create(fb->GetDevice());
for (auto& semaphore : mSubmitSemaphore)
semaphore.reset(new VulkanSemaphore(fb->device.get()));
semaphore.reset(new VulkanSemaphore(fb->GetDevice()));
for (auto& fence : mSubmitFence)
fence.reset(new VulkanFence(fb->device.get()));
fence.reset(new VulkanFence(fb->GetDevice()));
for (int i = 0; i < maxConcurrentSubmitCount; i++)
mSubmitWaitFences[i] = mSubmitFence[i]->fence;
if (fb->device->GraphicsTimeQueries)
if (fb->GetDevice()->GraphicsTimeQueries)
{
mTimestampQueryPool = QueryPoolBuilder()
.QueryType(VK_QUERY_TYPE_TIMESTAMP, MaxTimestampQueries)
.Create(fb->device.get());
.Create(fb->GetDevice());
GetDrawCommands()->resetQueryPool(mTimestampQueryPool.get(), 0, MaxTimestampQueries);
}
@ -104,8 +104,8 @@ void VkCommandBufferManager::FlushCommands(VulkanCommandBuffer** commands, size_
if (mNextSubmit >= maxConcurrentSubmitCount)
{
vkWaitForFences(fb->device->device, 1, &mSubmitFence[currentIndex]->fence, VK_TRUE, std::numeric_limits<uint64_t>::max());
vkResetFences(fb->device->device, 1, &mSubmitFence[currentIndex]->fence);
vkWaitForFences(fb->GetDevice()->device, 1, &mSubmitFence[currentIndex]->fence, VK_TRUE, std::numeric_limits<uint64_t>::max());
vkResetFences(fb->GetDevice()->device, 1, &mSubmitFence[currentIndex]->fence);
}
QueueSubmit submit;
@ -125,7 +125,7 @@ void VkCommandBufferManager::FlushCommands(VulkanCommandBuffer** commands, size_
if (!lastsubmit)
submit.AddSignal(mSubmitSemaphore[currentIndex].get());
submit.Execute(fb->device.get(), fb->device->GraphicsQueue, mSubmitFence[currentIndex].get());
submit.Execute(fb->GetDevice(), fb->GetDevice()->GraphicsQueue, mSubmitFence[currentIndex].get());
mNextSubmit++;
}
@ -181,8 +181,8 @@ void VkCommandBufferManager::WaitForCommands(bool finish, bool uploadOnly)
if (numWaitFences > 0)
{
vkWaitForFences(fb->device->device, numWaitFences, mSubmitWaitFences, VK_TRUE, std::numeric_limits<uint64_t>::max());
vkResetFences(fb->device->device, numWaitFences, mSubmitWaitFences);
vkWaitForFences(fb->GetDevice()->device, numWaitFences, mSubmitWaitFences, VK_TRUE, std::numeric_limits<uint64_t>::max());
vkResetFences(fb->GetDevice()->device, numWaitFences, mSubmitWaitFences);
}
DeleteFrameObjects(uploadOnly);
@ -208,7 +208,7 @@ void VkCommandBufferManager::PushGroup(const FString& name)
if (!gpuStatActive)
return;
if (mNextTimestampQuery < MaxTimestampQueries && fb->device->GraphicsTimeQueries)
if (mNextTimestampQuery < MaxTimestampQueries && fb->GetDevice()->GraphicsTimeQueries)
{
TimestampQuery q;
q.name = name;
@ -228,7 +228,7 @@ void VkCommandBufferManager::PopGroup()
TimestampQuery& q = timeElapsedQueries[mGroupStack.back()];
mGroupStack.pop_back();
if (mNextTimestampQuery < MaxTimestampQueries && fb->device->GraphicsTimeQueries)
if (mNextTimestampQuery < MaxTimestampQueries && fb->GetDevice()->GraphicsTimeQueries)
{
q.endIndex = mNextTimestampQuery++;
GetDrawCommands()->writeTimestamp(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, mTimestampQueryPool.get(), q.endIndex);
@ -241,7 +241,7 @@ void VkCommandBufferManager::UpdateGpuStats()
if (mNextTimestampQuery > 0)
mTimestampQueryPool->getResults(0, mNextTimestampQuery, sizeof(uint64_t) * mNextTimestampQuery, timestamps, sizeof(uint64_t), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT);
double timestampPeriod = fb->device->PhysicalDevice.Properties.Properties.limits.timestampPeriod;
double timestampPeriod = fb->GetDevice()->PhysicalDevice.Properties.Properties.limits.timestampPeriod;
gpuStatOutput = "";
for (auto& q : timeElapsedQueries)

View file

@ -86,7 +86,7 @@ void VkDescriptorSetManager::UpdateHWBufferSet()
.AddBuffer(HWBufferSet.get(), 2, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->GetBufferManager()->StreamBuffer->UniformBuffer->mBuffer.get(), 0, sizeof(StreamUBO))
.AddBuffer(HWBufferSet.get(), 3, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->GetBufferManager()->LightBufferSSO->mBuffer.get())
.AddBuffer(HWBufferSet.get(), 4, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->GetBufferManager()->BoneBufferSSO->mBuffer.get())
.Execute(fb->device.get());
.Execute(fb->GetDevice());
}
void VkDescriptorSetManager::UpdateFixedSet()
@ -103,7 +103,7 @@ void VkDescriptorSetManager::UpdateFixedSet()
WriteDescriptors update;
update.AddCombinedImageSampler(FixedSet.get(), 0, fb->GetTextureManager()->Shadowmap.View.get(), fb->GetSamplerManager()->ShadowmapSampler.get(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
update.AddCombinedImageSampler(FixedSet.get(), 1, fb->GetTextureManager()->Lightmap.View.get(), fb->GetSamplerManager()->LightmapSampler.get(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
if (fb->device->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME))
if (fb->GetDevice()->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME))
{
update.AddAccelerationStructure(FixedSet.get(), 2, fb->GetRaytrace()->GetAccelStruct());
}
@ -113,7 +113,7 @@ void VkDescriptorSetManager::UpdateFixedSet()
update.AddBuffer(FixedSet.get(), 3, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->GetRaytrace()->GetVertexBuffer());
update.AddBuffer(FixedSet.get(), 4, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->GetRaytrace()->GetIndexBuffer());
}
update.Execute(fb->device.get());
update.Execute(fb->GetDevice());
}
void VkDescriptorSetManager::ResetHWTextureSets()
@ -144,7 +144,7 @@ VulkanDescriptorSet* VkDescriptorSetManager::GetNullTextureDescriptorSet()
{
update.AddCombinedImageSampler(NullTextureDescriptorSet.get(), i, fb->GetTextureManager()->GetNullTextureView(), fb->GetSamplerManager()->Get(CLAMP_XY_NOMIP), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
}
update.Execute(fb->device.get());
update.Execute(fb->GetDevice());
}
return NullTextureDescriptorSet.get();
@ -161,7 +161,7 @@ std::unique_ptr<VulkanDescriptorSet> VkDescriptorSetManager::AllocateTextureDesc
.AddPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, TextureDescriptorsLeft)
.MaxSets(TextureDescriptorSetsLeft)
.DebugName("VkDescriptorSetManager.TextureDescriptorPool")
.Create(fb->device.get()));
.Create(fb->GetDevice()));
}
TextureDescriptorSetsLeft--;
@ -184,7 +184,7 @@ VulkanDescriptorSetLayout* VkDescriptorSetManager::GetTextureSetLayout(int numLa
builder.AddBinding(i, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
}
builder.DebugName("VkDescriptorSetManager.TextureSetLayout");
layout = builder.Create(fb->device.get());
layout = builder.Create(fb->GetDevice());
return layout.get();
}
@ -225,7 +225,7 @@ VulkanDescriptorSet* VkDescriptorSetManager::GetInput(VkPPRenderPassSetup* passS
write.AddBuffer(descriptors.get(), LIGHTLIST_BINDINGPOINT, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->GetBufferManager()->LightList->mBuffer.get());
}
write.Execute(fb->device.get());
write.Execute(fb->GetDevice());
imageTransition.Execute(fb->GetCommands()->GetDrawCommands());
VulkanDescriptorSet* set = descriptors.get();
@ -249,7 +249,7 @@ std::unique_ptr<VulkanDescriptorSet> VkDescriptorSetManager::AllocatePPDescripto
.AddPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 4)
.MaxSets(100)
.DebugName("PPDescriptorPool")
.Create(fb->device.get());
.Create(fb->GetDevice());
return PPDescriptorPool->allocate(layout);
}
@ -263,7 +263,7 @@ void VkDescriptorSetManager::CreateHWBufferSetLayout()
.AddBinding(3, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT)
.AddBinding(4, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT)
.DebugName("VkDescriptorSetManager.HWBufferSetLayout")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
void VkDescriptorSetManager::CreateFixedSetLayout()
@ -271,7 +271,7 @@ void VkDescriptorSetManager::CreateFixedSetLayout()
DescriptorSetLayoutBuilder builder;
builder.AddBinding(0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
builder.AddBinding(1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
if (fb->device->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME))
if (fb->GetDevice()->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME))
{
builder.AddBinding(2, VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
}
@ -282,7 +282,7 @@ void VkDescriptorSetManager::CreateFixedSetLayout()
builder.AddBinding(4, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
}
builder.DebugName("VkDescriptorSetManager.FixedSetLayout");
FixedSetLayout = builder.Create(fb->device.get());
FixedSetLayout = builder.Create(fb->GetDevice());
}
void VkDescriptorSetManager::CreateHWBufferPool()
@ -292,14 +292,14 @@ void VkDescriptorSetManager::CreateHWBufferPool()
.AddPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 2 * maxSets)
.MaxSets(maxSets)
.DebugName("VkDescriptorSetManager.HWBufferDescriptorPool")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
void VkDescriptorSetManager::CreateFixedSetPool()
{
DescriptorPoolBuilder poolbuilder;
poolbuilder.AddPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2 * maxSets);
if (fb->device->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME))
if (fb->GetDevice()->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME))
{
poolbuilder.AddPoolSize(VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, 1 * maxSets);
}
@ -309,5 +309,5 @@ void VkDescriptorSetManager::CreateFixedSetPool()
}
poolbuilder.MaxSets(maxSets);
poolbuilder.DebugName("VkDescriptorSetManager.FixedDescriptorPool");
FixedDescriptorPool = poolbuilder.Create(fb->device.get());
FixedDescriptorPool = poolbuilder.Create(fb->GetDevice());
}

View file

@ -34,15 +34,15 @@ CVAR(Bool, vk_exclusivefullscreen, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
VkFramebufferManager::VkFramebufferManager(VulkanRenderDevice* fb) : fb(fb)
{
SwapChain = VulkanSwapChainBuilder()
.Create(fb->device.get());
.Create(fb->GetDevice());
SwapChainImageAvailableSemaphore = SemaphoreBuilder()
.DebugName("SwapChainImageAvailableSemaphore")
.Create(fb->device.get());
.Create(fb->GetDevice());
RenderFinishedSemaphore = SemaphoreBuilder()
.DebugName("RenderFinishedSemaphore")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
VkFramebufferManager::~VkFramebufferManager()

View file

@ -63,7 +63,7 @@ VkRenderPassManager::VkRenderPassManager(VulkanRenderDevice* fb) : fb(fb)
{
}
PipelineCache = builder.Create(fb->device.get());
PipelineCache = builder.Create(fb->GetDevice());
}
VkRenderPassManager::~VkRenderPassManager()
@ -155,7 +155,7 @@ VulkanPipelineLayout* VkRenderPassManager::GetPipelineLayout(int numLayers)
builder.AddSetLayout(descriptors->GetTextureSetLayout(numLayers));
builder.AddPushConstantRange(VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(PushConstants));
builder.DebugName("VkRenderPassManager.PipelineLayout");
layout = builder.Create(fb->device.get());
layout = builder.Create(fb->GetDevice());
return layout.get();
}
@ -222,7 +222,7 @@ std::unique_ptr<VulkanRenderPass> VkRenderPassSetup::CreateRenderPass(int clearT
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT);
}
builder.DebugName("VkRenderPassSetup.RenderPass");
return builder.Create(fb->device.get());
return builder.Create(fb->GetDevice());
}
VulkanRenderPass *VkRenderPassSetup::GetRenderPass(int clearTargets)
@ -303,7 +303,7 @@ std::unique_ptr<VulkanPipeline> VkRenderPassSetup::CreatePipeline(const VkPipeli
builder.Topology(vktopology[key.DrawType]);
builder.DepthStencilEnable(key.DepthTest, key.DepthWrite, key.StencilTest);
builder.DepthFunc(depthfunc2vk[key.DepthFunc]);
if (fb->device->EnabledFeatures.Features.depthClamp)
if (fb->GetDevice()->EnabledFeatures.Features.depthClamp)
builder.DepthClampEnable(key.DepthClamp);
builder.DepthBias(key.DepthBias, 0.0f, 0.0f, 0.0f);
@ -321,7 +321,7 @@ std::unique_ptr<VulkanPipeline> VkRenderPassSetup::CreatePipeline(const VkPipeli
builder.RenderPass(GetRenderPass(0));
builder.DebugName("VkRenderPassSetup.Pipeline");
return builder.Create(fb->device.get());
return builder.Create(fb->GetDevice());
}
/////////////////////////////////////////////////////////////////////////////
@ -346,7 +346,7 @@ void VkPPRenderPassSetup::CreateDescriptorLayout(const VkPPRenderPassKey& key)
builder.AddBinding(LIGHTLIST_BINDINGPOINT, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
}
builder.DebugName("VkPPRenderPassSetup.DescriptorLayout");
DescriptorLayout = builder.Create(fb->device.get());
DescriptorLayout = builder.Create(fb->GetDevice());
}
void VkPPRenderPassSetup::CreatePipelineLayout(const VkPPRenderPassKey& key)
@ -356,7 +356,7 @@ void VkPPRenderPassSetup::CreatePipelineLayout(const VkPPRenderPassKey& key)
if (key.Uniforms > 0)
builder.AddPushConstantRange(VK_SHADER_STAGE_FRAGMENT_BIT, 0, key.Uniforms);
builder.DebugName("VkPPRenderPassSetup.PipelineLayout");
PipelineLayout = builder.Create(fb->device.get());
PipelineLayout = builder.Create(fb->GetDevice());
}
void VkPPRenderPassSetup::CreatePipeline(const VkPPRenderPassKey& key)
@ -386,7 +386,7 @@ void VkPPRenderPassSetup::CreatePipeline(const VkPPRenderPassKey& key)
builder.Layout(PipelineLayout.get());
builder.RenderPass(RenderPass.get());
builder.DebugName("VkPPRenderPassSetup.Pipeline");
Pipeline = builder.Create(fb->device.get());
Pipeline = builder.Create(fb->GetDevice());
}
void VkPPRenderPassSetup::CreateRenderPass(const VkPPRenderPassKey& key)
@ -434,7 +434,7 @@ void VkPPRenderPassSetup::CreateRenderPass(const VkPPRenderPassKey& key)
}
builder.DebugName("VkPPRenderPassSetup.RenderPass");
RenderPass = builder.Create(fb->device.get());
RenderPass = builder.Create(fb->GetDevice());
}
/////////////////////////////////////////////////////////////////////////////

View file

@ -104,7 +104,7 @@ void VkSamplerManager::CreateHWSamplers()
builder.MaxLod(0.25f);
}
builder.DebugName("VkSamplerManager.mSamplers");
mSamplers[i] = builder.Create(fb->device.get());
mSamplers[i] = builder.Create(fb->GetDevice());
}
mSamplers[CLAMP_XY_NOMIP] = SamplerBuilder()
@ -114,7 +114,7 @@ void VkSamplerManager::CreateHWSamplers()
.MipmapMode(VK_SAMPLER_MIPMAP_MODE_NEAREST)
.MaxLod(0.25f)
.DebugName("VkSamplerManager.mSamplers")
.Create(fb->device.get());
.Create(fb->GetDevice());
for (int i = CLAMP_NOFILTER; i <= CLAMP_NOFILTER_XY; i++)
{
@ -125,7 +125,7 @@ void VkSamplerManager::CreateHWSamplers()
.MipmapMode(VK_SAMPLER_MIPMAP_MODE_NEAREST)
.MaxLod(0.25f)
.DebugName("VkSamplerManager.mSamplers")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
// CAMTEX is repeating with texture filter and no mipmap
@ -136,7 +136,7 @@ void VkSamplerManager::CreateHWSamplers()
.MipmapMode(VK_SAMPLER_MIPMAP_MODE_NEAREST)
.MaxLod(0.25f)
.DebugName("VkSamplerManager.mSamplers")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
void VkSamplerManager::DeleteHWSamplers()
@ -161,7 +161,7 @@ VulkanSampler* VkSamplerManager::Get(PPFilterMode filter, PPWrapMode wrap)
.MagFilter(filter == PPFilterMode::Nearest ? VK_FILTER_NEAREST : VK_FILTER_LINEAR)
.AddressMode(wrap == PPWrapMode::Clamp ? VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE : VK_SAMPLER_ADDRESS_MODE_REPEAT)
.DebugName("VkPostprocess.mSamplers")
.Create(fb->device.get());
.Create(fb->GetDevice());
return sampler.get();
}
@ -174,7 +174,7 @@ void VkSamplerManager::CreateShadowmapSampler()
.MagFilter(VK_FILTER_NEAREST)
.AddressMode(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE)
.DebugName("VkRenderBuffers.ShadowmapSampler")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
void VkSamplerManager::CreateLightmapSampler()
@ -185,5 +185,5 @@ void VkSamplerManager::CreateLightmapSampler()
.MagFilter(VK_FILTER_LINEAR)
.AddressMode(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE)
.DebugName("VkRenderBuffers.LightmapSampler")
.Create(fb->device.get());
.Create(fb->GetDevice());
}

View file

@ -39,13 +39,13 @@ VkPPShader::VkPPShader(VulkanRenderDevice* fb, PPShader *shader) : fb(fb)
.Type(ShaderType::Vertex)
.AddSource(shader->VertexShader.GetChars(), LoadShaderCode(shader->VertexShader, "", shader->Version).GetChars())
.DebugName(shader->VertexShader.GetChars())
.Create(shader->VertexShader.GetChars(), fb->device.get());
.Create(shader->VertexShader.GetChars(), fb->GetDevice());
FragmentShader = ShaderBuilder()
.Type(ShaderType::Fragment)
.AddSource(shader->FragmentShader.GetChars(), LoadShaderCode(shader->FragmentShader, prolog, shader->Version).GetChars())
.DebugName(shader->FragmentShader.GetChars())
.Create(shader->FragmentShader.GetChars(), fb->device.get());
.Create(shader->FragmentShader.GetChars(), fb->GetDevice());
fb->GetShaderManager()->AddVkPPShader(this);
}

View file

@ -139,7 +139,7 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadVertShader(FString shadername
#ifdef NPOT_EMULATION
definesBlock << "#define NPOT_EMULATION\n";
#endif
if (!fb->device->EnabledFeatures.Features.shaderClipDistance)
if (!fb->GetDevice()->EnabledFeatures.Features.shaderClipDistance)
{
definesBlock << "#define NO_CLIPDISTANCE_SUPPORT\n";
}
@ -160,19 +160,19 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadVertShader(FString shadername
.AddSource(vert_lump, codeBlock.GetChars())
.OnIncludeLocal([=](std::string headerName, std::string includerName, size_t depth) { return OnInclude(headerName.c_str(), includerName.c_str(), depth, false); })
.OnIncludeSystem([=](std::string headerName, std::string includerName, size_t depth) { return OnInclude(headerName.c_str(), includerName.c_str(), depth, true); })
.Create(shadername.GetChars(), fb->device.get());
.Create(shadername.GetChars(), fb->GetDevice());
}
std::unique_ptr<VulkanShader> VkShaderManager::LoadFragShader(FString shadername, const char *frag_lump, const char *material_lump, const char* mateffect_lump, const char *light_lump, const char *defines, const VkShaderKey& key)
{
FString definesBlock;
if (fb->device->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME)) definesBlock << "\n#define SUPPORTS_RAYQUERY\n";
if (fb->GetDevice()->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME)) definesBlock << "\n#define SUPPORTS_RAYQUERY\n";
definesBlock << defines;
definesBlock << "\n#define MAX_STREAM_DATA " << std::to_string(MAX_STREAM_DATA).c_str() << "\n";
#ifdef NPOT_EMULATION
definesBlock << "#define NPOT_EMULATION\n";
#endif
if (!fb->device->EnabledFeatures.Features.shaderClipDistance) definesBlock << "#define NO_CLIPDISTANCE_SUPPORT\n";
if (!fb->GetDevice()->EnabledFeatures.Features.shaderClipDistance) definesBlock << "#define NO_CLIPDISTANCE_SUPPORT\n";
if (!key.AlphaTest) definesBlock << "#define NO_ALPHATEST\n";
if (key.GBufferPass) definesBlock << "#define GBUFFER_PASS\n";
@ -240,14 +240,14 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadFragShader(FString shadername
.AddSource(frag_lump, codeBlock.GetChars())
.OnIncludeLocal([=](std::string headerName, std::string includerName, size_t depth) { return OnInclude(headerName.c_str(), includerName.c_str(), depth, false); })
.OnIncludeSystem([=](std::string headerName, std::string includerName, size_t depth) { return OnInclude(headerName.c_str(), includerName.c_str(), depth, true); })
.Create(shadername.GetChars(), fb->device.get());
.Create(shadername.GetChars(), fb->GetDevice());
}
FString VkShaderManager::GetVersionBlock()
{
FString versionBlock;
if (fb->device->Instance->ApiVersion >= VK_API_VERSION_1_2)
if (fb->GetDevice()->Instance->ApiVersion >= VK_API_VERSION_1_2)
{
versionBlock << "#version 460 core\n";
}
@ -258,7 +258,7 @@ FString VkShaderManager::GetVersionBlock()
versionBlock << "#extension GL_GOOGLE_include_directive : enable\n";
if (fb->device->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME))
if (fb->GetDevice()->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME))
{
versionBlock << "#extension GL_EXT_ray_query : enable\n";
}

View file

@ -87,14 +87,14 @@ VkTextureImage *VkHardwareTexture::GetDepthStencil(FTexture *tex)
.Format(format)
.Usage(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)
.DebugName("VkHardwareTexture.DepthStencil")
.Create(fb->device.get());
.Create(fb->GetDevice());
mDepthStencil.AspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
mDepthStencil.View = ImageViewBuilder()
.Image(mDepthStencil.Image.get(), format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)
.DebugName("VkHardwareTexture.DepthStencilView")
.Create(fb->device.get());
.Create(fb->GetDevice());
VkImageTransition()
.AddImage(&mDepthStencil, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, true)
@ -122,12 +122,12 @@ void VkHardwareTexture::CreateImage(FTexture *tex, int translation, int flags)
.Size(w, h)
.Usage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT)
.DebugName("VkHardwareTexture.mImage")
.Create(fb->device.get());
.Create(fb->GetDevice());
mImage.View = ImageViewBuilder()
.Image(mImage.Image.get(), format)
.DebugName("VkHardwareTexture.mImageView")
.Create(fb->device.get());
.Create(fb->GetDevice());
VkImageTransition()
.AddImage(&mImage, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, true)
@ -146,7 +146,7 @@ void VkHardwareTexture::CreateTexture(int w, int h, int pixelsize, VkFormat form
.Size(totalSize)
.Usage(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY)
.DebugName("VkHardwareTexture.mStagingBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
uint8_t *data = (uint8_t*)stagingBuffer->Map(0, totalSize);
memcpy(data, pixels, totalSize);
@ -157,12 +157,12 @@ void VkHardwareTexture::CreateTexture(int w, int h, int pixelsize, VkFormat form
.Size(w, h, !mipmap ? 1 : GetMipLevels(w, h))
.Usage(VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT)
.DebugName("VkHardwareTexture.mImage")
.Create(fb->device.get());
.Create(fb->GetDevice());
mImage.View = ImageViewBuilder()
.Image(mImage.Image.get(), format)
.DebugName("VkHardwareTexture.mImageView")
.Create(fb->device.get());
.Create(fb->GetDevice());
auto cmdbuffer = fb->GetCommands()->GetTransferCommands();
@ -219,14 +219,14 @@ void VkHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
.DebugName("VkHardwareTexture.mImage")
.Create(fb->device.get(), &allocatedBytes);
.Create(fb->GetDevice(), &allocatedBytes);
mTexelsize = texelsize;
mImage.View = ImageViewBuilder()
.Image(mImage.Image.get(), format)
.DebugName("VkHardwareTexture.mImageView")
.Create(fb->device.get());
.Create(fb->GetDevice());
VkImageTransition()
.AddImage(&mImage, VK_IMAGE_LAYOUT_GENERAL, true)
@ -260,14 +260,14 @@ void VkHardwareTexture::CreateWipeTexture(int w, int h, const char *name)
.Size(w, h)
.Usage(VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, VMA_MEMORY_USAGE_GPU_ONLY)
.DebugName(name)
.Create(fb->device.get());
.Create(fb->GetDevice());
mTexelsize = 4;
mImage.View = ImageViewBuilder()
.Image(mImage.Image.get(), format)
.DebugName(name)
.Create(fb->device.get());
.Create(fb->GetDevice());
if (fb->GetBuffers()->GetWidth() > 0 && fb->GetBuffers()->GetHeight() > 0)
{
@ -380,7 +380,7 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state)
update.AddCombinedImageSampler(descriptor.get(), i, dummyImage, sampler, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
}
update.Execute(fb->device.get());
update.Execute(fb->GetDevice());
mDescriptorSets.emplace_back(clampmode, translationp, std::move(descriptor));
return mDescriptorSets.back().descriptor.get();
}

View file

@ -47,15 +47,15 @@ VkPPTexture::VkPPTexture(VulkanRenderDevice* fb, PPTexture *texture) : fb(fb)
else
imgbuilder.Usage(VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
imgbuilder.DebugName("VkPPTexture");
if (!imgbuilder.IsFormatSupported(fb->device.get()))
if (!imgbuilder.IsFormatSupported(fb->GetDevice()))
I_FatalError("Vulkan device does not support the image format required by a postprocess texture\n");
TexImage.Image = imgbuilder.Create(fb->device.get());
TexImage.Image = imgbuilder.Create(fb->GetDevice());
Format = format;
TexImage.View = ImageViewBuilder()
.Image(TexImage.Image.get(), format)
.DebugName("VkPPTextureView")
.Create(fb->device.get());
.Create(fb->GetDevice());
if (texture->Data)
{
@ -65,7 +65,7 @@ VkPPTexture::VkPPTexture(VulkanRenderDevice* fb, PPTexture *texture) : fb(fb)
.Size(totalsize)
.Usage(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY)
.DebugName("VkPPTextureStaging")
.Create(fb->device.get());
.Create(fb->GetDevice());
VkImageTransition()
.AddImage(&TexImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, true)

View file

@ -41,7 +41,7 @@ VkRenderBuffers::~VkRenderBuffers()
VkSampleCountFlagBits VkRenderBuffers::GetBestSampleCount()
{
const auto &limits = fb->device->PhysicalDevice.Properties.Properties.limits;
const auto &limits = fb->GetDevice()->PhysicalDevice.Properties.Properties.limits;
VkSampleCountFlags deviceSampleCounts = limits.sampledImageColorSampleCounts & limits.sampledImageDepthSampleCounts & limits.sampledImageStencilSampleCounts;
int requestedSamples = clamp((int)gl_multisample, 0, 64);
@ -90,29 +90,29 @@ void VkRenderBuffers::CreatePipelineDepthStencil(int width, int height)
builder.Size(width, height);
builder.Format(PipelineDepthStencilFormat);
builder.Usage(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
if (!builder.IsFormatSupported(fb->device.get()))
if (!builder.IsFormatSupported(fb->GetDevice()))
{
PipelineDepthStencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
builder.Format(PipelineDepthStencilFormat);
if (!builder.IsFormatSupported(fb->device.get()))
if (!builder.IsFormatSupported(fb->GetDevice()))
{
I_FatalError("This device does not support any of the required depth stencil image formats.");
}
}
builder.DebugName("VkRenderBuffers.PipelineDepthStencil");
PipelineDepthStencil.Image = builder.Create(fb->device.get());
PipelineDepthStencil.Image = builder.Create(fb->GetDevice());
PipelineDepthStencil.AspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
PipelineDepthStencil.View = ImageViewBuilder()
.Image(PipelineDepthStencil.Image.get(), PipelineDepthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)
.DebugName("VkRenderBuffers.PipelineDepthStencilView")
.Create(fb->device.get());
.Create(fb->GetDevice());
PipelineDepthStencil.DepthOnlyView = ImageViewBuilder()
.Image(PipelineDepthStencil.Image.get(), PipelineDepthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT)
.DebugName("VkRenderBuffers.PipelineDepthView")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
void VkRenderBuffers::CreatePipeline(int width, int height)
@ -134,12 +134,12 @@ void VkRenderBuffers::CreatePipeline(int width, int height)
.Format(VK_FORMAT_R16G16B16A16_SFLOAT)
.Usage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT)
.DebugName("VkRenderBuffers.PipelineImage")
.Create(fb->device.get());
.Create(fb->GetDevice());
PipelineImage[i].View = ImageViewBuilder()
.Image(PipelineImage[i].Image.get(), VK_FORMAT_R16G16B16A16_SFLOAT)
.DebugName("VkRenderBuffers.PipelineView")
.Create(fb->device.get());
.Create(fb->GetDevice());
barrier.AddImage(&PipelineImage[i], VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, true);
}
@ -174,12 +174,12 @@ void VkRenderBuffers::CreateSceneColor(int width, int height, VkSampleCountFlagB
.Format(VK_FORMAT_R16G16B16A16_SFLOAT)
.Usage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT)
.DebugName("VkRenderBuffers.SceneColor")
.Create(fb->device.get());
.Create(fb->GetDevice());
SceneColor.View = ImageViewBuilder()
.Image(SceneColor.Image.get(), VK_FORMAT_R16G16B16A16_SFLOAT)
.DebugName("VkRenderBuffers.SceneColorView")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
void VkRenderBuffers::CreateSceneDepthStencil(int width, int height, VkSampleCountFlagBits samples)
@ -189,29 +189,29 @@ void VkRenderBuffers::CreateSceneDepthStencil(int width, int height, VkSampleCou
builder.Samples(samples);
builder.Format(SceneDepthStencilFormat);
builder.Usage(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
if (!builder.IsFormatSupported(fb->device.get()))
if (!builder.IsFormatSupported(fb->GetDevice()))
{
SceneDepthStencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
builder.Format(SceneDepthStencilFormat);
if (!builder.IsFormatSupported(fb->device.get()))
if (!builder.IsFormatSupported(fb->GetDevice()))
{
I_FatalError("This device does not support any of the required depth stencil image formats.");
}
}
builder.DebugName("VkRenderBuffers.SceneDepthStencil");
SceneDepthStencil.Image = builder.Create(fb->device.get());
SceneDepthStencil.Image = builder.Create(fb->GetDevice());
SceneDepthStencil.AspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
SceneDepthStencil.View = ImageViewBuilder()
.Image(SceneDepthStencil.Image.get(), SceneDepthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)
.DebugName("VkRenderBuffers.SceneDepthStencilView")
.Create(fb->device.get());
.Create(fb->GetDevice());
SceneDepthStencil.DepthOnlyView = ImageViewBuilder()
.Image(SceneDepthStencil.Image.get(), SceneDepthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT)
.DebugName("VkRenderBuffers.SceneDepthView")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
void VkRenderBuffers::CreateSceneFog(int width, int height, VkSampleCountFlagBits samples)
@ -222,12 +222,12 @@ void VkRenderBuffers::CreateSceneFog(int width, int height, VkSampleCountFlagBit
.Format(VK_FORMAT_R8G8B8A8_UNORM)
.Usage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT)
.DebugName("VkRenderBuffers.SceneFog")
.Create(fb->device.get());
.Create(fb->GetDevice());
SceneFog.View = ImageViewBuilder()
.Image(SceneFog.Image.get(), VK_FORMAT_R8G8B8A8_UNORM)
.DebugName("VkRenderBuffers.SceneFogView")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
void VkRenderBuffers::CreateSceneNormal(int width, int height, VkSampleCountFlagBits samples)
@ -237,19 +237,19 @@ void VkRenderBuffers::CreateSceneNormal(int width, int height, VkSampleCountFlag
builder.Samples(samples);
builder.Format(SceneNormalFormat);
builder.Usage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
if (!builder.IsFormatSupported(fb->device.get(), VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
if (!builder.IsFormatSupported(fb->GetDevice(), VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
{
SceneNormalFormat = VK_FORMAT_R8G8B8A8_UNORM;
builder.Format(SceneNormalFormat);
}
builder.DebugName("VkRenderBuffers.SceneNormal");
SceneNormal.Image = builder.Create(fb->device.get());
SceneNormal.Image = builder.Create(fb->GetDevice());
SceneNormal.View = ImageViewBuilder()
.Image(SceneNormal.Image.get(), SceneNormalFormat)
.DebugName("VkRenderBuffers.SceneNormalView")
.Create(fb->device.get());
.Create(fb->GetDevice());
}
VulkanFramebuffer* VkRenderBuffers::GetOutput(VkPPRenderPassSetup* passSetup, const PPOutput& output, WhichDepthStencil stencilTest, int& framebufferWidth, int& framebufferHeight)
@ -296,7 +296,7 @@ VulkanFramebuffer* VkRenderBuffers::GetOutput(VkPPRenderPassSetup* passSetup, co
if (stencilTest == WhichDepthStencil::Pipeline)
builder.AddAttachment(fb->GetBuffers()->PipelineDepthStencil.View.get());
builder.DebugName("PPOutputFB");
framebuffer = builder.Create(fb->device.get());
framebuffer = builder.Create(fb->GetDevice());
}
framebufferWidth = w;

View file

@ -148,12 +148,12 @@ void VkTextureManager::CreateNullTexture()
.Size(1, 1)
.Usage(VK_IMAGE_USAGE_SAMPLED_BIT)
.DebugName("VkDescriptorSetManager.NullTexture")
.Create(fb->device.get());
.Create(fb->GetDevice());
NullTextureView = ImageViewBuilder()
.Image(NullTexture.get(), VK_FORMAT_R8G8B8A8_UNORM)
.DebugName("VkDescriptorSetManager.NullTextureView")
.Create(fb->device.get());
.Create(fb->GetDevice());
PipelineBarrier()
.AddImage(NullTexture.get(), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 0, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_ASPECT_COLOR_BIT)
@ -167,12 +167,12 @@ void VkTextureManager::CreateShadowmap()
.Format(VK_FORMAT_R32_SFLOAT)
.Usage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT)
.DebugName("VkRenderBuffers.Shadowmap")
.Create(fb->device.get());
.Create(fb->GetDevice());
Shadowmap.View = ImageViewBuilder()
.Image(Shadowmap.Image.get(), VK_FORMAT_R32_SFLOAT)
.DebugName("VkRenderBuffers.ShadowmapView")
.Create(fb->device.get());
.Create(fb->GetDevice());
VkImageTransition()
.AddImage(&Shadowmap, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, true)
@ -203,13 +203,13 @@ void VkTextureManager::SetLightmap(int LMTextureSize, int LMTextureCount, const
.Format(VK_FORMAT_R16G16B16A16_SFLOAT)
.Usage(VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT)
.DebugName("VkRenderBuffers.Lightmap")
.Create(fb->device.get());
.Create(fb->GetDevice());
Lightmap.View = ImageViewBuilder()
.Type(VK_IMAGE_VIEW_TYPE_2D_ARRAY)
.Image(Lightmap.Image.get(), VK_FORMAT_R16G16B16A16_SFLOAT)
.DebugName("VkRenderBuffers.LightmapView")
.Create(fb->device.get());
.Create(fb->GetDevice());
auto cmdbuffer = fb->GetCommands()->GetTransferCommands();
@ -219,7 +219,7 @@ void VkTextureManager::SetLightmap(int LMTextureSize, int LMTextureCount, const
.Size(totalSize)
.Usage(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY)
.DebugName("VkHardwareTexture.mStagingBuffer")
.Create(fb->device.get());
.Create(fb->GetDevice());
uint16_t one = 0x3c00; // half-float 1.0
const uint16_t* src = LMTextureData.Data();

View file

@ -119,20 +119,19 @@ void VulkanPrintLog(const char* typestr, const std::string& msg)
}
}
VulkanRenderDevice::VulkanRenderDevice(void *hMonitor, bool fullscreen, std::shared_ptr<VulkanSurface> surface) :
Super(hMonitor, fullscreen)
VulkanRenderDevice::VulkanRenderDevice(void *hMonitor, bool fullscreen, std::shared_ptr<VulkanSurface> surface) : SystemBaseFrameBuffer(hMonitor, fullscreen)
{
VulkanDeviceBuilder builder;
builder.OptionalRayQuery();
builder.Surface(surface);
builder.SelectDevice(vk_device);
SupportedDevices = builder.FindDevices(surface->Instance);
device = builder.Create(surface->Instance);
mDevice = builder.Create(surface->Instance);
}
VulkanRenderDevice::~VulkanRenderDevice()
{
vkDeviceWaitIdle(device->device); // make sure the GPU is no longer using any objects before RAII tears them down
vkDeviceWaitIdle(mDevice->device); // make sure the GPU is no longer using any objects before RAII tears them down
delete mVertexData;
delete mSkyData;
@ -163,7 +162,7 @@ void VulkanRenderDevice::InitializeState()
}
// Use the same names here as OpenGL returns.
switch (device->PhysicalDevice.Properties.Properties.vendorID)
switch (mDevice->PhysicalDevice.Properties.Properties.vendorID)
{
case 0x1002: vendorstring = "ATI Technologies Inc."; break;
case 0x10DE: vendorstring = "NVIDIA Corporation"; break;
@ -173,8 +172,8 @@ void VulkanRenderDevice::InitializeState()
hwcaps = RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE;
glslversion = 4.50f;
uniformblockalignment = (unsigned int)device->PhysicalDevice.Properties.Properties.limits.minUniformBufferOffsetAlignment;
maxuniformblock = device->PhysicalDevice.Properties.Properties.limits.maxUniformBufferRange;
uniformblockalignment = (unsigned int)mDevice->PhysicalDevice.Properties.Properties.limits.minUniformBufferOffsetAlignment;
maxuniformblock = mDevice->PhysicalDevice.Properties.Properties.limits.maxUniformBufferRange;
mCommands.reset(new VkCommandBufferManager(this));
@ -228,7 +227,7 @@ void VulkanRenderDevice::Update()
mCommands->WaitForCommands(true);
mCommands->UpdateGpuStats();
Super::Update();
SystemBaseFrameBuffer::Update();
}
bool VulkanRenderDevice::CompileNextShader()
@ -277,7 +276,8 @@ void VulkanRenderDevice::PostProcessScene(bool swscene, int fixedcm, float flash
const char* VulkanRenderDevice::DeviceName() const
{
return device->PhysicalDevice.Properties.Properties.deviceName;
const auto &props = mDevice->PhysicalDevice.Properties;
return props.Properties.deviceName;
}
void VulkanRenderDevice::SetVSync(bool vsync)
@ -390,7 +390,7 @@ void VulkanRenderDevice::CopyScreenToBuffer(int w, int h, uint8_t *data)
.Usage(VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT)
.Size(w, h)
.DebugName("CopyScreenToBuffer")
.Create(device.get());
.Create(mDevice.get());
GetPostprocess()->BlitCurrentToImage(&image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
@ -399,7 +399,7 @@ void VulkanRenderDevice::CopyScreenToBuffer(int w, int h, uint8_t *data)
.Size(w * h * 4)
.Usage(VK_BUFFER_USAGE_TRANSFER_DST_BIT, VMA_MEMORY_USAGE_GPU_TO_CPU)
.DebugName("CopyScreenToBuffer")
.Create(device.get());
.Create(mDevice.get());
// Copy from image to buffer
VkBufferImageCopy region = {};
@ -496,7 +496,7 @@ unsigned int VulkanRenderDevice::GetLightBufferBlockSize() const
void VulkanRenderDevice::PrintStartupLog()
{
const auto &props = device->PhysicalDevice.Properties.Properties;
const auto &props = mDevice->PhysicalDevice.Properties.Properties;
FString deviceType;
switch (props.deviceType)
@ -519,7 +519,7 @@ void VulkanRenderDevice::PrintStartupLog()
Printf("Vulkan version: %s (api) %s (driver)\n", apiVersion.GetChars(), driverVersion.GetChars());
Printf(PRINT_LOG, "Vulkan extensions:");
for (const VkExtensionProperties &p : device->PhysicalDevice.Extensions)
for (const VkExtensionProperties &p : mDevice->PhysicalDevice.Extensions)
{
Printf(PRINT_LOG, " %s", p.extensionName);
}

View file

@ -25,12 +25,11 @@ class SWSceneDrawer;
class VulkanRenderDevice : public SystemBaseFrameBuffer
{
typedef SystemBaseFrameBuffer Super;
public:
std::shared_ptr<VulkanDevice> device;
VulkanRenderDevice(void* hMonitor, bool fullscreen, std::shared_ptr<VulkanSurface> surface);
~VulkanRenderDevice();
VulkanDevice* GetDevice() { return mDevice.get(); }
VkCommandBufferManager* GetCommands() { return mCommands.get(); }
VkShaderManager *GetShaderManager() { return mShaderManager.get(); }
VkSamplerManager *GetSamplerManager() { return mSamplerManager.get(); }
@ -47,8 +46,6 @@ public:
unsigned int GetLightBufferBlockSize() const;
VulkanRenderDevice(void *hMonitor, bool fullscreen, std::shared_ptr<VulkanSurface> surface);
~VulkanRenderDevice();
bool IsVulkan() override { return true; }
void Update() override;
@ -96,6 +93,7 @@ private:
void PrintStartupLog();
void CopyScreenToBuffer(int w, int h, uint8_t *data) override;
std::shared_ptr<VulkanDevice> mDevice;
std::unique_ptr<VkCommandBufferManager> mCommands;
std::unique_ptr<VkBufferManager> mBufferManager;
std::unique_ptr<VkSamplerManager> mSamplerManager;

View file

@ -560,7 +560,7 @@ void VkRenderState::BeginRenderPass(VulkanCommandBuffer *cmdbuffer)
if (key.DepthStencil)
builder.AddAttachment(mRenderTarget.DepthStencil);
builder.DebugName("VkRenderPassSetup.Framebuffer");
framebuffer = builder.Create(fb->device.get());
framebuffer = builder.Create(fb->GetDevice());
}
// Only clear depth+stencil if the render target actually has that