Dummy pipeline layout ctor created

Renderer now can update and bind descriptor set
This commit is contained in:
Brandon Mak 2022-09-22 19:38:43 +08:00
parent f28d966ebb
commit cb31628e66
22 changed files with 161 additions and 81 deletions

View File

@ -7,6 +7,7 @@
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Scene/SHSceneManager.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
#include "Math/Transform/SHTransformComponent.h"
using namespace SHADE;
@ -28,6 +29,8 @@ namespace Sandbox
}
void SBTestScene::Init()
{
SHComponentManager::CreateComponentSparseSet<SHTransformComponent>();
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
// Create temp meshes
const auto CUBE_MESH = SHADE::SHPrimitiveGenerator::Cube(*graphicsSystem);
@ -37,16 +40,25 @@ namespace Sandbox
auto matInst = graphicsSystem->AddMaterialInstance();
// Create entity and add mesh
auto entity = SHADE::SHEntityManager::CreateEntity<SHADE::SHRenderable>();
auto& renderable = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHRenderable>(entity);
testEntity = SHADE::SHEntityManager::CreateEntity<SHADE::SHRenderable>();
SHComponentManager::AddComponent<SHTransformComponent>(testEntity);
auto& renderable = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHRenderable>(testEntity);
auto& transform = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHTransformComponent>(testEntity);
renderable.Mesh = CUBE_MESH;
renderable.SetMaterial(matInst);
renderable.TransformMatrix.Translate(0.0f, 0.0f, 2.0f);
transform.SetWorldPosition (SHVec3 (0.0f, 0.0f, 2.0f));
}
void SBTestScene::Update(float dt)
{
(void)dt;
static float rotation = 0.0f;
auto& transform = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHTransformComponent>(testEntity);
transform.SetWorldRotation (rotation, 0.0f, 0.0f);
rotation += dt * 10.0f;
}
void SBTestScene::Render()

View File

@ -9,7 +9,7 @@ namespace Sandbox
{
private:
EntityID camera;
unsigned int testEntity;
public:
virtual void Load();

View File

@ -49,6 +49,11 @@ namespace SHADE
Init(newSize, data, srcSize, bufferUsageFlags, allocCreateInfo.usage, allocCreateInfo.flags);
}
void SHVkBuffer::FlushAllocation(uint32_t srcOffset, uint32_t dstOffset) noexcept
{
vmaFlushAllocation(vmaAllocator, alloc, srcOffset, dstOffset);
}
vk::Buffer SHVkBuffer::GetVkBuffer(void) const noexcept
{
return vkBuffer;
@ -72,8 +77,7 @@ namespace SHADE
/***************************************************************************/
void SHVkBuffer::Map(void) noexcept
{
if (!boundToCoherent)
vmaMapMemory(vmaAllocator, alloc, &mappedPtr);
vmaMapMemory(vmaAllocator, alloc, &mappedPtr);
}
/***************************************************************************/
@ -90,11 +94,8 @@ namespace SHADE
/***************************************************************************/
void SHVkBuffer::Unmap(void) noexcept
{
if (!boundToCoherent)
{
vmaUnmapMemory(vmaAllocator, alloc);
mappedPtr = nullptr;
}
vmaUnmapMemory(vmaAllocator, alloc);
mappedPtr = nullptr;
}
/***************************************************************************/
@ -132,9 +133,7 @@ namespace SHADE
Otherwise, only the copying is carried out.
In the instance where memory is non-coherent but HOST_VISIBLE, we want to
write to data and then unmap and flush it immediately. If you want to write
to memory in random-access fashion, consider, mapping, writing a few
things, unmapping then flushing.
write to data and then unmap and flush it immediately.
\param vmaAllocator
The VMA allocator object.
@ -155,18 +154,11 @@ namespace SHADE
/***************************************************************************/
void SHVkBuffer::MapWriteUnmap(void* data, uint32_t sizeToWrite, uint32_t srcOffset, uint32_t dstOffset) noexcept
{
if (!boundToCoherent)
{
// map from host visible memory to pointer, do a DMA, and then unmap
Map();
WriteToMemory(data, sizeToWrite, srcOffset, dstOffset);
Unmap();
}
else
{
if (mappedPtr)
std::memcpy(static_cast<uint8_t*>(mappedPtr) + dstOffset, static_cast<uint8_t*>(data) + srcOffset, sizeToWrite);
}
// map from host visible memory to pointer, do a DMA, and then unmap
Map();
WriteToMemory(data, sizeToWrite, srcOffset, dstOffset);
Unmap();
FlushAllocation(srcOffset, dstOffset);
}
/***************************************************************************/
@ -279,7 +271,6 @@ namespace SHADE
, mappedPtr{ nullptr }
, alloc {nullptr}
, randomAccessOptimized{false}
, boundToCoherent {false}
, vmaAllocator{allocator}
{}
@ -304,7 +295,6 @@ namespace SHADE
, mappedPtr{ std::move(rhs.mappedPtr) }
, alloc{ std::move (rhs.alloc) }
, randomAccessOptimized{ rhs.randomAccessOptimized }
, boundToCoherent{ rhs.boundToCoherent}
, vmaAllocator{ rhs.vmaAllocator }
, bufferUsageFlags {rhs.bufferUsageFlags}
, bufferCreateInfo { rhs.bufferCreateInfo }
@ -325,7 +315,6 @@ namespace SHADE
mappedPtr = std::move(rhs.mappedPtr);
alloc = std::move(rhs.alloc);
randomAccessOptimized = rhs.randomAccessOptimized;
boundToCoherent = rhs.boundToCoherent;
vmaAllocator = std::move (rhs.vmaAllocator);
rhs.vkBuffer = VK_NULL_HANDLE;
bufferCreateInfo = rhs.bufferCreateInfo;
@ -430,16 +419,12 @@ namespace SHADE
// mainly host visible. Can be cached (need to flush/invalidate), uncached (always coherent) and coherent (virtual).
if(memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
{
// If memory is marked to be coherent between CPU and GPU (no need flush/invalidate) (TODO: Verify if VMA_ALLOCATION_CREATE_MAPPED_BIT is used when VMA_MEMORY_USAGE_AUTO is set)
// TODO: also verify that coherent bit = pointer is already mapped
if (memPropFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
{
boundToCoherent = true;
mappedPtr = allocInfo.pMappedData;
}
if (allocFlags | VMA_ALLOCATION_CREATE_MAPPED_BIT)
mappedPtr = allocInfo.pMappedData;
else
mappedPtr = nullptr;
if (data)
MapWriteUnmap(data, srcSize, 0, 0);
}

View File

@ -41,9 +41,6 @@ namespace SHADE
//! If initialized with vma random access flag, this is true
bool randomAccessOptimized;
//! Whether or not this buffer is bound to coherent memory
bool boundToCoherent;
//! buffer usage info flags
vk::BufferUsageFlags bufferUsageFlags;
@ -100,6 +97,7 @@ namespace SHADE
void TransferToDeviceResource(Handle<SHVkCommandBuffer> const& cmdBufferHdl) noexcept;
void ResizeNoCopy (uint32_t newSize);
void ResizeReplace (uint32_t newSize, void* data, uint32_t srcSize);
void FlushAllocation (uint32_t srcOffset, uint32_t dstOffset) noexcept;
/*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */

View File

@ -491,6 +491,11 @@ namespace SHADE
// //vkCommandBuffer.pipelineBarrier()
//}
void SHVkCommandBuffer::ForceSetPipelineLayout(Handle<SHVkPipelineLayout> pipelineLayout) noexcept
{
boundPipelineLayoutHdl = pipelineLayout;
}
/***************************************************************************/
/*!

View File

@ -141,6 +141,7 @@ namespace SHADE
{
memcpy (static_cast<uint8_t*>(pushConstantData) + boundPipelineLayoutHdl->GetPushConstantInterface().GetOffset(variableName), &data, sizeof (T));
};
void ForceSetPipelineLayout (Handle<SHVkPipelineLayout> pipelineLayout) noexcept;
void SubmitPushConstants (void) const noexcept;

View File

@ -176,7 +176,7 @@ namespace SHADE
}
}
void SHVkDescriptorSetGroup::ModifyWriteDescBuffer(uint32_t set, uint32_t binding, std::span<Handle<SHVkBuffer>> const& buffers) noexcept
void SHVkDescriptorSetGroup::ModifyWriteDescBuffer(uint32_t set, uint32_t binding, std::span<Handle<SHVkBuffer>> const& buffers, uint32_t offset, uint32_t range) noexcept
{
// Find the target writeDescSet
BindingAndSetHash writeHash = binding;
@ -193,6 +193,8 @@ namespace SHADE
// write sampler and image view
auto& buffer = buffers[i];
writeInfo.descBufferInfos[i].buffer = buffer->GetVkBuffer();
writeInfo.descBufferInfos[i].offset = offset;
writeInfo.descBufferInfos[i].range = range;
}
}

View File

@ -64,7 +64,7 @@ namespace SHADE
void UpdateDescriptorSetBuffer(uint32_t set, uint32_t binding) noexcept;
void ModifyWriteDescImage(uint32_t set, uint32_t binding, std::span<std::pair<Handle<SHVkImageView>, Handle<SHVkSampler>>> const& imageViewsAndSamplers) noexcept;
void ModifyWriteDescBuffer (uint32_t set, uint32_t binding, std::span<Handle<SHVkBuffer>> const& buffers) noexcept;
void ModifyWriteDescBuffer (uint32_t set, uint32_t binding, std::span<Handle<SHVkBuffer>> const& buffers, uint32_t offset, uint32_t range) noexcept;
/*-----------------------------------------------------------------------------*/

View File

@ -467,7 +467,12 @@ namespace SHADE
*/
/***************************************************************************/
Handle<SHVkPipelineLayout> SHVkLogicalDevice::CreatePipelineLayout(SHPipelineLayoutParams& pipelineLayoutParams) noexcept
Handle<SHVkPipelineLayout> SHVkLogicalDevice::CreatePipelineLayout(SHPipelineLayoutParams const& pipelineLayoutParams) noexcept
{
return SHVkInstance::GetResourceManager().Create <SHVkPipelineLayout>(GetHandle(), pipelineLayoutParams);
}
Handle<SHVkPipelineLayout> SHVkLogicalDevice::CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy const& pipelineLayoutParams) noexcept
{
return SHVkInstance::GetResourceManager().Create <SHVkPipelineLayout>(GetHandle(), pipelineLayoutParams);
}

View File

@ -187,7 +187,8 @@ namespace SHADE
Handle<SHVkDescriptorSetGroup> CreateDescriptorSetGroup(Handle<SHVkDescriptorPool> pool,
std::vector<Handle<SHVkDescriptorSetLayout>> const& layouts,
std::vector<uint32_t> const& variableDescCounts) noexcept;
Handle<SHVkPipelineLayout> CreatePipelineLayout (SHPipelineLayoutParams& pipelineLayoutParams) noexcept;
Handle<SHVkPipelineLayout> CreatePipelineLayout(SHPipelineLayoutParams const& pipelineLayoutParams) noexcept;
Handle<SHVkPipelineLayout> CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy const& pipelineLayoutParams) noexcept;
Handle<SHVkFence> CreateFence (void) const noexcept;
Handle<SHVkSemaphore> CreateSemaphore (void) const noexcept;

View File

@ -2,6 +2,7 @@
#include "SHGraphicsGlobalData.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Pipeline/SHPipelineState.h"
#include "Graphics/Pipeline/SHVkPipelineLayout.h"
#include "Graphics/Descriptors/SHVkDescriptorSetLayout.h"
namespace SHADE
@ -66,6 +67,9 @@ namespace SHADE
globalDescSetLayouts.push_back(dynamicGlobalLayout);
globalDescSetLayouts.push_back(cameraDataGlobalLayout);
globalDescSetLayouts.push_back(materialDataPerInstanceLayout);
dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{globalDescSetLayouts});
}
void SHGraphicsGlobalData::InitDefaultVertexInputState(void) noexcept
@ -94,4 +98,9 @@ namespace SHADE
return defaultVertexInputState;
}
Handle<SHVkPipelineLayout> SHGraphicsGlobalData::GetDummyPipelineLayout(void) const noexcept
{
return dummyPipelineLayout;
}
}

View File

@ -9,6 +9,7 @@ namespace SHADE
class SHVkLogicalDevice;
class SHVkDescriptorSetLayout;
class SHVkDescriptorSetGroup;
class SHVkPipelineLayout;
class SH_API SHGraphicsGlobalData
{
@ -22,6 +23,10 @@ namespace SHADE
//! Default vertex input state (used by everything).
SHVertexInputState defaultVertexInputState;
//! Since we want to bind global data but can't do so without a pipeline layout,
//! we create a dummy pipeline layout to use it for binding.
Handle<SHVkPipelineLayout> dummyPipelineLayout;
void InitDescSetLayouts (Handle<SHVkLogicalDevice> logicalDevice) noexcept;
void InitDefaultVertexInputState(void) noexcept;
public:
@ -35,5 +40,6 @@ namespace SHADE
/*-----------------------------------------------------------------------*/
std::vector<Handle<SHVkDescriptorSetLayout>> const& GetDescSetLayouts (void) const noexcept;
SHVertexInputState const& GetDefaultViState (void) const noexcept;
Handle<SHVkPipelineLayout> GetDummyPipelineLayout (void) const noexcept;
};
}

View File

@ -22,24 +22,24 @@ namespace SHADE
void SHCamera::SetLookAt(const SHVec3& pos, const SHVec3& target, const SHVec3& up)
{
SHVec3 view = target - pos; view = SHVec3::Normalise(view);
SHVec3 right = SHVec3::Cross(view, up); right = SHVec3::Normalise(right);
const SHVec3 UP = SHVec3::Cross(right, view);
SHVec3 right = SHVec3::Cross(view, up); right = SHVec3::Normalise(right);
const SHVec3 UP = SHVec3::Cross(right, view);
viewMatrix = SHMatrix::Identity;
viewMatrix(0, 0) = right[0];
viewMatrix(1, 0) = right[1];
viewMatrix(2, 0) = right[2];
viewMatrix(0, 1) = UP[0];
viewMatrix(1, 1) = UP[1];
viewMatrix(2, 1) = UP[2];
viewMatrix(0, 2) = -view[0];
viewMatrix(1, 2) = -view[1];
viewMatrix(2, 2) = -view[2];
viewMatrix(3, 0) = -right.Dot(pos);
viewMatrix(3, 1) = -UP.Dot(pos);
viewMatrix(3, 2) = view.Dot(pos);
isDirty = true;
viewMatrix = SHMatrix::Identity;
viewMatrix(0, 0) = UP[0];
viewMatrix(1, 0) = UP[1];
viewMatrix(2, 0) = UP[2];
viewMatrix(0, 1) = right[0];
viewMatrix(1, 1) = right[1];
viewMatrix(2, 1) = right[2];
viewMatrix(0, 2) = view[0];
viewMatrix(1, 2) = view[1];
viewMatrix(2, 2) = view[2];
viewMatrix(3, 0) = -UP.Dot(pos);
viewMatrix(3, 1) = -right.Dot(pos);
viewMatrix(3, 2) = -view.Dot(pos);
isDirty = true;
}
/*---------------------------------------------------------------------------------*/

View File

@ -114,7 +114,7 @@ namespace SHADE
screenCamera->SetLookAt(SHVec3(0.0f, 0.0f, -1.0f), SHVec3(0.0f, 0.0f, 1.0f), SHVec3(0.0f, 1.0f, 0.0f));
screenCamera->SetOrthographic(static_cast<float>(windowDims.first), static_cast<float>(windowDims.second), 0.01f, 100.0f);
worldCamera = resourceManager.Create<SHCamera>();
worldCamera->SetLookAt(SHVec3(0.0f, 0.0f, -1.0f), SHVec3(0.0f, 0.0f, 1.0f), SHVec3(0.0f, 1.0f, 0.0f));
worldCamera->SetLookAt(SHVec3(1.0f, 0.0f, -1.0f), SHVec3(0.0f, 0.0f, 2.0f), SHVec3(0.0f, 1.0f, 0.0f));
worldCamera->SetPerspective(90.0f, static_cast<float>(windowDims.first), static_cast<float>(windowDims.second), 0.0f, 100.0f);
// Create Default Viewport
@ -221,7 +221,6 @@ namespace SHADE
renderContext.ResetFence();
// For every viewport
for (int vpIndex = 0; vpIndex < static_cast<int>(viewports.size()); ++vpIndex)
{
@ -239,6 +238,8 @@ namespace SHADE
// Begin recording the command buffer
currentCmdBuffer->BeginRecording();
currentCmdBuffer->ForceSetPipelineLayout(globalData->GetDummyPipelineLayout());
// Bind all the buffers required for meshes
for (auto& [buffer, bindingPoint] : MESH_DATA)
{
@ -249,7 +250,7 @@ namespace SHADE
}
// bind camera data
renderers[renIndex]->BindDescriptorSet(currentCmdBuffer, frameIndex);
renderers[renIndex]->UpdateDataAndBind(currentCmdBuffer, frameIndex);
// Draw first
renderers[renIndex]->Draw(frameIndex);

View File

@ -37,15 +37,14 @@ namespace SHADE
commandBuffers[i] = cmdPools[i]->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
cameraDescriptorSet = descriptorPool->Allocate({ cameraDescLayout }, { 1 });
cpuCameraData.resize(numFrames);
cameraDataAlignedSize = logicalDevice->PadUBOSize(sizeof(SHShaderCameraData));
cameraBuffer = logicalDevice->CreateBuffer(cameraDataAlignedSize * numFrames, nullptr, cameraDataAlignedSize * numFrames, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
cameraBuffer = logicalDevice->CreateBuffer(cameraDataAlignedSize * numFrames, nullptr, cameraDataAlignedSize * numFrames, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
std::array cameraBufferArray{cameraBuffer};
cameraDescriptorSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS, SHGraphicsConstants::DescriptorSetBindings::CAMERA_DATA, std::span<Handle<SHVkBuffer>>{ cameraBufferArray.data(), cameraBufferArray.size()});
cameraDescriptorSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS, SHGraphicsConstants::DescriptorSetBindings::CAMERA_DATA, std::span<Handle<SHVkBuffer>>{ cameraBufferArray.data(), cameraBufferArray.size()}, 0, sizeof (SHShaderCameraData));
cameraDescriptorSet->UpdateDescriptorSetBuffer(SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS, SHGraphicsConstants::DescriptorSetBindings::CAMERA_DATA);
}
@ -66,13 +65,20 @@ namespace SHADE
renderGraph->Execute(frameIndex, commandBuffers[frameIndex]);
}
void SHRenderer::BindDescriptorSet(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept
void SHRenderer::UpdateDataAndBind(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept
{
std::array<uint32_t, 1> dynamicOffsets{ frameIndex * cameraDataAlignedSize };
cpuCameraData.viewProjectionMatrix = camera->GetViewProjectionMatrix();
cameraBuffer->WriteToMemory(&cpuCameraData, sizeof(SHShaderCameraData), 0, cameraDataAlignedSize * frameIndex);
std::array<uint32_t, 1> dynamicOffsets{ frameIndex * cameraDataAlignedSize };
cmdBuffer->BindDescriptorSet(cameraDescriptorSet, vk::PipelineBindPoint::eGraphics, SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS, std::span{ dynamicOffsets.data(), 1 });
}
void SHRenderer::UpdateCameraDataToBuffer(void) noexcept
{
}
Handle<SHRenderGraph> SHRenderer::GetRenderGraph(void) const noexcept
{
return renderGraph;

View File

@ -75,7 +75,8 @@ namespace SHADE
/* Drawing Functions */
/*-----------------------------------------------------------------------------*/
void Draw(uint32_t frameIndex) noexcept;
void BindDescriptorSet (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept;
void UpdateDataAndBind (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept;
void UpdateCameraDataToBuffer (void) noexcept;
/*-----------------------------------------------------------------------------*/
/* Setters and Getters */
@ -95,7 +96,10 @@ namespace SHADE
Handle<SHRenderGraph> renderGraph;
Handle<SHVkDescriptorSetGroup> cameraDescriptorSet;
Handle<SHVkBuffer> cameraBuffer;
std::vector<SHShaderCameraData> cpuCameraData;
// we really only need 1 copy even though we need %swapchainImages copies for
// GPU.
SHShaderCameraData cpuCameraData;
//! Command buffers for the render graph
std::vector<Handle<SHVkCommandBuffer>> commandBuffers;

View File

@ -25,6 +25,15 @@ namespace SHADE
//! want to use it for allocating descriptor sets.
std::vector<Handle<SHVkDescriptorSetLayout>> const& globalDescSetLayouts = {};
};
struct SHPipelineLayoutParamsDummy
{
/*-----------------------------------------------------------------------*/
/* MEMBER VARIABLES */
/*-----------------------------------------------------------------------*/
std::vector<Handle<SHVkDescriptorSetLayout>> const& globalDescSetLayouts = {};
};
}
#endif

View File

@ -64,7 +64,7 @@ namespace SHADE
vk::CullModeFlags cull_mode{ vk::CullModeFlagBits::eBack };
//! CW or CCW
vk::FrontFace frontFacingOrientation{ vk::FrontFace::eClockwise };
vk::FrontFace frontFacingOrientation{ vk::FrontFace::eCounterClockwise };
bool depthBias{ VK_FALSE };
};

View File

@ -254,12 +254,6 @@ namespace SHADE
// Clear pc ranges
vkPcRanges.clear();
// Kill all descriptor set layouts
for (auto& layout : descriptorSetLayoutsGlobal)
SHVkInstance::GetResourceManager().Free(layout);
descriptorSetLayoutsGlobal.clear();
for (auto& layout : descriptorSetLayoutsAllocate)
SHVkInstance::GetResourceManager().Free(layout);
@ -285,9 +279,9 @@ namespace SHADE
*/
/***************************************************************************/
SHVkPipelineLayout::SHVkPipelineLayout(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, SHPipelineLayoutParams& pipelineLayoutParams) noexcept
SHVkPipelineLayout::SHVkPipelineLayout(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, SHPipelineLayoutParams const& pipelineLayoutParams) noexcept
: vkPipelineLayout {VK_NULL_HANDLE}
, shaderModules{std::move (pipelineLayoutParams.shaderModules)}
, shaderModules{pipelineLayoutParams.shaderModules}
, logicalDeviceHdl {inLogicalDeviceHdl}
, pushConstantInterface{}
, vkPcRanges{}
@ -308,6 +302,46 @@ namespace SHADE
RecreateIfNeeded ();
}
SHVkPipelineLayout::SHVkPipelineLayout(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, SHPipelineLayoutParamsDummy const& pipelineLayoutParams) noexcept
: vkPipelineLayout{ VK_NULL_HANDLE }
, shaderModules{ }
, logicalDeviceHdl{ inLogicalDeviceHdl }
, pushConstantInterface{}
, vkPcRanges{}
, descriptorSetLayoutsGlobal{}
, descriptorSetLayoutsAllocate{}
, vkDescriptorSetLayoutsAllocate{}
, vkDescriptorSetLayoutsPipeline{}
{
vkDescriptorSetLayoutsPipeline.resize(pipelineLayoutParams.globalDescSetLayouts.size());
for (uint32_t i = 0; auto& layout : vkDescriptorSetLayoutsPipeline)
{
layout = pipelineLayoutParams.globalDescSetLayouts[i]->GetVkHandle();
++i;
}
vk::PipelineLayoutCreateInfo plCreateInfo{};
// Set push constant data to pipeline layout
plCreateInfo.pushConstantRangeCount = 0;
plCreateInfo.pPushConstantRanges = nullptr;
// To initialize the descriptor set layouts for the pipeline layout.
plCreateInfo.setLayoutCount = static_cast<uint32_t>(vkDescriptorSetLayoutsPipeline.size());
plCreateInfo.pSetLayouts = vkDescriptorSetLayoutsPipeline.data();
if (auto const RESULT = logicalDeviceHdl->GetVkLogicalDevice().createPipelineLayout(&plCreateInfo, nullptr, &vkPipelineLayout); RESULT != vk::Result::eSuccess)
{
SHVulkanDebugUtil::ReportVkError(RESULT, "Failed to create Pipeline Layout. ");
return;
}
else
SHVulkanDebugUtil::ReportVkSuccess("Successfully created Pipeline Layout. ");
}
/***************************************************************************/
/*!

View File

@ -57,7 +57,8 @@ namespace SHADE
/*-----------------------------------------------------------------------*/
/* CTORS AND DTORS */
/*-----------------------------------------------------------------------*/
SHVkPipelineLayout (Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, SHPipelineLayoutParams& pipelineLayoutParams) noexcept;
SHVkPipelineLayout(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, SHPipelineLayoutParams const& pipelineLayoutParams) noexcept;
SHVkPipelineLayout(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, SHPipelineLayoutParamsDummy const& pipelineLayoutParams) noexcept;
SHVkPipelineLayout (SHVkPipelineLayout&& rhs) noexcept;
~SHVkPipelineLayout (void) noexcept;
SHVkPipelineLayout& operator= (SHVkPipelineLayout&& rhs) noexcept;

View File

@ -56,6 +56,7 @@ void main()
//Out.uv = aUV;
// render NDC first
gl_Position = vec4(aVertexPos, 1.0);
//gl_Position = vec4(aVertexPos, 1.0f);
gl_Position = cameraData.vpMat * vec4 (aVertexPos, 1.0f);
Out.vertColor = vec4 (aVertexPos, 1.0f);
}

Binary file not shown.