diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-02-09 01:28:02 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-02-09 01:28:02 +0000 |
| commit | 26a81f5d5aef3e8d367c7e91870becce7c21e1f9 (patch) | |
| tree | 47a80be0a9f5d26ac632785825aa0b6dc524a6a6 /Graphics/GraphicsEngineVulkan | |
| parent | Defined constructos to fix build errors on Apple's clang (diff) | |
| download | DiligentCore-26a81f5d5aef3e8d367c7e91870becce7c21e1f9.tar.gz DiligentCore-26a81f5d5aef3e8d367c7e91870becce7c21e1f9.zip | |
Updated IRenderDevice::CreateTexture and IRenderDevice::CreateBuffer to take pointers to initial data rather than references
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
10 files changed, 29 insertions, 29 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h index 7e702a0c..f3d1784b 100644 --- a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h @@ -53,7 +53,7 @@ public: FixedBlockMemoryAllocator& BuffViewObjMemAllocator, RenderDeviceVkImpl* pDeviceVk, const BufferDesc& BuffDesc, - const BufferData& BuffData = BufferData()); + const BufferData* pBuffData = nullptr); BufferVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h index 9ec268f3..64410774 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h @@ -70,11 +70,11 @@ public: virtual void CreatePipelineState( const PipelineStateDesc &PipelineDesc, IPipelineState** ppPipelineState )override final; - virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer** ppBuffer)override final; + virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer** ppBuffer)override final; virtual void CreateShader(const ShaderCreationAttribs& ShaderCreationAttribs, IShader** ppShader)override final; - virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture** ppTexture)override final; + virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture** ppTexture)override final; void CreateTexture(const TextureDesc& TexDesc, VkImage vkImgHandle, RESOURCE_STATE InitialState, class TextureVkImpl** ppTexture); diff --git a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h index 00f02fe2..4d040a0e 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h @@ -50,7 +50,7 @@ public: FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceVkImpl* pDeviceVk, const TextureDesc& TexDesc, - const TextureData& InitData = TextureData()); + const TextureData* pInitData = nullptr); // Attaches to an existing Vk resource TextureVkImpl(IReferenceCounters* pRefCounters, diff --git a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp index 1876d6b2..faeff985 100644 --- a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp @@ -40,16 +40,16 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, RenderDeviceVkImpl* pRenderDeviceVk, const BufferDesc& BuffDesc, - const BufferData& BuffData /*= BufferData()*/) : + const BufferData* pBuffData /*= nullptr*/) : TBufferBase(pRefCounters, BuffViewObjMemAllocator, pRenderDeviceVk, BuffDesc, false), m_DynamicAllocations(STD_ALLOCATOR_RAW_MEM(VulkanDynamicAllocation, GetRawAllocator(), "Allocator for vector<VulkanDynamicAllocation>")) { #define LOG_BUFFER_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Buffer \"", BuffDesc.Name ? BuffDesc.Name : "", "\": ", ##__VA_ARGS__); - if( m_Desc.Usage == USAGE_STATIC && BuffData.pData == nullptr ) + if( m_Desc.Usage == USAGE_STATIC && (pBuffData == nullptr || pBuffData->pData == nullptr) ) LOG_BUFFER_ERROR_AND_THROW("Static buffer must be initialized with data at creation time") - if( m_Desc.Usage == USAGE_DYNAMIC && BuffData.pData != nullptr ) + if( m_Desc.Usage == USAGE_DYNAMIC && pBuffData != nullptr && pBuffData->pData != nullptr ) LOG_BUFFER_ERROR_AND_THROW("Dynamic buffer must be initialized via Map()") if (m_Desc.Usage == USAGE_CPU_ACCESSIBLE) @@ -59,7 +59,7 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters, if (m_Desc.CPUAccessFlags == CPU_ACCESS_WRITE) { - if(BuffData.pData != nullptr ) + if (pBuffData != nullptr ) LOG_BUFFER_ERROR_AND_THROW("CPU-writable staging buffers must be updated via map") } } @@ -185,7 +185,7 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters, auto err = LogicalDevice.BindBufferMemory(m_VulkanBuffer, Memory, AlignedOffset); CHECK_VK_ERROR_AND_THROW(err, "Failed to bind buffer memory"); - bool bInitializeBuffer = (BuffData.pData != nullptr && BuffData.DataSize > 0); + bool bInitializeBuffer = (pBuffData != nullptr && pBuffData->pData != nullptr && pBuffData->DataSize > 0); RESOURCE_STATE InitialState = RESOURCE_STATE_UNDEFINED; if( bInitializeBuffer ) { @@ -211,7 +211,7 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters, auto* StagingData = reinterpret_cast<uint8_t*>(StagingMemoryAllocation.Page->GetCPUMemory()); if (StagingData == nullptr) LOG_BUFFER_ERROR_AND_THROW("Failed to allocate staging data"); - memcpy(StagingData + AlignedStagingMemOffset, BuffData.pData, BuffData.DataSize); + memcpy(StagingData + AlignedStagingMemOffset, pBuffData->pData, pBuffData->DataSize); err = LogicalDevice.BindBufferMemory(StagingBuffer, StagingBufferMemory, AlignedStagingMemOffset); CHECK_VK_ERROR_AND_THROW(err, "Failed to bind staging bufer memory"); diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index d2e2326a..42ea4022 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -98,7 +98,7 @@ namespace Diligent DummyVBDesc.Usage = USAGE_DEFAULT; DummyVBDesc.uiSizeInBytes = 32; RefCntAutoPtr<IBuffer> pDummyVB; - m_pDevice->CreateBuffer(DummyVBDesc, BufferData{}, &pDummyVB); + m_pDevice->CreateBuffer(DummyVBDesc, nullptr, &pDummyVB); m_DummyVB = pDummyVB.RawPtr<BufferVkImpl>(); } diff --git a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp index 54e64aab..fc9af5a8 100644 --- a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp +++ b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp @@ -171,7 +171,7 @@ namespace Diligent ConstantsCBDesc.Usage = USAGE_DYNAMIC; ConstantsCBDesc.CPUAccessFlags = CPU_ACCESS_WRITE; ConstantsCBDesc.uiSizeInBytes = 32; - DeviceVkImpl.CreateBuffer(ConstantsCBDesc, BufferData(), &m_ConstantsCB); + DeviceVkImpl.CreateBuffer(ConstantsCBDesc, nullptr, &m_ConstantsCB); FindPSOs(TEX_FORMAT_RGBA8_UNORM); FindPSOs(TEX_FORMAT_BGRA8_UNORM); diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index 05edf7a2..dbf2893f 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -419,12 +419,12 @@ void RenderDeviceVkImpl :: CreateBufferFromVulkanResource(VkBuffer vkBuffer, con } -void RenderDeviceVkImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData &BuffData, IBuffer **ppBuffer) +void RenderDeviceVkImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer **ppBuffer) { CreateDeviceObject("buffer", BuffDesc, ppBuffer, [&]() { - BufferVkImpl* pBufferVk( NEW_RC_OBJ(m_BufObjAllocator, "BufferVkImpl instance", BufferVkImpl)(m_BuffViewObjAllocator, this, BuffDesc, BuffData ) ); + BufferVkImpl* pBufferVk( NEW_RC_OBJ(m_BufObjAllocator, "BufferVkImpl instance", BufferVkImpl)(m_BuffViewObjAllocator, this, BuffDesc, pBuffData ) ); pBufferVk->QueryInterface( IID_Buffer, reinterpret_cast<IObject**>(ppBuffer) ); pBufferVk->CreateDefaultViews(); OnCreateDeviceObject( pBufferVk ); @@ -474,12 +474,12 @@ void RenderDeviceVkImpl::CreateTexture(const TextureDesc& TexDesc, VkImage vkImg } -void RenderDeviceVkImpl :: CreateTexture(const TextureDesc& TexDesc, const TextureData &Data, ITexture **ppTexture) +void RenderDeviceVkImpl :: CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture **ppTexture) { CreateDeviceObject( "texture", TexDesc, ppTexture, [&]() { - TextureVkImpl* pTextureVk = NEW_RC_OBJ(m_TexObjAllocator, "TextureVkImpl instance", TextureVkImpl)(m_TexViewObjAllocator, this, TexDesc, Data ); + TextureVkImpl* pTextureVk = NEW_RC_OBJ(m_TexObjAllocator, "TextureVkImpl instance", TextureVkImpl)(m_TexViewObjAllocator, this, TexDesc, pData ); pTextureVk->QueryInterface( IID_Texture, reinterpret_cast<IObject**>(ppTexture) ); pTextureVk->CreateDefaultViews(); diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp index f3837886..27743a2e 100644 --- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp @@ -396,7 +396,7 @@ void SwapChainVkImpl::InitBuffersAndViews() DepthBufferDesc.ClearValue.DepthStencil.Stencil = m_SwapChainDesc.DefaultStencilValue; DepthBufferDesc.Name = "Main depth buffer"; RefCntAutoPtr<ITexture> pDepthBufferTex; - m_pRenderDevice->CreateTexture(DepthBufferDesc, TextureData(), static_cast<ITexture**>(&pDepthBufferTex) ); + m_pRenderDevice->CreateTexture(DepthBufferDesc, nullptr, static_cast<ITexture**>(&pDepthBufferTex) ); auto pDSV = pDepthBufferTex->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); m_pDepthBufferDSV = RefCntAutoPtr<ITextureViewVk>(pDSV, IID_TextureViewVk); } diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index 82d461d1..71cf5ae8 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -40,11 +40,11 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceVkImpl* pRenderDeviceVk, const TextureDesc& TexDesc, - const TextureData& InitData /*= TextureData()*/) : + const TextureData* pInitData /*= nullptr*/) : TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceVk, TexDesc) { - if( m_Desc.Usage == USAGE_STATIC && InitData.pSubResources == nullptr ) - LOG_ERROR_AND_THROW("Static Texture must be initialized with data at creation time"); + if( m_Desc.Usage == USAGE_STATIC && (pInitData == nullptr || pInitData->pSubResources == nullptr) ) + LOG_ERROR_AND_THROW("Static textures must be initialized with data at creation time"); const auto& LogicalDevice = pRenderDeviceVk->GetLogicalDevice(); @@ -139,7 +139,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, // and the transition away from this layout is not guaranteed to preserve that data. ImageCI.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - bool bInitializeTexture = (InitData.pSubResources != nullptr && InitData.NumSubresources > 0); + bool bInitializeTexture = (pInitData != nullptr && pInitData->pSubResources != nullptr && pInitData->NumSubresources > 0); m_VulkanImage = LogicalDevice.CreateImage(ImageCI, m_Desc.Name); @@ -197,10 +197,10 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, if(bInitializeTexture) { Uint32 ExpectedNumSubresources = ImageCI.mipLevels * ImageCI.arrayLayers; - if( InitData.NumSubresources != ExpectedNumSubresources ) - LOG_ERROR_AND_THROW("Incorrect number of subresources in init data. ", ExpectedNumSubresources, " expected, while ", InitData.NumSubresources, " provided"); + if (pInitData->NumSubresources != ExpectedNumSubresources ) + LOG_ERROR_AND_THROW("Incorrect number of subresources in init data. ", ExpectedNumSubresources, " expected, while ", pInitData->NumSubresources, " provided"); - std::vector<VkBufferImageCopy> Regions(InitData.NumSubresources); + std::vector<VkBufferImageCopy> Regions(pInitData->NumSubresources); Uint64 uploadBufferSize = 0; Uint32 subres = 0; @@ -208,7 +208,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, { for(Uint32 mip = 0; mip < ImageCI.mipLevels; ++mip) { - const auto& SubResData = InitData.pSubResources[subres]; (void)SubResData; + const auto& SubResData = pInitData->pSubResources[subres]; (void)SubResData; auto& CopyRegion = Regions[subres]; auto MipWidth = std::max(m_Desc.Width >> mip, 1u); @@ -255,7 +255,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, ++subres; } } - VERIFY_EXPR(subres == InitData.NumSubresources); + VERIFY_EXPR(subres == pInitData->NumSubresources); VkBufferCreateInfo VkStaginBuffCI = {}; VkStaginBuffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; @@ -291,7 +291,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, { for(Uint32 mip = 0; mip < ImageCI.mipLevels; ++mip) { - const auto &SubResData = InitData.pSubResources[subres]; + const auto &SubResData = pInitData->pSubResources[subres]; const auto &CopyRegion = Regions[subres]; auto MipWidth = CopyRegion.imageExtent.width; @@ -325,7 +325,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, ++subres; } } - VERIFY_EXPR(subres == InitData.NumSubresources); + VERIFY_EXPR(subres == pInitData->NumSubresources); err = LogicalDevice.BindBufferMemory(StagingBuffer, StagingBufferMemory, AlignedStagingMemOffset); CHECK_VK_ERROR_AND_THROW(err, "Failed to bind staging bufer memory"); diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp index 54ac6d9e..ab8b7cd5 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp @@ -94,7 +94,7 @@ namespace VulkanUtilities return CreateVulkanObject<VkCommandPool>(vkCreateCommandPool, CmdPoolCI, DebugName, "command pool"); } - BufferWrapper VulkanLogicalDevice::CreateBuffer(const VkBufferCreateInfo &BufferCI, + BufferWrapper VulkanLogicalDevice::CreateBuffer(const VkBufferCreateInfo& BufferCI, const char* DebugName)const { VERIFY_EXPR(BufferCI.sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO); |
