MSVC fixes.
This commit is contained in:
parent
69aa72770f
commit
362468ebe7
|
|
@ -10,7 +10,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
|||
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "/W4 /GR- /Zi")
|
||||
add_compile_definitions(_HAS_EXCEPTIONS=1)
|
||||
add_compile_definitions(_HAS_EXCEPTIONS=0)
|
||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||
else ()
|
||||
set(CMAKE_CXX_FLAGS "-Wall -g -fno-rtti -fno-exceptions")
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ Buffer::Allocate(const Device *device, usize size, vk::BufferUsageFlags bufferUs
|
|||
m_Buffer = buffer;
|
||||
m_Size = size | VALID_BUFFER_BIT | (hostAccessible ? HOST_ACCESSIBLE_BIT : 0);
|
||||
m_Allocation = allocation;
|
||||
m_Mapped = allocationInfo.pMappedData;
|
||||
m_Mapped = Cast<u8 *>(allocationInfo.pMappedData);
|
||||
|
||||
device->SetName(m_Buffer, name);
|
||||
}
|
||||
|
|
@ -61,11 +61,13 @@ Buffer::Write(const Device *device, usize offset, usize size, const void *data)
|
|||
|
||||
if (!IsMapped())
|
||||
{
|
||||
auto result = Cast<vk::Result>(vmaMapMemory(device->m_Allocator, m_Allocation, &m_Mapped));
|
||||
void *mapped;
|
||||
auto result = Cast<vk::Result>(vmaMapMemory(device->m_Allocator, m_Allocation, &mapped));
|
||||
ERROR_IF(Failed(result), "Memory mapping failed. Cause: {}", result);
|
||||
if (!Failed(result))
|
||||
{
|
||||
memcpy(m_Mapped, data, size);
|
||||
m_Mapped = Cast<u8 *>(mapped);
|
||||
memcpy(m_Mapped + offset, data, size);
|
||||
|
||||
vmaUnmapMemory(device->m_Allocator, m_Allocation);
|
||||
m_Mapped = nullptr;
|
||||
|
|
@ -73,7 +75,7 @@ Buffer::Write(const Device *device, usize offset, usize size, const void *data)
|
|||
}
|
||||
else
|
||||
{
|
||||
memcpy(m_Mapped, data, size);
|
||||
memcpy(m_Mapped + offset, data, size);
|
||||
}
|
||||
|
||||
// TODO: Debug this.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ struct Buffer
|
|||
{
|
||||
vk::Buffer m_Buffer = nullptr;
|
||||
VmaAllocation m_Allocation = nullptr;
|
||||
void *m_Mapped = nullptr;
|
||||
u8 *m_Mapped = nullptr;
|
||||
|
||||
[[nodiscard]] usize GetSize() const;
|
||||
[[nodiscard]] bool IsHostVisible() const;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ Texture::Init(const Device *device, const vk::Extent2D extent, vk::Format imageF
|
|||
m_View = view;
|
||||
m_Allocation = allocation;
|
||||
m_Extent = {extent.width, extent.height, 1};
|
||||
m_MipLevels = mipLevels;
|
||||
m_MipLevels = Cast<u8>(mipLevels);
|
||||
|
||||
device->SetName(m_Image, name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ FrameManager::GetNextFrame(Swapchain *swapchain, const Window *window)
|
|||
AbortIfFailedMV(m_Device->m_Device.waitForFences(1, ¤tFrame->m_FrameAvailableFence, true, MaxValue<u64>),
|
||||
"Waiting for fence {} failed.", frameIndex);
|
||||
|
||||
u32 imageIndex;
|
||||
u32 imageIndex = 0;
|
||||
bool imageAcquired = false;
|
||||
while (!imageAcquired)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ main(int, char **)
|
|||
.addressModeU = vk::SamplerAddressMode::eRepeat,
|
||||
.addressModeV = vk::SamplerAddressMode::eRepeat,
|
||||
.addressModeW = vk::SamplerAddressMode::eRepeat,
|
||||
.mipLodBias = 0.2,
|
||||
.mipLodBias = 0.2f,
|
||||
.anisotropyEnable = true,
|
||||
.maxAnisotropy = 1.0f,
|
||||
.compareEnable = false,
|
||||
|
|
|
|||
|
|
@ -29,10 +29,23 @@ VectorToVec4(const std::vector<double> &vec)
|
|||
{
|
||||
return vec4{0.0f};
|
||||
}
|
||||
assert(vec.size() == 4);
|
||||
|
||||
return {vec[0], vec[1], vec[2], vec[3]};
|
||||
}
|
||||
|
||||
vec3
|
||||
VectorToVec3(const std::vector<double> &vec)
|
||||
{
|
||||
if (vec.empty())
|
||||
{
|
||||
return vec3{0.0f};
|
||||
}
|
||||
assert(vec.size() == 3);
|
||||
|
||||
return {vec[0], vec[1], vec[2]};
|
||||
}
|
||||
|
||||
TextureHandle
|
||||
ModelLoader::LoadImage(vk::CommandBuffer commandBuffer, Texture *texture, StagingBuffer *stagingBuffer,
|
||||
tinygltf::Image *image)
|
||||
|
|
@ -228,7 +241,7 @@ ModelLoader::LoadModel(cstr path, cstr name)
|
|||
|
||||
if (!model.images.empty())
|
||||
{
|
||||
u32 numImages = model.images.size();
|
||||
u32 numImages = Cast<u32>(model.images.size());
|
||||
|
||||
stagingBuffers.resize(numImages);
|
||||
textures.resize(numImages);
|
||||
|
|
@ -264,7 +277,7 @@ ModelLoader::LoadModel(cstr path, cstr name)
|
|||
{
|
||||
materials.push_back({
|
||||
.m_AlbedoFactor = VectorToVec4(material.pbrMetallicRoughness.baseColorFactor),
|
||||
.m_EmissionFactor = VectorToVec4(material.emissiveFactor),
|
||||
.m_EmissionFactor = VectorToVec3(material.emissiveFactor),
|
||||
.m_MetalFactor = Cast<f32>(material.pbrMetallicRoughness.metallicFactor),
|
||||
.m_RoughFactor = Cast<f32>(material.pbrMetallicRoughness.roughnessFactor),
|
||||
.m_AlbedoTex = getTextureHandle(material.pbrMetallicRoughness.baseColorTexture.index),
|
||||
|
|
@ -299,9 +312,9 @@ ModelLoader::LoadModel(cstr path, cstr name)
|
|||
{
|
||||
for (auto &prim : mesh.primitives)
|
||||
{
|
||||
u32 vertexOffset = vertexPositions.size();
|
||||
u32 vertexOffset = Cast<u32>(vertexPositions.size());
|
||||
u32 vertexCount;
|
||||
u32 indexOffset = indices.size();
|
||||
u32 indexOffset = Cast<u32>(indices.size());
|
||||
u32 indexCount;
|
||||
|
||||
assert(prim.attributes.contains(APosition));
|
||||
|
|
@ -315,7 +328,7 @@ ModelLoader::LoadModel(cstr path, cstr name)
|
|||
tinygltf::Buffer *posBuffer = &model.buffers[posBufferView->buffer];
|
||||
usize byteOffset = (posAccessor->byteOffset + posBufferView->byteOffset);
|
||||
|
||||
vertexCount = posAccessor->count;
|
||||
vertexCount = Cast<u32>(posAccessor->count);
|
||||
vertexPositions.reserve(vertexOffset + vertexCount);
|
||||
|
||||
if (posAccessor->type == TINYGLTF_TYPE_VEC4)
|
||||
|
|
@ -351,7 +364,7 @@ ModelLoader::LoadModel(cstr path, cstr name)
|
|||
tinygltf::Buffer *indexBuffer = &model.buffers[indexBufferView->buffer];
|
||||
usize byteOffset = (indexAccessor->byteOffset + indexBufferView->byteOffset);
|
||||
|
||||
indexCount = indexAccessor->count;
|
||||
indexCount = Cast<u32>(indexAccessor->count);
|
||||
indices.reserve(indexOffset + indexCount);
|
||||
|
||||
if (indexAccessor->componentType == TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ struct MeshPrimitive
|
|||
struct Material
|
||||
{
|
||||
vec4 m_AlbedoFactor;
|
||||
vec4 m_EmissionFactor;
|
||||
vec3 m_EmissionFactor;
|
||||
f32 m_MetalFactor;
|
||||
f32 m_RoughFactor;
|
||||
TextureHandle m_AlbedoTex;
|
||||
|
|
|
|||
|
|
@ -128,10 +128,11 @@ RenderResourceManager::Update()
|
|||
if (m_Writes.empty() || m_WriteInfos.empty())
|
||||
return;
|
||||
|
||||
m_Device->m_Device.updateDescriptorSets(m_Writes.size(), m_Writes.data(), 0, nullptr);
|
||||
m_Device->m_Device.updateDescriptorSets(Cast<u32>(m_Writes.size()), m_Writes.data(), 0, nullptr);
|
||||
|
||||
m_Writes.clear();
|
||||
m_WriteInfos.clear();
|
||||
m_WriteOwner.clear();
|
||||
}
|
||||
|
||||
RenderResourceManager::RenderResourceManager(const Device *device, u16 maxSize)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct VertexData {
|
|||
|
||||
struct MaterialData {
|
||||
float m_AlbedoFactor[4];
|
||||
float m_EmissionFactor[4];
|
||||
float m_EmissionFactor[3];
|
||||
float m_MetalFactor;
|
||||
float m_RoughFactor;
|
||||
uint m_AlbedoTex;
|
||||
|
|
@ -38,9 +38,9 @@ layout(push_constant) uniform Block {
|
|||
};
|
||||
|
||||
vec4 ToVec4(float array[4]) {
|
||||
return vec4(array[0],array[1],array[2],array[3]);
|
||||
return vec4(array[0], array[1], array[2], array[3]);
|
||||
}
|
||||
|
||||
void main() {
|
||||
outColor = ToVec4(materialsBuffer[materialBufferHandle].data[materialIdx].m_AlbedoFactor); // vec4(texture(textures[textureHandle], inUV).rgb, 1.0f);
|
||||
outColor = ToVec4(materialsBuffer[materialBufferHandle].data[materialIdx].m_AlbedoFactor);// vec4(texture(textures[textureHandle], inUV).rgb, 1.0f);
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ struct VertexData {
|
|||
|
||||
struct MaterialData {
|
||||
float m_AlbedoFactor[4];
|
||||
float m_EmissionFactor[4];
|
||||
float m_EmissionFactor[3];
|
||||
float m_MetalFactor;
|
||||
float m_RoughFactor;
|
||||
uint m_AlbedoTex;
|
||||
|
|
@ -56,6 +56,6 @@ layout(push_constant) uniform Block {
|
|||
};
|
||||
|
||||
void main() {
|
||||
// outUV = GetUV(vertexBufferHandle, gl_VertexIndex);
|
||||
// outUV = GetUV(vertexBufferHandle, gl_VertexIndex);
|
||||
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(GetPosition(vertexBufferHandle, gl_VertexIndex), 1.0f);
|
||||
}
|
||||
Loading…
Reference in New Issue