From 298c023b1dc0eae4bb4a2b059dff97739ebe5bad Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Jun 2022 01:22:19 +0200 Subject: [PATCH] Add buffer and texture managers for handling object lifetimes --- src/CMakeLists.txt | 4 ++- .../vulkan/renderer/vk_descriptorset.cpp | 2 +- .../vulkan/renderer/vk_postprocess.cpp | 2 +- .../vulkan/renderer/vk_pprenderstate.cpp | 2 +- .../vulkan/renderer/vk_renderpass.cpp | 2 +- .../vulkan/renderer/vk_renderstate.cpp | 8 ++--- .../vulkan/renderer/vk_renderstate.h | 2 +- .../vulkan/renderer/vk_streambuffer.cpp | 2 +- .../vulkan/renderer/vk_streambuffer.h | 4 +-- .../rendering/vulkan/system/vk_buffer.cpp | 31 ++++++++++++++++++ .../rendering/vulkan/system/vk_buffer.h | 16 ++++++++++ .../vulkan/system/vk_framebuffer.cpp | 17 ++++++---- .../rendering/vulkan/system/vk_framebuffer.h | 20 ++++++++---- .../{vk_buffers.cpp => vk_hwbuffer.cpp} | 32 +++++++++---------- .../system/{vk_buffers.h => vk_hwbuffer.h} | 26 +++++++-------- .../rendering/vulkan/textures/vk_texture.cpp | 31 ++++++++++++++++++ .../rendering/vulkan/textures/vk_texture.h | 16 ++++++++++ 17 files changed, 162 insertions(+), 55 deletions(-) create mode 100644 src/common/rendering/vulkan/system/vk_buffer.cpp create mode 100644 src/common/rendering/vulkan/system/vk_buffer.h rename src/common/rendering/vulkan/system/{vk_buffers.cpp => vk_hwbuffer.cpp} (88%) rename src/common/rendering/vulkan/system/{vk_buffers.h => vk_hwbuffer.h} (61%) create mode 100644 src/common/rendering/vulkan/textures/vk_texture.cpp create mode 100644 src/common/rendering/vulkan/textures/vk_texture.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3079f539e4..bfd31c8cf9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -798,7 +798,8 @@ set (VULKAN_SOURCES common/rendering/vulkan/system/vk_builders.cpp common/rendering/vulkan/system/vk_framebuffer.cpp common/rendering/vulkan/system/vk_commandbuffer.cpp - common/rendering/vulkan/system/vk_buffers.cpp + common/rendering/vulkan/system/vk_hwbuffer.cpp + common/rendering/vulkan/system/vk_buffer.cpp common/rendering/vulkan/renderer/vk_renderstate.cpp common/rendering/vulkan/renderer/vk_renderpass.cpp common/rendering/vulkan/renderer/vk_streambuffer.cpp @@ -813,6 +814,7 @@ set (VULKAN_SOURCES common/rendering/vulkan/textures/vk_pptexture.cpp common/rendering/vulkan/textures/vk_imagetransition.cpp common/rendering/vulkan/textures/vk_renderbuffers.cpp + common/rendering/vulkan/textures/vk_texture.cpp common/rendering/vulkan/thirdparty/volk/volk.c common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp ) diff --git a/src/common/rendering/vulkan/renderer/vk_descriptorset.cpp b/src/common/rendering/vulkan/renderer/vk_descriptorset.cpp index 07f4b98856..8bac0f32b7 100644 --- a/src/common/rendering/vulkan/renderer/vk_descriptorset.cpp +++ b/src/common/rendering/vulkan/renderer/vk_descriptorset.cpp @@ -29,7 +29,7 @@ #include "vulkan/textures/vk_hwtexture.h" #include "vulkan/system/vk_builders.h" #include "vulkan/system/vk_framebuffer.h" -#include "vulkan/system/vk_buffers.h" +#include "vulkan/system/vk_hwbuffer.h" #include "vulkan/system/vk_commandbuffer.h" #include "flatvertices.h" #include "hw_viewpointuniforms.h" diff --git a/src/common/rendering/vulkan/renderer/vk_postprocess.cpp b/src/common/rendering/vulkan/renderer/vk_postprocess.cpp index d75523ad8b..b3f5897784 100644 --- a/src/common/rendering/vulkan/renderer/vk_postprocess.cpp +++ b/src/common/rendering/vulkan/renderer/vk_postprocess.cpp @@ -24,7 +24,7 @@ #include "vulkan/shaders/vk_shader.h" #include "vulkan/system/vk_builders.h" #include "vulkan/system/vk_framebuffer.h" -#include "vulkan/system/vk_buffers.h" +#include "vulkan/system/vk_hwbuffer.h" #include "vulkan/system/vk_swapchain.h" #include "vulkan/system/vk_commandbuffer.h" #include "vulkan/renderer/vk_renderstate.h" diff --git a/src/common/rendering/vulkan/renderer/vk_pprenderstate.cpp b/src/common/rendering/vulkan/renderer/vk_pprenderstate.cpp index b5a4b77a22..78f3477c94 100644 --- a/src/common/rendering/vulkan/renderer/vk_pprenderstate.cpp +++ b/src/common/rendering/vulkan/renderer/vk_pprenderstate.cpp @@ -118,7 +118,7 @@ void VkPPRenderState::RenderScreenQuad(VkPPRenderPassSetup *passSetup, VulkanDes beginInfo.setFramebuffer(framebuffer); beginInfo.addClearColor(0.0f, 0.0f, 0.0f, 1.0f); - VkBuffer vertexBuffers[] = { static_cast(screen->mVertexData->GetBufferObjects().first)->mBuffer->buffer }; + VkBuffer vertexBuffers[] = { static_cast(screen->mVertexData->GetBufferObjects().first)->mBuffer->buffer }; VkDeviceSize offsets[] = { 0 }; cmdbuffer->beginRenderPass(beginInfo); diff --git a/src/common/rendering/vulkan/renderer/vk_renderpass.cpp b/src/common/rendering/vulkan/renderer/vk_renderpass.cpp index 2a3de77315..1233a0131d 100644 --- a/src/common/rendering/vulkan/renderer/vk_renderpass.cpp +++ b/src/common/rendering/vulkan/renderer/vk_renderpass.cpp @@ -30,7 +30,7 @@ #include "vulkan/shaders/vk_ppshader.h" #include "vulkan/system/vk_builders.h" #include "vulkan/system/vk_framebuffer.h" -#include "vulkan/system/vk_buffers.h" +#include "vulkan/system/vk_hwbuffer.h" #include "flatvertices.h" #include "hw_viewpointuniforms.h" #include "v_2ddrawer.h" diff --git a/src/common/rendering/vulkan/renderer/vk_renderstate.cpp b/src/common/rendering/vulkan/renderer/vk_renderstate.cpp index 28ff102df1..60b192eaeb 100644 --- a/src/common/rendering/vulkan/renderer/vk_renderstate.cpp +++ b/src/common/rendering/vulkan/renderer/vk_renderstate.cpp @@ -218,7 +218,7 @@ void VkRenderState::ApplyRenderPass(int dt) // Find a pipeline that matches our state VkPipelineKey pipelineKey; pipelineKey.DrawType = dt; - pipelineKey.VertexFormat = static_cast(mVertexBuffer)->VertexFormat; + pipelineKey.VertexFormat = static_cast(mVertexBuffer)->VertexFormat; pipelineKey.RenderStyle = mRenderStyle; pipelineKey.DepthTest = mDepthTest; pipelineKey.DepthWrite = mDepthTest && mDepthWrite; @@ -342,7 +342,7 @@ void VkRenderState::ApplyStreamData() { auto passManager = fb->GetRenderPassManager(); - mStreamData.useVertexData = passManager->GetVertexFormat(static_cast(mVertexBuffer)->VertexFormat)->UseVertexData; + mStreamData.useVertexData = passManager->GetVertexFormat(static_cast(mVertexBuffer)->VertexFormat)->UseVertexData; if (mMaterial.mMaterial && mMaterial.mMaterial->Source()) mStreamData.timer = static_cast((double)(screen->FrameTime - firstFrame) * (double)mMaterial.mMaterial->Source()->GetShaderSpeed() / 1000.); @@ -414,7 +414,7 @@ void VkRenderState::ApplyVertexBuffers() { if ((mVertexBuffer != mLastVertexBuffer || mVertexOffsets[0] != mLastVertexOffsets[0] || mVertexOffsets[1] != mLastVertexOffsets[1]) && mVertexBuffer) { - auto vkbuf = static_cast(mVertexBuffer); + auto vkbuf = static_cast(mVertexBuffer); const VkVertexFormat *format = fb->GetRenderPassManager()->GetVertexFormat(vkbuf->VertexFormat); VkBuffer vertexBuffers[2] = { vkbuf->mBuffer->buffer, vkbuf->mBuffer->buffer }; VkDeviceSize offsets[] = { mVertexOffsets[0] * format->Stride, mVertexOffsets[1] * format->Stride }; @@ -426,7 +426,7 @@ void VkRenderState::ApplyVertexBuffers() if (mIndexBuffer != mLastIndexBuffer && mIndexBuffer) { - mCommandBuffer->bindIndexBuffer(static_cast(mIndexBuffer)->mBuffer->buffer, 0, VK_INDEX_TYPE_UINT32); + mCommandBuffer->bindIndexBuffer(static_cast(mIndexBuffer)->mBuffer->buffer, 0, VK_INDEX_TYPE_UINT32); mLastIndexBuffer = mIndexBuffer; } } diff --git a/src/common/rendering/vulkan/renderer/vk_renderstate.h b/src/common/rendering/vulkan/renderer/vk_renderstate.h index bdf4100e43..d6940393a2 100644 --- a/src/common/rendering/vulkan/renderer/vk_renderstate.h +++ b/src/common/rendering/vulkan/renderer/vk_renderstate.h @@ -1,7 +1,7 @@ #pragma once -#include "vulkan/system/vk_buffers.h" +#include "vulkan/system/vk_hwbuffer.h" #include "vulkan/shaders/vk_shader.h" #include "vulkan/renderer/vk_renderpass.h" #include "vulkan/renderer/vk_streambuffer.h" diff --git a/src/common/rendering/vulkan/renderer/vk_streambuffer.cpp b/src/common/rendering/vulkan/renderer/vk_streambuffer.cpp index 48b2b87439..4bd1f86f10 100644 --- a/src/common/rendering/vulkan/renderer/vk_streambuffer.cpp +++ b/src/common/rendering/vulkan/renderer/vk_streambuffer.cpp @@ -29,7 +29,7 @@ VkStreamBuffer::VkStreamBuffer(VulkanFrameBuffer* fb, size_t structSize, size_t { mBlockSize = static_cast((structSize + screen->uniformblockalignment - 1) / screen->uniformblockalignment * screen->uniformblockalignment); - UniformBuffer = (VKDataBuffer*)fb->CreateDataBuffer(-1, false, false); + UniformBuffer = (VkHardwareDataBuffer*)fb->CreateDataBuffer(-1, false, false); UniformBuffer->SetData(mBlockSize * count, nullptr, BufferUsageType::Persistent); } diff --git a/src/common/rendering/vulkan/renderer/vk_streambuffer.h b/src/common/rendering/vulkan/renderer/vk_streambuffer.h index 0c4093ca11..2cb21bbb6d 100644 --- a/src/common/rendering/vulkan/renderer/vk_streambuffer.h +++ b/src/common/rendering/vulkan/renderer/vk_streambuffer.h @@ -1,7 +1,7 @@ #pragma once -#include "vulkan/system/vk_buffers.h" +#include "vulkan/system/vk_hwbuffer.h" #include "vulkan/shaders/vk_shader.h" class VkStreamBuffer; @@ -50,7 +50,7 @@ public: uint32_t NextStreamDataBlock(); void Reset() { mStreamDataOffset = 0; } - VKDataBuffer* UniformBuffer = nullptr; + VkHardwareDataBuffer* UniformBuffer = nullptr; private: uint32_t mBlockSize = 0; diff --git a/src/common/rendering/vulkan/system/vk_buffer.cpp b/src/common/rendering/vulkan/system/vk_buffer.cpp new file mode 100644 index 0000000000..90b18dd61d --- /dev/null +++ b/src/common/rendering/vulkan/system/vk_buffer.cpp @@ -0,0 +1,31 @@ +/* +** Vulkan backend +** Copyright (c) 2016-2020 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include "vk_buffer.h" + +VkBufferManager::VkBufferManager(VulkanFrameBuffer* fb) : fb(fb) +{ +} + +VkBufferManager::~VkBufferManager() +{ +} diff --git a/src/common/rendering/vulkan/system/vk_buffer.h b/src/common/rendering/vulkan/system/vk_buffer.h new file mode 100644 index 0000000000..ccf751c6a2 --- /dev/null +++ b/src/common/rendering/vulkan/system/vk_buffer.h @@ -0,0 +1,16 @@ + +#pragma once + +#include "vulkan/system/vk_objects.h" + +class VulkanFrameBuffer; + +class VkBufferManager +{ +public: + VkBufferManager(VulkanFrameBuffer* fb); + ~VkBufferManager(); + +private: + VulkanFrameBuffer* fb = nullptr; +}; diff --git a/src/common/rendering/vulkan/system/vk_framebuffer.cpp b/src/common/rendering/vulkan/system/vk_framebuffer.cpp index a803cb6cf8..052a1f7f29 100644 --- a/src/common/rendering/vulkan/system/vk_framebuffer.cpp +++ b/src/common/rendering/vulkan/system/vk_framebuffer.cpp @@ -43,7 +43,7 @@ #include "hw_lightbuffer.h" #include "vk_framebuffer.h" -#include "vk_buffers.h" +#include "vk_hwbuffer.h" #include "vulkan/renderer/vk_renderstate.h" #include "vulkan/renderer/vk_renderpass.h" #include "vulkan/renderer/vk_descriptorset.h" @@ -54,9 +54,11 @@ #include "vulkan/textures/vk_renderbuffers.h" #include "vulkan/textures/vk_samplers.h" #include "vulkan/textures/vk_hwtexture.h" +#include "vulkan/textures/vk_texture.h" #include "vulkan/system/vk_builders.h" #include "vulkan/system/vk_swapchain.h" #include "vulkan/system/vk_commandbuffer.h" +#include "vulkan/system/vk_buffer.h" #include "engineerrors.h" #include "c_dispatch.h" @@ -85,7 +87,7 @@ VulkanFrameBuffer::~VulkanFrameBuffer() // All descriptors must be destroyed before the descriptor pool in renderpass manager is destroyed VkHardwareTexture::ResetAll(); - VKBuffer::ResetAll(); + VkHardwareBuffer::ResetAll(); PPResource::ResetAll(); delete MatrixBuffer; @@ -124,6 +126,10 @@ void VulkanFrameBuffer::InitializeState() mCommands.reset(new VkCommandBufferManager(this)); + mSamplerManager.reset(new VkSamplerManager(this)); + mTextureManager.reset(new VkTextureManager(this)); + mBufferManager.reset(new VkBufferManager(this)); + mScreenBuffers.reset(new VkRenderBuffers(this)); mSaveBuffers.reset(new VkRenderBuffers(this)); mActiveRenderBuffers = mScreenBuffers.get(); @@ -145,7 +151,6 @@ void VulkanFrameBuffer::InitializeState() StreamBuffer = new VkStreamBuffer(this, sizeof(StreamUBO), 300); mShaderManager.reset(new VkShaderManager(device)); - mSamplerManager.reset(new VkSamplerManager(this)); mDescriptorSetManager->Init(); #ifdef __APPLE__ mRenderState.reset(new VkRenderStateMolten(this)); @@ -263,17 +268,17 @@ FMaterial* VulkanFrameBuffer::CreateMaterial(FGameTexture* tex, int scaleflags) IVertexBuffer *VulkanFrameBuffer::CreateVertexBuffer() { - return new VKVertexBuffer(); + return new VkHardwareVertexBuffer(); } IIndexBuffer *VulkanFrameBuffer::CreateIndexBuffer() { - return new VKIndexBuffer(); + return new VkHardwareIndexBuffer(); } IDataBuffer *VulkanFrameBuffer::CreateDataBuffer(int bindingpoint, bool ssbo, bool needsresize) { - auto buffer = new VKDataBuffer(bindingpoint, ssbo, needsresize); + auto buffer = new VkHardwareDataBuffer(bindingpoint, ssbo, needsresize); switch (bindingpoint) { diff --git a/src/common/rendering/vulkan/system/vk_framebuffer.h b/src/common/rendering/vulkan/system/vk_framebuffer.h index 5e58d58766..2729b1f578 100644 --- a/src/common/rendering/vulkan/system/vk_framebuffer.h +++ b/src/common/rendering/vulkan/system/vk_framebuffer.h @@ -6,6 +6,8 @@ struct FRenderViewpoint; class VkSamplerManager; +class VkBufferManager; +class VkTextureManager; class VkShaderManager; class VkCommandBufferManager; class VkDescriptorSetManager; @@ -13,7 +15,7 @@ class VkRenderPassManager; class VkRaytrace; class VkRenderState; class VkStreamBuffer; -class VKDataBuffer; +class VkHardwareDataBuffer; class VkHardwareTexture; class VkRenderBuffers; class VkPostprocess; @@ -30,6 +32,8 @@ public: VkCommandBufferManager* GetCommands() { return mCommands.get(); } VkShaderManager *GetShaderManager() { return mShaderManager.get(); } VkSamplerManager *GetSamplerManager() { return mSamplerManager.get(); } + VkBufferManager* GetBufferManager() { return mBufferManager.get(); } + VkTextureManager* GetTextureManager() { return mTextureManager.get(); } VkDescriptorSetManager* GetDescriptorSetManager() { return mDescriptorSetManager.get(); } VkRenderPassManager *GetRenderPassManager() { return mRenderPassManager.get(); } VkRaytrace* GetRaytrace() { return mRaytrace.get(); } @@ -40,14 +44,14 @@ public: unsigned int GetLightBufferBlockSize() const; - VKDataBuffer *ViewpointUBO = nullptr; - VKDataBuffer *LightBufferSSO = nullptr; + VkHardwareDataBuffer *ViewpointUBO = nullptr; + VkHardwareDataBuffer *LightBufferSSO = nullptr; VkStreamBuffer *MatrixBuffer = nullptr; VkStreamBuffer *StreamBuffer = nullptr; - VKDataBuffer *LightNodes = nullptr; - VKDataBuffer *LightLines = nullptr; - VKDataBuffer *LightList = nullptr; + VkHardwareDataBuffer *LightNodes = nullptr; + VkHardwareDataBuffer *LightLines = nullptr; + VkHardwareDataBuffer *LightList = nullptr; std::unique_ptr FanToTrisIndexBuffer; @@ -102,8 +106,10 @@ private: void CopyScreenToBuffer(int w, int h, uint8_t *data) override; std::unique_ptr mCommands; - std::unique_ptr mShaderManager; + std::unique_ptr mBufferManager; std::unique_ptr mSamplerManager; + std::unique_ptr mTextureManager; + std::unique_ptr mShaderManager; std::unique_ptr mScreenBuffers; std::unique_ptr mSaveBuffers; std::unique_ptr mPostprocess; diff --git a/src/common/rendering/vulkan/system/vk_buffers.cpp b/src/common/rendering/vulkan/system/vk_hwbuffer.cpp similarity index 88% rename from src/common/rendering/vulkan/system/vk_buffers.cpp rename to src/common/rendering/vulkan/system/vk_hwbuffer.cpp index 0c6a52dcff..c388e9b366 100644 --- a/src/common/rendering/vulkan/system/vk_buffers.cpp +++ b/src/common/rendering/vulkan/system/vk_hwbuffer.cpp @@ -20,7 +20,7 @@ ** */ -#include "vk_buffers.h" +#include "vk_hwbuffer.h" #include "vk_builders.h" #include "vk_framebuffer.h" #include "vk_commandbuffer.h" @@ -28,16 +28,16 @@ #include "vulkan/renderer/vk_descriptorset.h" #include "engineerrors.h" -VKBuffer *VKBuffer::First = nullptr; +VkHardwareBuffer *VkHardwareBuffer::First = nullptr; -VKBuffer::VKBuffer() +VkHardwareBuffer::VkHardwareBuffer() { Next = First; First = this; if (Next) Next->Prev = this; } -VKBuffer::~VKBuffer() +VkHardwareBuffer::~VkHardwareBuffer() { if (Next) Next->Prev = Prev; if (Prev) Prev->Next = Next; @@ -56,13 +56,13 @@ VKBuffer::~VKBuffer() } } -void VKBuffer::ResetAll() +void VkHardwareBuffer::ResetAll() { - for (VKBuffer *cur = VKBuffer::First; cur; cur = cur->Next) + for (VkHardwareBuffer *cur = VkHardwareBuffer::First; cur; cur = cur->Next) cur->Reset(); } -void VKBuffer::Reset() +void VkHardwareBuffer::Reset() { if (mBuffer && map) mBuffer->Unmap(); @@ -70,7 +70,7 @@ void VKBuffer::Reset() mStaging.reset(); } -void VKBuffer::SetData(size_t size, const void *data, BufferUsageType usage) +void VkHardwareBuffer::SetData(size_t size, const void *data, BufferUsageType usage) { auto fb = GetVulkanFrameBuffer(); @@ -152,7 +152,7 @@ void VKBuffer::SetData(size_t size, const void *data, BufferUsageType usage) buffersize = size; } -void VKBuffer::SetSubData(size_t offset, size_t size, const void *data) +void VkHardwareBuffer::SetSubData(size_t offset, size_t size, const void *data) { size = max(size, (size_t)16); // For supporting zero byte buffers @@ -173,7 +173,7 @@ void VKBuffer::SetSubData(size_t offset, size_t size, const void *data) } } -void VKBuffer::Resize(size_t newsize) +void VkHardwareBuffer::Resize(size_t newsize) { newsize = max(newsize, (size_t)16); // For supporting zero byte buffers @@ -204,13 +204,13 @@ void VKBuffer::Resize(size_t newsize) map = mBuffer->Map(0, newsize); } -void VKBuffer::Map() +void VkHardwareBuffer::Map() { if (!mPersistent) map = mBuffer->Map(0, mBuffer->size); } -void VKBuffer::Unmap() +void VkHardwareBuffer::Unmap() { if (!mPersistent) { @@ -219,7 +219,7 @@ void VKBuffer::Unmap() } } -void *VKBuffer::Lock(unsigned int size) +void *VkHardwareBuffer::Lock(unsigned int size) { size = max(size, (unsigned int)16); // For supporting zero byte buffers @@ -237,7 +237,7 @@ void *VKBuffer::Lock(unsigned int size) return map; } -void VKBuffer::Unlock() +void VkHardwareBuffer::Unlock() { if (!mBuffer) { @@ -254,7 +254,7 @@ void VKBuffer::Unlock() ///////////////////////////////////////////////////////////////////////////// -void VKVertexBuffer::SetFormat(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute *attrs) +void VkHardwareVertexBuffer::SetFormat(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute *attrs) { VertexFormat = GetVulkanFrameBuffer()->GetRenderPassManager()->GetVertexFormat(numBindingPoints, numAttributes, stride, attrs); } @@ -262,7 +262,7 @@ void VKVertexBuffer::SetFormat(int numBindingPoints, int numAttributes, size_t s ///////////////////////////////////////////////////////////////////////////// -void VKDataBuffer::BindRange(FRenderState* state, size_t start, size_t length) +void VkHardwareDataBuffer::BindRange(FRenderState* state, size_t start, size_t length) { static_cast(state)->Bind(bindingpoint, (uint32_t)start); } diff --git a/src/common/rendering/vulkan/system/vk_buffers.h b/src/common/rendering/vulkan/system/vk_hwbuffer.h similarity index 61% rename from src/common/rendering/vulkan/system/vk_buffers.h rename to src/common/rendering/vulkan/system/vk_hwbuffer.h index 78f8501480..33a4c79335 100644 --- a/src/common/rendering/vulkan/system/vk_buffers.h +++ b/src/common/rendering/vulkan/system/vk_hwbuffer.h @@ -5,16 +5,16 @@ #include "tarray.h" #ifdef _MSC_VER -// silence bogus warning C4250: 'VKVertexBuffer': inherits 'VKBuffer::VKBuffer::SetData' via dominance +// silence bogus warning C4250: 'VkHardwareVertexBuffer': inherits 'VkHardwareBuffer::VkHardwareBuffer::SetData' via dominance // According to internet infos, the warning is erroneously emitted in this case. #pragma warning(disable:4250) #endif -class VKBuffer : virtual public IBuffer +class VkHardwareBuffer : virtual public IBuffer { public: - VKBuffer(); - ~VKBuffer(); + VkHardwareBuffer(); + ~VkHardwareBuffer(); static void ResetAll(); void Reset(); @@ -36,30 +36,30 @@ public: TArray mStaticUpload; private: - static VKBuffer *First; - VKBuffer *Prev = nullptr; - VKBuffer *Next = nullptr; + static VkHardwareBuffer *First; + VkHardwareBuffer *Prev = nullptr; + VkHardwareBuffer *Next = nullptr; }; -class VKVertexBuffer : public IVertexBuffer, public VKBuffer +class VkHardwareVertexBuffer : public IVertexBuffer, public VkHardwareBuffer { public: - VKVertexBuffer() { mBufferType = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; } + VkHardwareVertexBuffer() { mBufferType = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; } void SetFormat(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute *attrs) override; int VertexFormat = -1; }; -class VKIndexBuffer : public IIndexBuffer, public VKBuffer +class VkHardwareIndexBuffer : public IIndexBuffer, public VkHardwareBuffer { public: - VKIndexBuffer() { mBufferType = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; } + VkHardwareIndexBuffer() { mBufferType = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; } }; -class VKDataBuffer : public IDataBuffer, public VKBuffer +class VkHardwareDataBuffer : public IDataBuffer, public VkHardwareBuffer { public: - VKDataBuffer(int bindingpoint, bool ssbo, bool needresize) : bindingpoint(bindingpoint) + VkHardwareDataBuffer(int bindingpoint, bool ssbo, bool needresize) : bindingpoint(bindingpoint) { mBufferType = ssbo ? VK_BUFFER_USAGE_STORAGE_BUFFER_BIT : VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; if (needresize) diff --git a/src/common/rendering/vulkan/textures/vk_texture.cpp b/src/common/rendering/vulkan/textures/vk_texture.cpp new file mode 100644 index 0000000000..0d485b6627 --- /dev/null +++ b/src/common/rendering/vulkan/textures/vk_texture.cpp @@ -0,0 +1,31 @@ +/* +** Vulkan backend +** Copyright (c) 2016-2020 Magnus Norddahl +** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#include "vk_texture.h" + +VkTextureManager::VkTextureManager(VulkanFrameBuffer* fb) : fb(fb) +{ +} + +VkTextureManager::~VkTextureManager() +{ +} diff --git a/src/common/rendering/vulkan/textures/vk_texture.h b/src/common/rendering/vulkan/textures/vk_texture.h new file mode 100644 index 0000000000..a5e716b946 --- /dev/null +++ b/src/common/rendering/vulkan/textures/vk_texture.h @@ -0,0 +1,16 @@ + +#pragma once + +#include "vulkan/system/vk_objects.h" + +class VulkanFrameBuffer; + +class VkTextureManager +{ +public: + VkTextureManager(VulkanFrameBuffer* fb); + ~VkTextureManager(); + +private: + VulkanFrameBuffer* fb = nullptr; +};