parent
870b18b1fa
commit
1302d26217
|
|
@ -57,26 +57,22 @@ Recast(TFrom &&in)
|
||||||
return reinterpret_cast<TType>(std::forward<TFrom>(in));
|
return reinterpret_cast<TType>(std::forward<TFrom>(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr f32
|
constexpr f32 operator""_deg(long double degrees)
|
||||||
operator""_deg(long double degrees)
|
|
||||||
{
|
{
|
||||||
return glm::radians<f32>(Cast<f32>(degrees));
|
return glm::radians<f32>(Cast<f32>(degrees));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr f32
|
constexpr f32 operator""_deg(unsigned long long int degrees)
|
||||||
operator""_deg(unsigned long long int degrees)
|
|
||||||
{
|
{
|
||||||
return glm::radians<f32>(Cast<f32>(degrees));
|
return glm::radians<f32>(Cast<f32>(degrees));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr f32
|
constexpr f32 operator""_rad(long double rads)
|
||||||
operator""_rad(long double rads)
|
|
||||||
{
|
{
|
||||||
return Cast<f32>(rads);
|
return Cast<f32>(rads);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr f32
|
constexpr f32 operator""_rad(unsigned long long int rads)
|
||||||
operator""_rad(unsigned long long int rads)
|
|
||||||
{
|
{
|
||||||
return Cast<f32>(rads);
|
return Cast<f32>(rads);
|
||||||
}
|
}
|
||||||
|
|
@ -84,10 +80,10 @@ operator""_rad(unsigned long long int rads)
|
||||||
using glm::ivec2;
|
using glm::ivec2;
|
||||||
using glm::ivec3;
|
using glm::ivec3;
|
||||||
using glm::ivec4;
|
using glm::ivec4;
|
||||||
|
using glm::quat;
|
||||||
using glm::vec2;
|
using glm::vec2;
|
||||||
using glm::vec3;
|
using glm::vec3;
|
||||||
using glm::vec4;
|
using glm::vec4;
|
||||||
using glm::quat;
|
|
||||||
|
|
||||||
using glm::mat2;
|
using glm::mat2;
|
||||||
using glm::mat3;
|
using glm::mat3;
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ BufferManager::Release(const Device *device, const BufferHandle handle)
|
||||||
void
|
void
|
||||||
BufferManager::Destroy(const Device *device)
|
BufferManager::Destroy(const Device *device)
|
||||||
{
|
{
|
||||||
for (auto& buffer : m_Buffers)
|
for (auto &buffer : m_Buffers)
|
||||||
{
|
{
|
||||||
buffer.Destroy(device);
|
buffer.Destroy(device);
|
||||||
}
|
}
|
||||||
|
|
@ -275,7 +275,7 @@ GpuResourceManager::Release(TextureHandle handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureHandle
|
TextureHandle
|
||||||
GpuResourceManager::Commit(Texture* texture)
|
GpuResourceManager::Commit(Texture *texture)
|
||||||
{
|
{
|
||||||
TextureHandle handle = m_TextureManager.Commit(texture);
|
TextureHandle handle = m_TextureManager.Commit(texture);
|
||||||
|
|
||||||
|
|
@ -338,7 +338,7 @@ GpuResourceManager::GpuResourceManager(const Device *device, u16 maxSize)
|
||||||
.maxAnisotropy = properties.limits.maxSamplerAnisotropy,
|
.maxAnisotropy = properties.limits.maxSamplerAnisotropy,
|
||||||
.compareEnable = false,
|
.compareEnable = false,
|
||||||
.minLod = 0,
|
.minLod = 0,
|
||||||
.maxLod = vk::LodClampNone,
|
.maxLod = VK_LOD_CLAMP_NONE,
|
||||||
.borderColor = vk::BorderColor::eFloatOpaqueBlack,
|
.borderColor = vk::BorderColor::eFloatOpaqueBlack,
|
||||||
.unnormalizedCoordinates = false,
|
.unnormalizedCoordinates = false,
|
||||||
};
|
};
|
||||||
|
|
@ -368,6 +368,18 @@ GpuResourceManager::GpuResourceManager(const Device *device, u16 maxSize)
|
||||||
};
|
};
|
||||||
AbortIfFailed(device->m_Device.createDescriptorPool(&poolCreateInfo, nullptr, &m_DescriptorPool));
|
AbortIfFailed(device->m_Device.createDescriptorPool(&poolCreateInfo, nullptr, &m_DescriptorPool));
|
||||||
|
|
||||||
|
vk::DescriptorBindingFlags bindingFlags =
|
||||||
|
vk::DescriptorBindingFlagBits::ePartiallyBound | vk::DescriptorBindingFlagBits::eUpdateAfterBind;
|
||||||
|
eastl::array layoutBindingFlags = {
|
||||||
|
bindingFlags,
|
||||||
|
bindingFlags,
|
||||||
|
};
|
||||||
|
|
||||||
|
vk::DescriptorSetLayoutBindingFlagsCreateInfo bindingFlagsCreateInfo = {
|
||||||
|
.bindingCount = Cast<u32>(layoutBindingFlags.size()),
|
||||||
|
.pBindingFlags = layoutBindingFlags.data(),
|
||||||
|
};
|
||||||
|
|
||||||
eastl::vector immutableSamplers(texturesCount, m_ImmutableSampler);
|
eastl::vector immutableSamplers(texturesCount, m_ImmutableSampler);
|
||||||
eastl::array descriptorLayoutBindings = {
|
eastl::array descriptorLayoutBindings = {
|
||||||
vk::DescriptorSetLayoutBinding{
|
vk::DescriptorSetLayoutBinding{
|
||||||
|
|
@ -384,7 +396,9 @@ GpuResourceManager::GpuResourceManager(const Device *device, u16 maxSize)
|
||||||
.pImmutableSamplers = immutableSamplers.data(),
|
.pImmutableSamplers = immutableSamplers.data(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
static_assert(layoutBindingFlags.size() == descriptorLayoutBindings.size());
|
||||||
const vk::DescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = {
|
const vk::DescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = {
|
||||||
|
.pNext = &bindingFlagsCreateInfo,
|
||||||
.flags = vk::DescriptorSetLayoutCreateFlagBits::eUpdateAfterBindPool,
|
.flags = vk::DescriptorSetLayoutCreateFlagBits::eUpdateAfterBindPool,
|
||||||
.bindingCount = Cast<u32>(descriptorLayoutBindings.size()),
|
.bindingCount = Cast<u32>(descriptorLayoutBindings.size()),
|
||||||
.pBindings = descriptorLayoutBindings.data(),
|
.pBindings = descriptorLayoutBindings.data(),
|
||||||
|
|
@ -420,18 +434,18 @@ GpuResourceManager::~GpuResourceManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
GpuResourceManager::GpuResourceManager(GpuResourceManager &&other) noexcept
|
GpuResourceManager::GpuResourceManager(GpuResourceManager &&other) noexcept
|
||||||
: m_WriteInfos(std::move(other.m_WriteInfos)),
|
: m_WriteInfos(std::move(other.m_WriteInfos))
|
||||||
m_Writes(std::move(other.m_Writes)),
|
, m_Writes(std::move(other.m_Writes))
|
||||||
m_WriteOwner(std::move(other.m_WriteOwner)),
|
, m_WriteOwner(std::move(other.m_WriteOwner))
|
||||||
m_ImmutableSampler(other.m_ImmutableSampler),
|
, m_ImmutableSampler(other.m_ImmutableSampler)
|
||||||
m_BufferManager(std::move(other.m_BufferManager)),
|
, m_BufferManager(std::move(other.m_BufferManager))
|
||||||
m_TextureManager(std::move(other.m_TextureManager)),
|
, m_TextureManager(std::move(other.m_TextureManager))
|
||||||
m_Device(Take(other.m_Device)),
|
, m_Device(Take(other.m_Device))
|
||||||
m_DescriptorPool(other.m_DescriptorPool),
|
, m_DescriptorPool(other.m_DescriptorPool)
|
||||||
m_SetLayout(other.m_SetLayout),
|
, m_SetLayout(other.m_SetLayout)
|
||||||
m_DescriptorSet(other.m_DescriptorSet),
|
, m_DescriptorSet(other.m_DescriptorSet)
|
||||||
m_CommitedBufferCount(other.m_CommitedBufferCount),
|
, m_CommitedBufferCount(other.m_CommitedBufferCount)
|
||||||
m_CommitedTextureCount(other.m_CommitedTextureCount)
|
, m_CommitedTextureCount(other.m_CommitedTextureCount)
|
||||||
{
|
{
|
||||||
assert(!other.m_Device);
|
assert(!other.m_Device);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,7 @@ struct TextureManager
|
||||||
u32 m_MaxCapacity;
|
u32 m_MaxCapacity;
|
||||||
u32 m_FreeHead;
|
u32 m_FreeHead;
|
||||||
|
|
||||||
void
|
void Init(u32 maxCapacity);
|
||||||
Init(u32 maxCapacity);
|
|
||||||
TextureHandle Commit(Texture *texture);
|
TextureHandle Commit(Texture *texture);
|
||||||
Texture *Fetch(TextureHandle handle);
|
Texture *Fetch(TextureHandle handle);
|
||||||
void Release(const Device *device, TextureHandle handle);
|
void Release(const Device *device, TextureHandle handle);
|
||||||
|
|
@ -63,9 +62,8 @@ struct BufferManager
|
||||||
|
|
||||||
struct GpuResourceManager
|
struct GpuResourceManager
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
union WriteInfo
|
union WriteInfo {
|
||||||
{
|
|
||||||
vk::DescriptorBufferInfo uBufferInfo;
|
vk::DescriptorBufferInfo uBufferInfo;
|
||||||
vk::DescriptorImageInfo uImageInfo;
|
vk::DescriptorImageInfo uImageInfo;
|
||||||
vk::BufferView uBufferView;
|
vk::BufferView uBufferView;
|
||||||
|
|
@ -98,7 +96,7 @@ private:
|
||||||
|
|
||||||
void EraseWrites(u32 handleIndex, HandleType handleType);
|
void EraseWrites(u32 handleIndex, HandleType handleType);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Device *m_Device;
|
const Device *m_Device;
|
||||||
|
|
||||||
constexpr static u32 BUFFER_BINDING_INDEX = 0;
|
constexpr static u32 BUFFER_BINDING_INDEX = 0;
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ LightManager::AddDirectional(const vec3 &direction, const vec3 &color)
|
||||||
}
|
}
|
||||||
|
|
||||||
LightHandle
|
LightHandle
|
||||||
LightManager::AddPoint(const vec3 & position, const vec3 &color, const f32 radius)
|
LightManager::AddPoint(const vec3 &position, const vec3 &color, const f32 radius)
|
||||||
{
|
{
|
||||||
assert(m_PointLightCount <= m_MetaInfo.m_PointLightMaxCount);
|
assert(m_PointLightCount <= m_MetaInfo.m_PointLightMaxCount);
|
||||||
assert(radius >= 0.0f);
|
assert(radius >= 0.0f);
|
||||||
|
|
@ -244,7 +244,6 @@ LightManager::RemoveLight(const LightHandle handle)
|
||||||
{
|
{
|
||||||
const u8 handleGen = handle.m_Generation;
|
const u8 handleGen = handle.m_Generation;
|
||||||
|
|
||||||
|
|
||||||
if (handle.m_Type == Light::TYPE_DIRECTIONAL)
|
if (handle.m_Type == Light::TYPE_DIRECTIONAL)
|
||||||
{
|
{
|
||||||
Light *lightSlot = &m_Lights[handle.m_Index];
|
Light *lightSlot = &m_Lights[handle.m_Index];
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ struct LightManager
|
||||||
constexpr static u16 CAPACITY_MASK = ~(UPDATE_REQUIRED_BIT);
|
constexpr static u16 CAPACITY_MASK = ~(UPDATE_REQUIRED_BIT);
|
||||||
|
|
||||||
LightHandle AddDirectional(const vec3 &direction, const vec3 &color);
|
LightHandle AddDirectional(const vec3 &direction, const vec3 &color);
|
||||||
LightHandle AddPoint(const vec3& position, const vec3 &color, f32 radius);
|
LightHandle AddPoint(const vec3 &position, const vec3 &color, f32 radius);
|
||||||
void Update();
|
void Update();
|
||||||
void RemoveLight(LightHandle handle);
|
void RemoveLight(LightHandle handle);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
#include "gpu_resource_manager.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "gpu_resource_manager.h"
|
|
||||||
|
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
vec4
|
vec4
|
||||||
VectorToVec4(const std::vector<double> &vec)
|
VectorToVec4(const std::vector<double> &vec)
|
||||||
|
|
@ -46,8 +46,7 @@ VectorToVec3(const std::vector<double> &vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureHandle
|
TextureHandle
|
||||||
ModelLoader::LoadImage(vk::CommandBuffer commandBuffer, StagingBuffer *stagingBuffer,
|
ModelLoader::LoadImage(vk::CommandBuffer commandBuffer, StagingBuffer *stagingBuffer, tinygltf::Image *image) const
|
||||||
tinygltf::Image *image) const
|
|
||||||
{
|
{
|
||||||
assert(image->component == 4);
|
assert(image->component == 4);
|
||||||
|
|
||||||
|
|
@ -64,8 +63,8 @@ ModelLoader::LoadImage(vk::CommandBuffer commandBuffer, StagingBuffer *stagingBu
|
||||||
.dstAccessMask = vk::AccessFlagBits::eTransferWrite,
|
.dstAccessMask = vk::AccessFlagBits::eTransferWrite,
|
||||||
.oldLayout = vk::ImageLayout::eUndefined,
|
.oldLayout = vk::ImageLayout::eUndefined,
|
||||||
.newLayout = vk::ImageLayout::eTransferDstOptimal,
|
.newLayout = vk::ImageLayout::eTransferDstOptimal,
|
||||||
.srcQueueFamilyIndex = vk::QueueFamilyIgnored,
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
.dstQueueFamilyIndex = vk::QueueFamilyIgnored,
|
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
.image = texture.m_Image,
|
.image = texture.m_Image,
|
||||||
.subresourceRange =
|
.subresourceRange =
|
||||||
{
|
{
|
||||||
|
|
@ -82,8 +81,8 @@ ModelLoader::LoadImage(vk::CommandBuffer commandBuffer, StagingBuffer *stagingBu
|
||||||
.dstAccessMask = vk::AccessFlagBits::eTransferRead,
|
.dstAccessMask = vk::AccessFlagBits::eTransferRead,
|
||||||
.oldLayout = vk::ImageLayout::eTransferDstOptimal,
|
.oldLayout = vk::ImageLayout::eTransferDstOptimal,
|
||||||
.newLayout = vk::ImageLayout::eTransferSrcOptimal,
|
.newLayout = vk::ImageLayout::eTransferSrcOptimal,
|
||||||
.srcQueueFamilyIndex = vk::QueueFamilyIgnored,
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
.dstQueueFamilyIndex = vk::QueueFamilyIgnored,
|
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
.image = texture.m_Image,
|
.image = texture.m_Image,
|
||||||
.subresourceRange =
|
.subresourceRange =
|
||||||
{
|
{
|
||||||
|
|
@ -135,9 +134,7 @@ ModelLoader::LoadImage(vk::CommandBuffer commandBuffer, StagingBuffer *stagingBu
|
||||||
commandBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer, {}, 0,
|
commandBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer, {}, 0,
|
||||||
nullptr, 0, nullptr, 1, &nextMipBarrier);
|
nullptr, 0, nullptr, 1, &nextMipBarrier);
|
||||||
|
|
||||||
auto calcNextMip = [](i32 prev) {
|
auto calcNextMip = [](i32 prev) { return eastl::max(prev / 2, 1); };
|
||||||
return eastl::max(prev / 2, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
i32 prevMipWidth = Cast<i32>(texture.m_Extent.width);
|
i32 prevMipWidth = Cast<i32>(texture.m_Extent.width);
|
||||||
i32 prevMipHeight = Cast<i32>(texture.m_Extent.height);
|
i32 prevMipHeight = Cast<i32>(texture.m_Extent.height);
|
||||||
|
|
@ -157,7 +154,8 @@ ModelLoader::LoadImage(vk::CommandBuffer commandBuffer, StagingBuffer *stagingBu
|
||||||
.baseArrayLayer = 0,
|
.baseArrayLayer = 0,
|
||||||
.layerCount = 1,
|
.layerCount = 1,
|
||||||
},
|
},
|
||||||
.srcOffsets = std::array{
|
.srcOffsets =
|
||||||
|
std::array{
|
||||||
vk::Offset3D{0, 0, 0},
|
vk::Offset3D{0, 0, 0},
|
||||||
vk::Offset3D{prevMipWidth, prevMipHeight, 1},
|
vk::Offset3D{prevMipWidth, prevMipHeight, 1},
|
||||||
},
|
},
|
||||||
|
|
@ -168,7 +166,8 @@ ModelLoader::LoadImage(vk::CommandBuffer commandBuffer, StagingBuffer *stagingBu
|
||||||
.baseArrayLayer = 0,
|
.baseArrayLayer = 0,
|
||||||
.layerCount = 1,
|
.layerCount = 1,
|
||||||
},
|
},
|
||||||
.dstOffsets = std::array{
|
.dstOffsets =
|
||||||
|
std::array{
|
||||||
vk::Offset3D{0, 0, 0},
|
vk::Offset3D{0, 0, 0},
|
||||||
vk::Offset3D{currentMipWidth, currentMipHeight, 1},
|
vk::Offset3D{currentMipWidth, currentMipHeight, 1},
|
||||||
},
|
},
|
||||||
|
|
@ -513,7 +512,8 @@ ModelLoader::LoadModel(cstr path, cstr name, bool batched)
|
||||||
{
|
{
|
||||||
if (model.defaultScene >= 0)
|
if (model.defaultScene >= 0)
|
||||||
{
|
{
|
||||||
eastl::function<void(i32,i32)> processNode = [&processNode, &model, &nodes, &meshPrimRanges, &meshPrimitives](i32 idx, i32 parent) -> void {
|
eastl::function<void(i32, i32)> processNode = [&processNode, &model, &nodes, &meshPrimRanges,
|
||||||
|
&meshPrimitives](i32 idx, i32 parent) -> void {
|
||||||
const auto *node = &model.nodes[idx];
|
const auto *node = &model.nodes[idx];
|
||||||
|
|
||||||
vec3 nodeTranslation = vec3{0.0f};
|
vec3 nodeTranslation = vec3{0.0f};
|
||||||
|
|
@ -537,8 +537,8 @@ ModelLoader::LoadModel(cstr path, cstr name, bool batched)
|
||||||
{
|
{
|
||||||
nodeMatrix = glm::make_mat4(node->matrix.data());
|
nodeMatrix = glm::make_mat4(node->matrix.data());
|
||||||
}
|
}
|
||||||
const mat4 transform =
|
const mat4 transform = translate(mat4(1.0f), nodeTranslation) * mat4_cast(nodeRotation) *
|
||||||
translate(mat4(1.0f), nodeTranslation) * mat4_cast(nodeRotation) * scale(mat4(1.0f), nodeScale) * nodeMatrix;
|
scale(mat4(1.0f), nodeScale) * nodeMatrix;
|
||||||
|
|
||||||
const i32 nodeArrayIndex = Cast<i32>(nodes.Add(transform, parent));
|
const i32 nodeArrayIndex = Cast<i32>(nodes.Add(transform, parent));
|
||||||
if (node->mesh >= 0)
|
if (node->mesh >= 0)
|
||||||
|
|
@ -633,12 +633,14 @@ ModelLoader::LoadModel(cstr path, cstr name, bool batched)
|
||||||
.m_NodeHandle = nodeHandle,
|
.m_NodeHandle = nodeHandle,
|
||||||
};
|
};
|
||||||
|
|
||||||
return Model{m_ResourceManager, std::move(textureHandles), std::move(nodes),
|
return Model{
|
||||||
handles, indexBuffer, meshPrimitives, };
|
m_ResourceManager, std::move(textureHandles), std::move(nodes), handles, indexBuffer, meshPrimitives,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Model::Model(GpuResourceManager *resourceManager, eastl::vector<TextureHandle> &&textureHandles, Nodes &&nodes,
|
Model::Model(GpuResourceManager *resourceManager, eastl::vector<TextureHandle> &&textureHandles, Nodes &&nodes,
|
||||||
const ModelHandles &handles, const IndexBuffer &indexBuffer, const eastl::vector<MeshPrimitive> &meshPrimitives)
|
const ModelHandles &handles, const IndexBuffer &indexBuffer,
|
||||||
|
const eastl::vector<MeshPrimitive> &meshPrimitives)
|
||||||
: m_ResourceManager(resourceManager)
|
: m_ResourceManager(resourceManager)
|
||||||
, m_TextureHandles(std::move(textureHandles))
|
, m_TextureHandles(std::move(textureHandles))
|
||||||
, m_Nodes(std::move(nodes))
|
, m_Nodes(std::move(nodes))
|
||||||
|
|
@ -741,12 +743,13 @@ ModelLoader::~ModelLoader()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelLoader::ModelLoader(ModelLoader &&other) noexcept: m_ResourceManager(Take(other.m_ResourceManager)),
|
ModelLoader::ModelLoader(ModelLoader &&other) noexcept
|
||||||
m_CommandPool(other.m_CommandPool),
|
: m_ResourceManager(Take(other.m_ResourceManager))
|
||||||
m_CommandBuffer(other.m_CommandBuffer),
|
, m_CommandPool(other.m_CommandPool)
|
||||||
m_TransferQueue(other.m_TransferQueue),
|
, m_CommandBuffer(other.m_CommandBuffer)
|
||||||
m_TransferQueueIndex(other.m_TransferQueueIndex),
|
, m_TransferQueue(other.m_TransferQueue)
|
||||||
m_GraphicsQueueIndex(other.m_GraphicsQueueIndex)
|
, m_TransferQueueIndex(other.m_TransferQueueIndex)
|
||||||
|
, m_GraphicsQueueIndex(other.m_GraphicsQueueIndex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,8 @@ struct Model
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
Model(GpuResourceManager *resourceManager, eastl::vector<TextureHandle> &&textureHandles, Nodes &&nodes,
|
Model(GpuResourceManager *resourceManager, eastl::vector<TextureHandle> &&textureHandles, Nodes &&nodes,
|
||||||
const ModelHandles& handles, const IndexBuffer &indexBuffer, const eastl::vector<MeshPrimitive> &meshPrimitives);
|
const ModelHandles &handles, const IndexBuffer &indexBuffer,
|
||||||
|
const eastl::vector<MeshPrimitive> &meshPrimitives);
|
||||||
~Model();
|
~Model();
|
||||||
|
|
||||||
Model(Model &&other) noexcept;
|
Model(Model &&other) noexcept;
|
||||||
|
|
@ -91,8 +92,8 @@ struct ModelLoader
|
||||||
u32 m_TransferQueueIndex;
|
u32 m_TransferQueueIndex;
|
||||||
u32 m_GraphicsQueueIndex;
|
u32 m_GraphicsQueueIndex;
|
||||||
|
|
||||||
TextureHandle LoadImage(vk::CommandBuffer commandBuffer, StagingBuffer *stagingBuffer,
|
TextureHandle
|
||||||
tinygltf::Image *image) const;
|
LoadImage(vk::CommandBuffer commandBuffer, StagingBuffer *stagingBuffer, tinygltf::Image *image) const;
|
||||||
Model LoadModel(cstr path, cstr name = nullptr, bool batched = false);
|
Model LoadModel(cstr path, cstr name = nullptr, bool batched = false);
|
||||||
|
|
||||||
constexpr static auto ANormal = "NORMAL";
|
constexpr static auto ANormal = "NORMAL";
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "light_manager.h"
|
#include "light_manager.h"
|
||||||
|
|
||||||
|
#include "gpu_resource_manager.h"
|
||||||
#include "model_loader.h"
|
#include "model_loader.h"
|
||||||
#include "pipeline_utils.h"
|
#include "pipeline_utils.h"
|
||||||
#include "gpu_resource_manager.h"
|
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
|
|
@ -285,11 +285,11 @@ main(int, char **)
|
||||||
|
|
||||||
for (auto &prim : model.m_MeshPrimitives)
|
for (auto &prim : model.m_MeshPrimitives)
|
||||||
{
|
{
|
||||||
cmd.pushConstants(pipeline.m_Layout, vk::ShaderStageFlagBits::eAll, pcbOffset,
|
cmd.pushConstants(pipeline.m_Layout, vk::ShaderStageFlagBits::eAll, pcbOffset, sizeof prim.m_MaterialIdx,
|
||||||
sizeof prim.m_MaterialIdx, &prim.m_MaterialIdx);
|
&prim.m_MaterialIdx);
|
||||||
pcbOffset += sizeof prim.m_MaterialIdx;
|
pcbOffset += sizeof prim.m_MaterialIdx;
|
||||||
cmd.pushConstants(pipeline.m_Layout, vk::ShaderStageFlagBits::eAll, pcbOffset,
|
cmd.pushConstants(pipeline.m_Layout, vk::ShaderStageFlagBits::eAll, pcbOffset, sizeof prim.m_TransformIdx,
|
||||||
sizeof prim.m_TransformIdx, &prim.m_TransformIdx);
|
&prim.m_TransformIdx);
|
||||||
pcbOffset += sizeof prim.m_TransformIdx;
|
pcbOffset += sizeof prim.m_TransformIdx;
|
||||||
cmd.drawIndexed(prim.m_IndexCount, 1, prim.m_FirstIndex, Cast<i32>(prim.m_VertexOffset), 0);
|
cmd.drawIndexed(prim.m_IndexCount, 1, prim.m_FirstIndex, Cast<i32>(prim.m_VertexOffset), 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
#include "pipeline_utils.h"
|
#include "pipeline_utils.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "gpu_resource_manager.h"
|
#include "gpu_resource_manager.h"
|
||||||
|
#include "helpers.h"
|
||||||
#include "swapchain.h"
|
#include "swapchain.h"
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue