Skip to content

Commit

Permalink
update to compile with clang
Browse files Browse the repository at this point in the history
  • Loading branch information
tadgem committed Jul 10, 2024
1 parent 3f33325 commit 509cdca
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lvk/include/Im3D/shaders/im3d_lines.frag.spv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#pragma warning( disable : 4838)
#pragma warning( disable : 4309)

const char im3d_lines_frag_spv_bin[956] = {
const unsigned char im3d_lines_frag_spv_bin[956] = {
0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x0D, 0x00, 0x21, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x06, 0x00,
0x01, 0x00, 0x00, 0x00, 0x47, 0x4C, 0x53, 0x4C, 0x2E, 0x73, 0x74, 0x64, 0x2E, 0x34, 0x35, 0x30,
Expand Down
2 changes: 1 addition & 1 deletion lvk/include/Im3D/shaders/im3d_lines.vert.spv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#pragma warning( disable : 4838)
#pragma warning( disable : 4309)

const char im3d_lines_vert_spv_bin[5528] = {
const unsigned char im3d_lines_vert_spv_bin[5528] = {
0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x0D, 0x00, 0xDB, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x06, 0x00,
0x01, 0x00, 0x00, 0x00, 0x47, 0x4C, 0x53, 0x4C, 0x2E, 0x73, 0x74, 0x64, 0x2E, 0x34, 0x35, 0x30,
Expand Down
2 changes: 1 addition & 1 deletion lvk/include/Im3D/shaders/im3d_points.frag.spv.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#pragma warning( disable : 4309)


const char im3d_points_frag_spv_bin[996] = {
const unsigned char im3d_points_frag_spv_bin[996] = {
0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x0D, 0x00, 0x24, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x06, 0x00,
0x01, 0x00, 0x00, 0x00, 0x47, 0x4C, 0x53, 0x4C, 0x2E, 0x73, 0x74, 0x64, 0x2E, 0x34, 0x35, 0x30,
Expand Down
2 changes: 1 addition & 1 deletion lvk/include/Im3D/shaders/im3d_points.vert.spv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#pragma warning( disable : 4838)
#pragma warning( disable : 4309)

const char im3d_points_vert_spv_bin[4092] = {
const unsigned char im3d_points_vert_spv_bin[4092] = {
0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x0D, 0x00, 0x9A, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x06, 0x00,
0x01, 0x00, 0x00, 0x00, 0x47, 0x4C, 0x53, 0x4C, 0x2E, 0x73, 0x74, 0x64, 0x2E, 0x34, 0x35, 0x30,
Expand Down
2 changes: 1 addition & 1 deletion lvk/include/Im3D/shaders/im3d_tris.frag.spv.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#pragma warning( disable : 4309)


const char im3d_tris_frag_spv_bin[524] = {
const unsigned char im3d_tris_frag_spv_bin[524] = {
0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x0D, 0x00, 0x0F, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x06, 0x00,
0x01, 0x00, 0x00, 0x00, 0x47, 0x4C, 0x53, 0x4C, 0x2E, 0x73, 0x74, 0x64, 0x2E, 0x34, 0x35, 0x30,
Expand Down
2 changes: 1 addition & 1 deletion lvk/include/Im3D/shaders/im3d_tris.vert.spv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#pragma warning( disable : 4838)
#pragma warning( disable : 4309)

const char im3d_tris_vert_spv_bin[3200] = {
const unsigned char im3d_tris_vert_spv_bin[3200] = {
0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x0D, 0x00, 0x72, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x06, 0x00,
0x01, 0x00, 0x00, 0x00, 0x47, 0x4C, 0x53, 0x4C, 0x2E, 0x73, 0x74, 0x64, 0x2E, 0x34, 0x35, 0x30,
Expand Down
2 changes: 1 addition & 1 deletion lvk/include/lvk/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace lvk
return { stageBin, pushConstants, stageLayoutDatas, stageType };
}

static ShaderStage Create(VulkanAPI& vk, Vector<char>& binary, const ShaderStage::Type& type)
static ShaderStage Create(VulkanAPI& vk, Vector<unsigned char>& binary, const ShaderStage::Type& type)
{
auto stageLayoutDatas = vk.ReflectDescriptorSetLayouts(binary);
auto pushConstants = vk.ReflectPushConstants(binary);
Expand Down
8 changes: 4 additions & 4 deletions lvk/include/lvk/VulkanAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace lvk

class VulkanAPIWindowHandle {};

using StageBinary = std::vector<char>;
using StageBinary = std::vector<unsigned char>;
static constexpr int MAX_FRAMES_IN_FLIGHT = 2;


Expand Down Expand Up @@ -392,12 +392,12 @@ namespace lvk
class Mesh
{
public:
VkBuffer m_VertexBuffer;
VkBuffer m_VertexBuffer = VK_NULL_HANDLE;
VmaAllocation m_VertexBufferMemory;
VkBuffer m_IndexBuffer;
VkBuffer m_IndexBuffer = VK_NULL_HANDLE;
VmaAllocation m_IndexBufferMemory;

uint32_t m_IndexCount;
uint32_t m_IndexCount = 0;

static Mesh* g_ScreenSpaceQuad;

Expand Down
30 changes: 16 additions & 14 deletions lvk/src/Im3D/im3d_lvk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

namespace lvk
{
Vector<char> ToVector(const char* src, uint32_t count)
Vector<unsigned char> ToVector(const unsigned char* src, uint32_t count)
{
Vector<char> chars{};
Vector<unsigned char> chars{};
for (uint32_t i = 0; i < count; i++)
{
chars.push_back(src[i]);
Expand All @@ -24,21 +24,21 @@ namespace lvk

LvkIm3dState LoadIm3D(VulkanAPI& vk)
{
Vector<char> tris_vert_bin = ToVector(&im3d_tris_vert_spv_bin[0], (uint32_t)im3d_tris_vert_spv_bin_SIZE);
Vector<unsigned char> tris_vert_bin = ToVector(&im3d_tris_vert_spv_bin[0], (uint32_t)im3d_tris_vert_spv_bin_SIZE);
ShaderStage tris_vert = ShaderStage::Create(vk, tris_vert_bin, ShaderStage::Type::Vertex);
Vector<char> tris_frag_bin = ToVector(&im3d_tris_frag_spv_bin[0], (uint32_t)im3d_tris_frag_spv_bin_SIZE);
Vector<unsigned char> tris_frag_bin = ToVector(&im3d_tris_frag_spv_bin[0], (uint32_t)im3d_tris_frag_spv_bin_SIZE);
ShaderStage tris_frag = ShaderStage::Create(vk, tris_frag_bin, ShaderStage::Type::Fragment);
ShaderProgram tris_prog = ShaderProgram::Create(vk, tris_vert, tris_frag);

Vector<char> lines_vert_bin = ToVector(&im3d_lines_vert_spv_bin[0], (uint32_t)im3d_lines_vert_spv_bin_SIZE);
Vector<unsigned char> lines_vert_bin = ToVector(&im3d_lines_vert_spv_bin[0], (uint32_t)im3d_lines_vert_spv_bin_SIZE);
ShaderStage lines_vert = ShaderStage::Create(vk, lines_vert_bin, ShaderStage::Type::Vertex);
Vector<char> lines_frag_bin = ToVector(&im3d_lines_frag_spv_bin[0], (uint32_t)im3d_lines_frag_spv_bin_SIZE);
Vector<unsigned char> lines_frag_bin = ToVector(&im3d_lines_frag_spv_bin[0], (uint32_t)im3d_lines_frag_spv_bin_SIZE);
ShaderStage lines_frag = ShaderStage::Create(vk, lines_frag_bin, ShaderStage::Type::Fragment);
ShaderProgram lines_prog = ShaderProgram::Create(vk, lines_vert, lines_frag);

Vector<char> points_vert_bin = ToVector(&im3d_points_vert_spv_bin[0], (uint32_t)im3d_points_vert_spv_bin_SIZE);
Vector<unsigned char> points_vert_bin = ToVector(&im3d_points_vert_spv_bin[0], (uint32_t)im3d_points_vert_spv_bin_SIZE);
ShaderStage points_vert = ShaderStage::Create(vk, points_vert_bin, ShaderStage::Type::Vertex);
Vector<char> points_frag_bin = ToVector(&im3d_points_frag_spv_bin[0], (uint32_t)im3d_points_frag_spv_bin_SIZE);
Vector<unsigned char> points_frag_bin = ToVector(&im3d_points_frag_spv_bin[0], (uint32_t)im3d_points_frag_spv_bin_SIZE);
ShaderStage points_frag = ShaderStage::Create(vk, points_frag_bin, ShaderStage::Type::Fragment);
ShaderProgram points_prog = ShaderProgram::Create(vk, points_vert, points_frag);

Expand All @@ -61,11 +61,13 @@ namespace lvk

LvkIm3dViewState AddIm3dForViewport(VulkanAPI& vk, LvkIm3dState& state, VkRenderPass renderPass, bool enableMSAA)
{
auto bindingDescriptions = Vector<VkVertexInputBindingDescription>{VertexDataPos4::GetBindingDescription() };
auto attrbuteDescriptions = VertexDataPos4::GetAttributeDescriptions();
VkPipelineLayout tris_layout;
VkPipeline tris_pipeline = vk.CreateRasterizationGraphicsPipeline(
state.m_TriProg,
Vector<VkVertexInputBindingDescription>{VertexDataPos4::GetBindingDescription() },
VertexDataPos4::GetAttributeDescriptions(),
bindingDescriptions,
attrbuteDescriptions,
renderPass,
vk.m_SwapChainImageExtent.width, vk.m_SwapChainImageExtent.height,
VK_POLYGON_MODE_FILL, VK_CULL_MODE_NONE, enableMSAA,
Expand All @@ -75,8 +77,8 @@ namespace lvk
VkPipelineLayout points_layout;
VkPipeline points_pipeline = vk.CreateRasterizationGraphicsPipeline(
state.m_PointsProg,
Vector<VkVertexInputBindingDescription>{VertexDataPos4::GetBindingDescription() },
VertexDataPos4::GetAttributeDescriptions(),
bindingDescriptions,
attrbuteDescriptions,
renderPass,
vk.m_SwapChainImageExtent.width, vk.m_SwapChainImageExtent.height,
VK_POLYGON_MODE_POINT, VK_CULL_MODE_NONE, enableMSAA,
Expand All @@ -87,8 +89,8 @@ namespace lvk
VkPipelineLayout lines_layout;
VkPipeline lines_pipeline = vk.CreateRasterizationGraphicsPipeline(
state.m_LinesProg,
Vector<VkVertexInputBindingDescription>{VertexDataPos4::GetBindingDescription() },
VertexDataPos4::GetAttributeDescriptions(),
bindingDescriptions,
attrbuteDescriptions,
renderPass,
vk.m_SwapChainImageExtent.width, vk.m_SwapChainImageExtent.height,
VK_POLYGON_MODE_LINE, VK_CULL_MODE_NONE, enableMSAA,
Expand Down
5 changes: 3 additions & 2 deletions lvk/src/lvk/VulkanAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,8 @@ StageBinary lvk::VulkanAPI::LoadSpirvBinary(const String& path)
StageBinary data(fileSize);

file.seekg(0);
file.read(data.data(), fileSize);

file.read((char*) data.data(), fileSize);

file.close();
return data;
Expand Down Expand Up @@ -1723,7 +1724,7 @@ VkPipeline lvk::VulkanAPI::CreateComputePipeline(StageBinary& comp, VkDescriptor
return pipeline;
}


return VK_NULL_HANDLE;
}

Vector<VkDescriptorSetLayoutBinding> lvk::VulkanAPI::GetDescriptorSetLayoutBindings(Vector<DescriptorSetLayoutData>& vertLayoutDatas, Vector<DescriptorSetLayoutData>& fragLayoutDatas)
Expand Down

0 comments on commit 509cdca

Please sign in to comment.