Moved GPU Data structs into its own header and hooked them up in the bindless descriptor management system
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "VulkanInit.h"
|
||||
#include "DescriptorLayoutBuilder.h"
|
||||
|
||||
#include "GPUData/GPUData.h"
|
||||
|
||||
using namespace Nuake;
|
||||
|
||||
@@ -150,11 +151,11 @@ void BindlessDescriptor::Swap(int32_t frameIndex)
|
||||
|
||||
ResourceDescriptors::ResourceDescriptors(const ResourceDescriptorsLimits& limits)
|
||||
{
|
||||
AddResourceDescriptors<ResourceType::View, View>(limits.MaxView);
|
||||
//AddResourceDescriptors<ResourceType::Material>(limits.MaxMaterial);
|
||||
//AddResourceDescriptors<ResourceType::Texture>(limits.MaxTexture);
|
||||
//AddResourceDescriptors<ResourceType::Light>(limits.MaxLight);
|
||||
//AddResourceDescriptors<ResourceType::Sampler>(limits.MaxSampler);
|
||||
AddResourceDescriptors<ResourceType::View, CameraView>(limits.MaxView);
|
||||
AddResourceDescriptors<ResourceType::Material, MaterialBufferStruct>(limits.MaxMaterial);
|
||||
AddResourceDescriptors<ResourceType::Texture, VkDescriptorImageInfo>(limits.MaxTexture);
|
||||
AddResourceDescriptors<ResourceType::Light, LightData>(limits.MaxLight);
|
||||
AddResourceDescriptors<ResourceType::Sampler, VkDescriptorImageInfo>(limits.MaxSampler);
|
||||
}
|
||||
|
||||
void ResourceDescriptors::Swap(int32_t frameIndex)
|
||||
@@ -162,6 +163,5 @@ void ResourceDescriptors::Swap(int32_t frameIndex)
|
||||
for (auto& [type, desc] : Descriptors)
|
||||
{
|
||||
desc.Swap(frameIndex);
|
||||
Logger::Log("Swapped: " + GetResourceTypeName(type));
|
||||
}
|
||||
}
|
||||
66
Nuake/Source/Nuake/Rendering/Vulkan/GPUData/GPUData.h
Normal file
66
Nuake/Source/Nuake/Rendering/Vulkan/GPUData/GPUData.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
#include "Nuake/Core/Maths.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
struct TransformData
|
||||
{
|
||||
std::array<Matrix4, 3000> Data;
|
||||
};
|
||||
|
||||
struct MaterialBufferStruct
|
||||
{
|
||||
int HasAlbedo;
|
||||
Vector3 AlbedoColor;
|
||||
int HasNormal;
|
||||
int HasMetalness;
|
||||
int HasRoughness;
|
||||
int HasAO;
|
||||
float MetalnessValue;
|
||||
float RoughnessValue;
|
||||
float AoValue;
|
||||
uint32_t AlbedoTextureId;
|
||||
uint32_t NormalTextureId;
|
||||
uint32_t MetalnessTextureId;
|
||||
uint32_t RoughnessTextureId;
|
||||
uint32_t AoTextureId;
|
||||
int SamplerType;
|
||||
int ReceiveShadow;
|
||||
int CastShadow;
|
||||
int Unlit;
|
||||
int AlphaScissor;
|
||||
int pad[3];
|
||||
};
|
||||
|
||||
struct LightData
|
||||
{
|
||||
Vector3 Position;
|
||||
int Type;
|
||||
Vector4 Color;
|
||||
Vector3 Direction;
|
||||
float OuterConeAngle;
|
||||
float InnerConeAngle;
|
||||
int CastShadow;
|
||||
int ShadowMapTextureId[4];
|
||||
int TransformId[4];
|
||||
float pad[2];
|
||||
};
|
||||
|
||||
struct CameraView
|
||||
{
|
||||
Matrix4 View;
|
||||
Matrix4 Projection;
|
||||
Matrix4 ViewProjection;
|
||||
Matrix4 InverseView;
|
||||
Matrix4 InverseProjection;
|
||||
Vector3 Position;
|
||||
float Near;
|
||||
float Far;
|
||||
float pad;
|
||||
float pad2;
|
||||
float pad3;
|
||||
//char padding[64]; // 124 bytes to reach 128 bytes
|
||||
};
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "Nuake/Rendering/Vulkan/VulkanRenderer.h"
|
||||
|
||||
#include "Nuake/Rendering/Vulkan/BindlessDescriptor.h"
|
||||
#include "Nuake/Rendering/Vulkan/GPUData/GPUData.h"
|
||||
|
||||
#include <volk/volk.h>
|
||||
|
||||
@@ -22,77 +23,17 @@
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
struct ModelData
|
||||
{
|
||||
std::array<Matrix4, 3000> Data;
|
||||
};
|
||||
|
||||
// This is what is present on the shader as a structured buffer
|
||||
struct MaterialBufferStruct
|
||||
{
|
||||
int HasAlbedo;
|
||||
Vector3 AlbedoColor;
|
||||
int HasNormal;
|
||||
int HasMetalness;
|
||||
int HasRoughness;
|
||||
int HasAO;
|
||||
float MetalnessValue;
|
||||
float RoughnessValue;
|
||||
float AoValue;
|
||||
uint32_t AlbedoTextureId;
|
||||
uint32_t NormalTextureId;
|
||||
uint32_t MetalnessTextureId;
|
||||
uint32_t RoughnessTextureId;
|
||||
uint32_t AoTextureId;
|
||||
int SamplerType;
|
||||
int ReceiveShadow;
|
||||
int CastShadow;
|
||||
int Unlit;
|
||||
int AlphaScissor;
|
||||
int pad[3];
|
||||
};
|
||||
|
||||
// This is the *whole* buffer
|
||||
struct MaterialData
|
||||
{
|
||||
std::array<MaterialBufferStruct, 2000> Data;
|
||||
};
|
||||
|
||||
struct LightData
|
||||
{
|
||||
Vector3 Position;
|
||||
int Type;
|
||||
Vector4 Color;
|
||||
Vector3 Direction;
|
||||
float OuterConeAngle;
|
||||
float InnerConeAngle;
|
||||
int CastShadow;
|
||||
int ShadowMapTextureId[4];
|
||||
int TransformId[4];
|
||||
float pad[2];
|
||||
};
|
||||
|
||||
struct LightDataContainer
|
||||
{
|
||||
std::array<LightData, 100> Data;
|
||||
};
|
||||
|
||||
struct CameraView
|
||||
{
|
||||
Matrix4 View;
|
||||
Matrix4 Projection;
|
||||
Matrix4 ViewProjection;
|
||||
Matrix4 InverseView;
|
||||
Matrix4 InverseProjection;
|
||||
Vector3 Position;
|
||||
float Near;
|
||||
float Far;
|
||||
float pad;
|
||||
float pad2;
|
||||
float pad3;
|
||||
//char padding[64]; // 124 bytes to reach 128 bytes
|
||||
};
|
||||
|
||||
constexpr uint32_t MAX_MODEL_MATRIX = 3000;
|
||||
constexpr uint32_t MAX_MATERIAL = 2000;
|
||||
constexpr uint32_t MAX_TEXTURES = 3000;
|
||||
@@ -147,7 +88,7 @@ namespace Nuake
|
||||
std::vector<CleanUpStack> DeletionQueue;
|
||||
|
||||
public:
|
||||
ModelData ModelTransforms;
|
||||
TransformData ModelTransforms;
|
||||
MaterialData MaterialDataContainer;
|
||||
|
||||
LightDataContainer LightDataContainerArray;
|
||||
|
||||
@@ -54,28 +54,17 @@ void GPUResources::Init()
|
||||
};
|
||||
resourceDescriptors = CreateScope<ResourceDescriptors>(limits);
|
||||
|
||||
View testData
|
||||
{
|
||||
.myView = 1,
|
||||
.dat2 = 2
|
||||
};
|
||||
|
||||
|
||||
std::vector<View> testDataVector;
|
||||
testDataVector.reserve(limits.MaxView);
|
||||
for (int i = 0; i < limits.MaxView; i++)
|
||||
{
|
||||
testDataVector.push_back(testData);
|
||||
}
|
||||
|
||||
resourceDescriptors->UpdateBuffer<ResourceType::View>(0, testDataVector.data(), testDataVector.size());
|
||||
|
||||
testDataVector[0].myView = 1337;
|
||||
resourceDescriptors->UpdateBuffer<ResourceType::View>(1, testDataVector.data(), testDataVector.size());
|
||||
|
||||
resourceDescriptors->Swap(1);
|
||||
resourceDescriptors->Swap(0);
|
||||
resourceDescriptors->UpdateBuffer<ResourceType::View>(1, testDataVector.data(), testDataVector.size());
|
||||
resourceDescriptors->Swap(0);
|
||||
//resourceDescriptors->UpdateBuffer<ResourceType::View>(0, testDataVector.data(), testDataVector.size());
|
||||
//
|
||||
//testDataVector[0].myView = 1337;
|
||||
//resourceDescriptors->UpdateBuffer<ResourceType::View>(1, testDataVector.data(), testDataVector.size());
|
||||
//
|
||||
//resourceDescriptors->Swap(1);
|
||||
//resourceDescriptors->Swap(0);
|
||||
//resourceDescriptors->UpdateBuffer<ResourceType::View>(1, testDataVector.data(), testDataVector.size());
|
||||
//resourceDescriptors->Swap(0);
|
||||
}
|
||||
|
||||
Ref<AllocatedBuffer> GPUResources::CreateBuffer(size_t size, BufferUsage flags, MemoryUsage usage, const std::string& name)
|
||||
|
||||
Reference in New Issue
Block a user