1 Commits

Author SHA1 Message Date
mo7sen 4cfd12797e Removed shaderc.wrap
Test Compilation / Run tests (push) Failing after 1m3s
2026-05-06 01:23:25 +03:00
23 changed files with 88 additions and 262 deletions
-17
View File
@@ -1,17 +0,0 @@
root = true
# All (Defaults)
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = true
max_line_length = 80
indent_style = space
indent_size = 2
# C
# [*.{c,h}]
# indent_style = space
# indent_size = 2
+1 -66
View File
@@ -3,7 +3,7 @@ run-name: ${{github.event_name}} - Build evk - ${{github.sha}}
on: [push] on: [push]
jobs: jobs:
Build evk: Run tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
@@ -11,71 +11,6 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Cache shaderc
id: cache-shaderc
uses: actions/cache@v4
env:
cache-name: cache-shaderc-src
with:
path: |
subprojects/shaderc/
build/subprojects/shaderc/
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('subprojects/shaderc.wrap', 'subprojects/packagefiles/shaderc/**/*') }}
- name: Cache VMA
id: cache-vma
uses: actions/cache@v4
env:
cache-name: cache-vma
with:
path: |
subprojects/vma/
build/subprojects/vma/
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('subprojects/vma.wrap', 'subprojects/packagefiles/vma/**/*') }}
- name: Cache volk
id: cache-volk
uses: actions/cache@v4
env:
cache-name: cache-volk
with:
path: |
subprojects/volk/
build/subprojects/volk/
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('subprojects/volk.wrap', 'subprojects/packagefiles/volk/**/*') }}
- name: Cache SPIRV-Reflect
id: cache-spvref
uses: actions/cache@v4
env:
cache-name: cache-spvref
with:
path: |
subprojects/spvref/
build/subprojects/spvref/
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('subprojects/spvref.wrap', 'subprojects/packagefiles/spvref/**/*') }}
- name: Cache GLFW
id: cache-glfw
uses: actions/cache@v4
env:
cache-name: cache-glfw
with:
path: |
subprojects/glfw/
build/subprojects/glfw/
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('subprojects/glfw.wrap', 'subprojects/packagefiles/glfw/**/*') }}
- name: Cache ninja
id: cache-ninja
uses: actions/cache@v4
env:
cache-name: cache-ninja
with:
path: |
build/.ninja_log
build/.ninja_deps
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Configure - name: Configure
run: meson setup build run: meson setup build
-3
View File
@@ -59,6 +59,3 @@ compile_commands.json
/subprojects/* /subprojects/*
!/subprojects/*.wrap !/subprojects/*.wrap
!/subprojects/packagefiles !/subprojects/packagefiles
# Internal wrap that is moved here during the configure step
/subprojects/shaderc_cmake.wrap
+6 -6
View File
@@ -88,9 +88,9 @@ static inline const char* VkResultStrings(VkResult res) {
} }
}; };
static VkResult __evk_check_result_internal; #define EVK_ASSERT(fn) do { \
#define EVK_CHECK(fn) ( \ VkResult __vk_assert_result_internal = fn; \
__evk_check_result_internal = fn, \ if(__vk_assert_result_internal != VK_SUCCESS) { \
__evk_check_result_internal != VK_SUCCESS? \ ev_log_error("[VulkanError] `%s` returned error code %d ('%s')", EV_STRINGIZE(fn), __vk_assert_result_internal, VkResultStrings(__vk_assert_result_internal));\
ev_log_error("[VulkanError] `%s` returned error code %d ('%s')", EV_STRINGIZE(fn), __evk_check_result_internal, VkResultStrings(__evk_check_result_internal)):0, \ } \
__evk_check_result_internal) } while (0)
+4 -4
View File
@@ -71,7 +71,7 @@ evkDevice evkCreateDevice(evkDeviceCreateInfo createInfo)
device._physicalDevice = evkDetectPhysicalDevice(createInfo.instance, createInfo.physicalDeviceType); device._physicalDevice = evkDetectPhysicalDevice(createInfo.instance, createInfo.physicalDeviceType);
device._instance = createInfo.instance; device._instance = createInfo.instance;
VkPhysicalDeviceProperties2 physicalDeviceProperties = { VkPhysicalDeviceProperties2 physicalDeviceProperties = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
}; };
@@ -200,7 +200,7 @@ evkDevice evkCreateDevice(evkDeviceCreateInfo createInfo)
} }
// Allowing the retrieval of non-requested, but allocated, queues is possible. // Allowing the retrieval of non-requested, but allocated, queues is possible.
// Example: Allocating COMPUTE | GRAPHICS then requesting GRAPHICS should // Example: Allocating COMPUTE | GRAPHICS then requesting GRAPHICS should
// return the already allocated queue // return the already allocated queue
for (i32 i = MAX_QUEUE_FAMILIES - 1; i >= 0; i--) { for (i32 i = MAX_QUEUE_FAMILIES - 1; i >= 0; i--) {
for (i32 j = i - 1; j >= 0; j--) { for (i32 j = i - 1; j >= 0; j--) {
@@ -210,7 +210,7 @@ evkDevice evkCreateDevice(evkDeviceCreateInfo createInfo)
} }
} }
EVK_CHECK(vkCreateDevice(device._physicalDevice, &vkDeviceCreateInfo, evkGetAllocationCallbacks(), &device.vk)); EVK_ASSERT(vkCreateDevice(device._physicalDevice, &vkDeviceCreateInfo, evkGetAllocationCallbacks(), &device.vk));
vec_fini(&queueCreateInfoList); vec_fini(&queueCreateInfoList);
vec_fini(&priorities); vec_fini(&priorities);
@@ -221,4 +221,4 @@ evkDevice evkCreateDevice(evkDeviceCreateInfo createInfo)
void evkDestroyDevice(evkDevice device) void evkDestroyDevice(evkDevice device)
{ {
vkDestroyDevice(device.vk, evkGetAllocationCallbacks()); vkDestroyDevice(device.vk, evkGetAllocationCallbacks());
} }
+1 -3
View File
@@ -56,7 +56,6 @@ evkImage evkGPUCreateImage(evkGPUAllocationCreateInfo allocationCreateInfo, VkIm
.flags = allocationCreateInfo.allocationFlags, .flags = allocationCreateInfo.allocationFlags,
.pool = allocationCreateInfo.pool.vma, .pool = allocationCreateInfo.pool.vma,
}; };
img.allocData.allocator = allocationCreateInfo.allocator;
vmaCreateImage(allocationCreateInfo.allocator.vma, imageCreateInfo, &vmaAllocCreateInfo, &img.vk, &img.allocData.allocation.vma, &img.allocData.allocationInfo.vma); vmaCreateImage(allocationCreateInfo.allocator.vma, imageCreateInfo, &vmaAllocCreateInfo, &img.vk, &img.allocData.allocation.vma, &img.allocData.allocationInfo.vma);
@@ -80,7 +79,6 @@ evkBuffer evkGPUCreateBuffer(evkGPUAllocationCreateInfo allocationCreateInfo, Vk
vmaCreateBuffer(allocationCreateInfo.allocator.vma, bufferCreateInfo, &vmaAllocCreateInfo, &buf.vk, &buf.allocData.allocation.vma, &buf.allocData.allocationInfo.vma); vmaCreateBuffer(allocationCreateInfo.allocator.vma, bufferCreateInfo, &vmaAllocCreateInfo, &buf.vk, &buf.allocData.allocation.vma, &buf.allocData.allocationInfo.vma);
buf.usage = bufferCreateInfo->usage; buf.usage = bufferCreateInfo->usage;
buf.allocData.allocator = allocationCreateInfo.allocator;
return buf; return buf;
} }
@@ -88,4 +86,4 @@ evkBuffer evkGPUCreateBuffer(evkGPUAllocationCreateInfo allocationCreateInfo, Vk
void evkGPUDestroyBuffer(evkBuffer buf) void evkGPUDestroyBuffer(evkBuffer buf)
{ {
vmaDestroyBuffer(buf.allocData.allocator.vma, buf.vk, buf.allocData.allocation.vma); vmaDestroyBuffer(buf.allocData.allocator.vma, buf.vk, buf.allocData.allocation.vma);
} }
+3 -8
View File
@@ -37,7 +37,7 @@ void evkDestroyPipelineLayout(evkDevice device, evkPipelineLayout layout)
evkPipeline evkCreateComputePipeline(evkDevice device, evkPipelineCreateInfo createInfo) evkPipeline evkCreateComputePipeline(evkDevice device, evkPipelineCreateInfo createInfo)
{ {
// return EV_INVALID(evkPipeline);
} }
evkPipeline evkCreateGraphicsPipeline(evkDevice device, evkPipelineCreateInfo createInfo) evkPipeline evkCreateGraphicsPipeline(evkDevice device, evkPipelineCreateInfo createInfo)
@@ -183,7 +183,7 @@ evkPipeline evkCreateGraphicsPipeline(evkDevice device, evkPipelineCreateInfo cr
if(createInfo.setLayouts != NULL) if(createInfo.setLayouts != NULL)
{ {
res.layout = evkCreatePipelineLayout(device, res.layout = evkCreatePipelineLayout(device,
EV_DEFAULT(evkPipelineLayoutCreateInfo, EV_DEFAULT(evkPipelineLayoutCreateInfo,
setLayouts = createInfo.setLayouts, setLayouts = createInfo.setLayouts,
) )
@@ -210,7 +210,7 @@ evkPipeline evkCreateGraphicsPipeline(evkDevice device, evkPipelineCreateInfo cr
.layout = res.layout.vk, .layout = res.layout.vk,
}; };
EVK_CHECK(vkCreateGraphicsPipelines(device.vk, VK_NULL_HANDLE, 1, &graphicsPipelineCreateInfo, NULL, &res.vk)); EVK_ASSERT(vkCreateGraphicsPipelines(device.vk, VK_NULL_HANDLE, 1, &graphicsPipelineCreateInfo, NULL, &res.vk));
res._device = device; res._device = device;
@@ -239,8 +239,3 @@ void evkCmdBindPipeline(evkCommandBuffer* cmdbuf, evkPipeline* pipeline)
cmdbuf->boundPipeline = pipeline; cmdbuf->boundPipeline = pipeline;
vkCmdBindPipeline(cmdbuf->vk, (VkPipelineBindPoint)pipeline->type, pipeline->vk); vkCmdBindPipeline(cmdbuf->vk, (VkPipelineBindPoint)pipeline->type, pipeline->vk);
} }
void evkCmdImageBarrier(evkCommandBuffer* cmdbuf, VkImageMemoryBarrier barrier)
{
vkCmdPipelineBarrier(cmdbuf->vk, 0, 0, 0, 0, NULL, 0, NULL, 1, &barrier);
}
-2
View File
@@ -10,5 +10,3 @@ evkPipeline evkCreatePipeline(evkDevice device, evkPipelineCreateInfo createInfo
void evkDestroyPipeline(evkPipeline pipeline); void evkDestroyPipeline(evkPipeline pipeline);
void evkCmdBindPipeline(evkCommandBuffer* cmdbuf, evkPipeline* pipeline); void evkCmdBindPipeline(evkCommandBuffer* cmdbuf, evkPipeline* pipeline);
void evkCmdImageBarrier(evkCommandBuffer* cmdbuf, VkImageMemoryBarrier barrier);
+11 -10
View File
@@ -107,26 +107,27 @@ void evkDestroyShaderCompiler(evkShaderCompiler compiler)
shaderc_compiler_release(compiler.sc); shaderc_compiler_release(compiler.sc);
} }
evkShader evkInitShaderFromString(evkDevice device, evkShaderCompiler compiler,evstring shaderName, evstring shaderText) evkShader evkInitShaderFromFile(evkDevice device, evkShaderCompiler compiler, evstring shaderPath)
{ {
shaderc_compilation_result_t compilation_result = shaderc_compile_into_spv(compiler.sc, shaderText, evstring_getLength(shaderText), shaderc_glsl_infer_from_source, shaderName, "main", compiler.scopt); evstring shaderText = evstring_readFile(shaderPath);
shaderc_compilation_result_t compilation_result = shaderc_compile_into_spv(compiler.sc, shaderText, evstring_getLength(shaderText), shaderc_glsl_infer_from_source, shaderPath, "main", compiler.scopt);
shaderc_compilation_status status = shaderc_result_get_compilation_status(compilation_result); shaderc_compilation_status status = shaderc_result_get_compilation_status(compilation_result);
u32 errorCount = shaderc_result_get_num_errors(compilation_result); u32 errorCount = shaderc_result_get_num_errors(compilation_result);
u32 warnCount = shaderc_result_get_num_warnings(compilation_result); u32 warnCount = shaderc_result_get_num_warnings(compilation_result);
ev_log_info("[[evkShader]] %s Compilation Status: %d ( %d Errors, %d Warnings )", shaderName, status, errorCount, warnCount); ev_log_info("[[evkShader]] %s Compilation Status: %d ( %d Errors, %d Warnings )", shaderPath, status, errorCount, warnCount);
if(errorCount + warnCount > 0) if(errorCount + warnCount > 0)
{ {
ev_log_error("Errors:\n%s", shaderc_result_get_error_message(compilation_result)); ev_log_error("Errors:\n%s", shaderc_result_get_error_message(compilation_result));
} }
return evkInitShaderFromBytes(device, (u8*)shaderc_result_get_bytes(compilation_result), shaderc_result_get_length(compilation_result)); evkShader shader = evkInitShaderFromBytes(device, (u8*)shaderc_result_get_bytes(compilation_result), shaderc_result_get_length(compilation_result));
}
evkShader evkInitShaderFromFile(evkDevice device, evkShaderCompiler compiler, evstring shaderPath) evstring_free(shaderText);
{
evstring shaderText = evstring_readFile(shaderPath); return shader;
return evkInitShaderFromString(device, compiler, shaderPath, shaderText);
} }
VkPipelineShaderStageCreateInfo evkGetShaderStageCreateInfo(evkShader shader) VkPipelineShaderStageCreateInfo evkGetShaderStageCreateInfo(evkShader shader)
@@ -137,4 +138,4 @@ VkPipelineShaderStageCreateInfo evkGetShaderStageCreateInfo(evkShader shader)
.module = shader.vk, .module = shader.vk,
.pName = "main", .pName = "main",
}; };
} }
+1 -4
View File
@@ -4,9 +4,6 @@
[[nodiscard("Leaking VkShaderModule")]] [[nodiscard("Leaking VkShaderModule")]]
evkShader evkInitShaderFromBytes(evkDevice device, const u8* shaderBytes, u32 shaderLen); evkShader evkInitShaderFromBytes(evkDevice device, const u8* shaderBytes, u32 shaderLen);
[[nodiscard("Leaking VkShaderModule")]]
evkShader evkInitShaderFromString(evkDevice device, evkShaderCompiler compiler, evstring shaderName, evstring shaderText);
[[nodiscard("Leaking VkShaderModule")]]
evkShader evkInitShaderFromFile(evkDevice device, evkShaderCompiler compiler, evstring shaderPath); evkShader evkInitShaderFromFile(evkDevice device, evkShaderCompiler compiler, evstring shaderPath);
void evkDestroyShader(evkDevice device, evkShader shader); void evkDestroyShader(evkDevice device, evkShader shader);
@@ -18,4 +15,4 @@ VkPipelineShaderStageCreateInfo evkGetShaderStageCreateInfo(evkShader shader);
[[nodiscard("Leaking Shader Reflection Data")]] [[nodiscard("Leaking Shader Reflection Data")]]
evkShaderReflectionData evkGenerateShaderReflectionData(const u8* shaderBytes, u32 shaderLen); evkShaderReflectionData evkGenerateShaderReflectionData(const u8* shaderBytes, u32 shaderLen);
void evkDestroyShaderReflectionData(evkShaderReflectionData data); void evkDestroyShaderReflectionData(evkShaderReflectionData data);
+7 -7
View File
@@ -9,7 +9,7 @@ evkSwapChain evkCreateSwapChain(evkSwapChainCreateInfo createInfo)
VkSurfaceCapabilitiesKHR surfaceCaps; VkSurfaceCapabilitiesKHR surfaceCaps;
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(createInfo.device._physicalDevice, createInfo.surface, &surfaceCaps); vkGetPhysicalDeviceSurfaceCapabilitiesKHR(createInfo.device._physicalDevice, createInfo.surface, &surfaceCaps);
if(surfaceCaps.maxImageCount == 0) if(surfaceCaps.maxImageCount == 0)
surfaceCaps.maxImageCount = UInt32.MAX; surfaceCaps.maxImageCount = UInt32.MAX;
VkCompositeAlphaFlagBitsKHR compositeAlpha = VkCompositeAlphaFlagBitsKHR compositeAlpha =
@@ -27,7 +27,7 @@ evkSwapChain evkCreateSwapChain(evkSwapChainCreateInfo createInfo)
VkSurfaceFormatKHR surfaceFormats[surfaceFormatCount]; VkSurfaceFormatKHR surfaceFormats[surfaceFormatCount];
vkGetPhysicalDeviceSurfaceFormatsKHR(createInfo.device._physicalDevice, createInfo.surface, &surfaceFormatCount, surfaceFormats); vkGetPhysicalDeviceSurfaceFormatsKHR(createInfo.device._physicalDevice, createInfo.surface, &surfaceFormatCount, surfaceFormats);
// TODO Add format picking logic // TODO Add format picking logic
swapChain.surfaceFormat = surfaceFormats[0]; swapChain.surfaceFormat = surfaceFormats[0];
u32 buffering = min(max(createInfo.imageCount, surfaceCaps.minImageCount), surfaceCaps.maxImageCount); u32 buffering = min(max(createInfo.imageCount, surfaceCaps.minImageCount), surfaceCaps.maxImageCount);
@@ -56,7 +56,7 @@ evkSwapChain evkCreateSwapChain(evkSwapChainCreateInfo createInfo)
.oldSwapchain = VK_NULL_HANDLE, .oldSwapchain = VK_NULL_HANDLE,
}; };
EVK_CHECK(vkCreateSwapchainKHR(createInfo.device.vk, &swapChainCreateInfo, NULL, &swapChain.vk)); EVK_ASSERT(vkCreateSwapchainKHR(createInfo.device.vk, &swapChainCreateInfo, NULL, &swapChain.vk));
vkGetSwapchainImagesKHR(createInfo.device.vk, swapChain.vk, &buffering, NULL); vkGetSwapchainImagesKHR(createInfo.device.vk, swapChain.vk, &buffering, NULL);
VkImage swapChainVkImages[buffering]; VkImage swapChainVkImages[buffering];
@@ -69,9 +69,9 @@ evkSwapChain evkCreateSwapChain(evkSwapChainCreateInfo createInfo)
for(u32 i = 0; i < buffering; i++) for(u32 i = 0; i < buffering; i++)
{ {
swapChain.images[i] = (evkImage) { swapChain.images[i] = (evkImage) {
.vk = swapChainVkImages[i], .vk = swapChainVkImages[i],
.width = imageExtent.width, .width = imageExtent.width,
.height = imageExtent.height, .height = imageExtent.height,
.format = swapChain.surfaceFormat.format .format = swapChain.surfaceFormat.format
}; };
swapChain.imageViews[i] = evkCreateImageView(createInfo.device, swapChain.images[i], swapChain.imageViews[i] = evkCreateImageView(createInfo.device, swapChain.images[i],
@@ -94,4 +94,4 @@ void evkDestroySwapChain(evkDevice device, evkSwapChain swapChain)
vec_fini(&swapChain.imageViews); vec_fini(&swapChain.imageViews);
vec_fini(&swapChain.images); vec_fini(&swapChain.images);
vkDestroySwapchainKHR(device.vk, swapChain.vk, NULL); vkDestroySwapchainKHR(device.vk, swapChain.vk, NULL);
} }
@@ -6,21 +6,12 @@
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
evstring PROJECT_NAME = evstr("basic_triangle"); evstring PROJECT_NAME = evstr("evk");
char vertexShaderBytes[] = { int main(void)
#embed "shaders/basic_triangle.vert"
,'\0'
};
char fragmentShaderBytes[] = {
#embed "shaders/basic_triangle.frag"
,'\0'
};
int main(void)
{ {
u32 width = 1280; u32 width = 1024;
u32 height = 800; u32 height = 1024;
evkInstance instance = evkCreateInstance((evkInstanceCreateInfo){ evkInstance instance = evkCreateInstance((evkInstanceCreateInfo){
.applicationInfo = EV_DEFAULT(evkApplicationInfo), .applicationInfo = EV_DEFAULT(evkApplicationInfo),
@@ -83,7 +74,7 @@ int main(void)
} }
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow* window = glfwCreateWindow(width, height, "evk", NULL, NULL); GLFWwindow* window = glfwCreateWindow(1024,1024, "evk", NULL, NULL);
if(!window) if(!window)
{ {
ev_log_error("Window Creation Failed."); ev_log_error("Window Creation Failed.");
@@ -91,7 +82,7 @@ int main(void)
} }
VkSurfaceKHR surface; VkSurfaceKHR surface;
VkResult err = EVK_CHECK(glfwCreateWindowSurface(instance.vk, window, NULL, &surface)); VkResult err = glfwCreateWindowSurface(instance.vk, window, NULL, &surface);
if (err) if (err)
{ {
ev_log_error("Surface creation failed."); ev_log_error("Surface creation failed.");
@@ -108,8 +99,8 @@ int main(void)
.imageCount = 3, .imageCount = 3,
}); });
evkCommandPool commandPool = evkCreateCommandPool((evkCommandPoolCreateInfo) { evkCommandPool commandPool = evkCreateCommandPool((evkCommandPoolCreateInfo) {
.device = device, .device = device,
.queueFlags = VK_QUEUE_GRAPHICS_BIT, .queueFlags = VK_QUEUE_GRAPHICS_BIT,
.poolFlags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT .poolFlags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT
}); });
@@ -118,15 +109,9 @@ int main(void)
evkShaderCompiler compiler = evkCreateShaderCompiler(); evkShaderCompiler compiler = evkCreateShaderCompiler();
evstring vertexShaderText = evstring_new(vertexShaderBytes); evkShader vertShader = evkInitShaderFromFile(device, compiler, "shaders/tri.vert");
evstring fragmentShaderText = evstring_new(fragmentShaderBytes); evkShader fragShader = evkInitShaderFromFile(device, compiler, "shaders/tri.frag");
evkShader vertShader = evkInitShaderFromString(device, compiler, evstr("basic_triangle.vert"),vertexShaderText);
evkShader fragShader = evkInitShaderFromString(device, compiler, evstr("basic_triangle.frag"), fragmentShaderText);
evstring_free(vertexShaderText);
evstring_free(fragmentShaderText);
evkDestroyShaderCompiler(compiler); evkDestroyShaderCompiler(compiler);
evkColorAttachment colorAttachment0 = { evkColorAttachment colorAttachment0 = {
@@ -137,26 +122,25 @@ int main(void)
// TODO Get this from shader reflection data // TODO Get this from shader reflection data
// evkDescriptorSetLayout setLayout_0 = evkCreateDescriptorSetLayout( // evkDescriptorSetLayout setLayout_0 = evkCreateDescriptorSetLayout(
// &device, svec_init(evkDescriptorBinding, { // &device, svec_init(evkDescriptorBinding, {
// { // {
// .name = evstr("positions"), // .name = evstr("positions"),
// .binding = 0, // .binding = 0,
// .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, // .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
// .descriptorCount = 1, // .descriptorCount = 1,
// .stageFlags = VK_SHADER_STAGE_ALL_GRAPHICS, // .stageFlags = VK_SHADER_STAGE_ALL_GRAPHICS,
// }, // },
// }) // })
// ); // );
// evkDescriptorSetLayout setLayout_0 = evkCreateDescriptorSetLayoutFromBindings(&device, vertShader.reflect.bindings); // evkDescriptorSetLayout setLayout_0 = evkCreateDescriptorSetLayoutFromBindings(&device, vertShader.reflect.bindings);
evkDescriptorSetLayout setLayout_0 = evkCreateDescriptorSetLayoutFromShaders(&device, svec_init(evkShader, {vertShader, fragShader})); evkDescriptorSetLayout setLayout_0 = evkCreateDescriptorSetLayoutFromShaders(&device, svec_init(evkShader, {vertShader, fragShader}));
evkPipelineCreateInfo pipelineCreateInfo = EV_DEFAULT(evkPipelineCreateInfo, evkPipelineCreateInfo pipelineCreateInfo = EV_DEFAULT(evkPipelineCreateInfo,
dynamicStates = svec_init(VkDynamicState, { dynamicStates = svec_init(VkDynamicState, {
VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR, VK_DYNAMIC_STATE_SCISSOR,
}), }),
shaderStages = svec_init(evkShader, { shaderStages = svec_init(evkShader, {
vertShader, vertShader,
fragShader, fragShader,
}), }),
colorAttachments = svec_init(evkColorAttachment, { colorAttachments = svec_init(evkColorAttachment, {
@@ -174,8 +158,8 @@ int main(void)
); );
evkDescriptorSet set_0 = evkCreateDescriptorSet(&(evkDescriptorSetCreateInfo){ evkDescriptorSet set_0 = evkCreateDescriptorSet(&(evkDescriptorSetCreateInfo){
.device = &device, .device = &device,
.allocator = &allocator, .allocator = &allocator,
.layout = &setLayout_0 .layout = &setLayout_0
}); });
@@ -244,7 +228,7 @@ int main(void)
{ {
imageIdx = (imageIdx + 1) % imageCount; imageIdx = (imageIdx + 1) % imageCount;
u32 swapChainImageIdx; u32 swapChainImageIdx;
EVK_CHECK(vkAcquireNextImageKHR(device.vk, swapChain.vk, UInt64.MAX, imageAcquiredSemaphores[imageIdx], VK_NULL_HANDLE, &swapChainImageIdx)); EVK_ASSERT(vkAcquireNextImageKHR(device.vk, swapChain.vk, UInt64.MAX, imageAcquiredSemaphores[imageIdx], VK_NULL_HANDLE, &swapChainImageIdx));
evkCommandBuffer cmdbuf = commandBuffers[imageIdx]; evkCommandBuffer cmdbuf = commandBuffers[imageIdx];
@@ -262,12 +246,6 @@ int main(void)
evkBeginPrimaryCommandBuffer(&cmdbuf); evkBeginPrimaryCommandBuffer(&cmdbuf);
{ {
evkCmdImageBarrier(&cmdbuf, EV_DEFAULT(VkImageMemoryBarrier,
image = swapChain.images[swapChainImageIdx].vk,
newLayout = VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR,
subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT
));
VkDeviceSize offset = 0; VkDeviceSize offset = 0;
vkCmdBindVertexBuffers(cmdbuf.vk, 0, 1, &vertBuf.vk, &offset); vkCmdBindVertexBuffers(cmdbuf.vk, 0, 1, &vertBuf.vk, &offset);
@@ -283,12 +261,13 @@ int main(void)
vkCmdEndRenderingKHR(cmdbuf.vk); vkCmdEndRenderingKHR(cmdbuf.vk);
evkCmdImageBarrier(&cmdbuf, EV_DEFAULT(VkImageMemoryBarrier, VkImageMemoryBarrier imageMemoryBarrier = EV_DEFAULT(VkImageMemoryBarrier,
image = swapChain.images[swapChainImageIdx].vk, image = swapChain.images[swapChainImageIdx].vk,
oldLayout = VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR,
newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT
)); );
vkCmdPipelineBarrier(cmdbuf.vk, 0, 0, 0, 0, NULL, 0, NULL, 1, &imageMemoryBarrier);
} }
evkEndCommandBuffer(&cmdbuf); evkEndCommandBuffer(&cmdbuf);
@@ -338,9 +317,6 @@ int main(void)
evkDestroyPipeline(graphicsPipeline); evkDestroyPipeline(graphicsPipeline);
evkDestroyBuffer(vertBuf);
evkDestroyBuffer(uniBuf);
evkDestroyDescriptorSet(&device, &set_0); evkDestroyDescriptorSet(&device, &set_0);
evkDestroyDescriptorSetLayout(&device, &setLayout_0); evkDestroyDescriptorSetLayout(&device, &setLayout_0);
@@ -350,8 +326,6 @@ int main(void)
evkFreeCommandBuffers(device, commandPool, commandBuffers); evkFreeCommandBuffers(device, commandPool, commandBuffers);
evkDestroyCommandPool(device, commandPool); evkDestroyCommandPool(device, commandPool);
evkGPUDestroyAllocator(allocator);
evkDestroySwapChain(device, swapChain); evkDestroySwapChain(device, swapChain);
// SwapchainCreationFailed: // SwapchainCreationFailed:
@@ -368,4 +342,4 @@ DeviceCreationFailed:
evkDestroyInstance(instance); evkDestroyInstance(instance);
InstanceCreationFailed: InstanceCreationFailed:
return 0; return 0;
} }
+17 -40
View File
@@ -1,15 +1,6 @@
project( project('evk', ['c','cpp'],
'evk', version : '0.1',
['c', 'cpp'], default_options : ['c_std=c23', 'default_library=static'])
version: '0.1',
default_options: {
'c_std': 'c23',
'default_library': 'static',
'c_args': '-fcolor-diagnostics -fansi-escape-codes',
'cpp_args': '-fcolor-diagnostics -fansi-escape-codes',
},
meson_version: '>=1.2',
)
build_config = configuration_data() build_config = configuration_data()
@@ -30,9 +21,7 @@ disabled_warnings = {
], ],
} }
subproject('evol-headers', default_options: {'build_tests': false}) subproject('evol-headers')
subproject('volk')
subproject('shaderc')
evk_c_args = [] evk_c_args = []
@@ -45,16 +34,16 @@ elif cc.get_id() == 'clang'
endif endif
foreach w : disabled_warnings[cc.get_id()] foreach w : disabled_warnings[cc.get_id()]
evk_c_args += '-Wno-' + w evk_c_args += '-Wno-'+w
endforeach endforeach
evk_incdir = include_directories( evk_incdir = [
[ '.',
'.', ]
],
)
evk_src = [ evk_src = [
'main.c',
'evk/evkInstance.c', 'evk/evkInstance.c',
'evk/evkDevice.c', 'evk/evkDevice.c',
'evk/evkAllocator.c', 'evk/evkAllocator.c',
@@ -71,32 +60,20 @@ evk_src = [
'evk/evkMemory.c', 'evk/evkMemory.c',
] ]
executable(
evk_lib = library(
'evk', 'evk',
evk_src, evk_src,
include_directories: evk_incdir, include_directories: include_directories(evk_incdir),
dependencies: [ dependencies: [
dependency('evol-headers'), dependency('evol-headers'),
dependency('vma'), dependency('vma'),
dependency('volk'), dependency('volk'),
dependency('glfw3'),
dependency('shaderc'), dependency('shaderc'),
dependency('spvref'), dependency('spvref'),
], ],
c_args: evk_c_args, c_args: evk_c_args,
) )
evk_dep = declare_dependency(
link_with: evk_lib,
include_directories: evk_incdir,
dependencies: [
dependency('volk').partial_dependency(includes: true, compile_args: true),
dependency('vma').partial_dependency(includes: true),
dependency('evol-headers').partial_dependency(includes: true),
],
)
meson.override_dependency('evk', evk_dep)
if get_option('build_samples')
subdir('samples')
endif
-1
View File
@@ -1 +0,0 @@
option('build_samples', type: 'boolean', value: true, description: 'Build the evk samples')
-10
View File
@@ -1,10 +0,0 @@
executable(
'basic_triangle',
'basic_triangle.c',
dependencies: [
dependency('evk'),
dependency('glfw3'),
],
c_args: evk_c_args,
)
-1
View File
@@ -1 +0,0 @@
subdir('basic_triangle')
@@ -1,7 +1,7 @@
#version 450 #version 450
#pragma shader_stage(vertex) #pragma shader_stage(vertex)
in layout(location=0) vec2 position; // in layout(location=0) vec2 position;
layout(set=0, binding=0) uniform data { layout(set=0, binding=0) uniform data {
vec4 positions[3]; vec4 positions[3];
@@ -12,5 +12,4 @@ void main() {
// gl_Position = vec4(position, 0.0, 1.0); // gl_Position = vec4(position, 0.0, 1.0);
// gl_Position = vec4(inputData.positions[gl_VertexIndex], 0.0, 1.0); // gl_Position = vec4(inputData.positions[gl_VertexIndex], 0.0, 1.0);
gl_Position = vertexData.positions[gl_VertexIndex]; gl_Position = vertexData.positions[gl_VertexIndex];
// gl_Position = vec4(position, 0.0, 1.0); }
}
@@ -15,13 +15,3 @@ index d44f62a..16bad95 100644
add_subdirectory(${SHADERC_GLSLANG_DIR} glslang) add_subdirectory(${SHADERC_GLSLANG_DIR} glslang)
endif() endif()
if (NOT TARGET glslang) if (NOT TARGET glslang)
diff --git a/utils/git-sync-deps b/utils/git-sync-deps
index eecfbe9..73df6e5 100755
--- a/utils/git-sync-deps
+++ b/utils/git-sync-deps
@@ -279,4 +279,4 @@ def main(argv):
if __name__ == '__main__':
- exit(main(sys.argv[1:]))
+ sys.exit(main(sys.argv[1:]))
@@ -1,12 +1,10 @@
[wrap-git] [wrap-git]
directory = shaderc directory = shaderc
url = https://github.com/google/shaderc url = https://github.com/google/shaderc
revision = v2024.4 revision = v2024.4
depth=1 depth=1
patch_directory = shaderc
diff_files = shaderc/fixes.diff ; patch_directory = shaderc_cmake
;
[provide] ; [provide]
dependency_names = shaderc ; dependency_names = shaderc_cmake
+1 -1
View File
@@ -1,7 +1,7 @@
[wrap-git] [wrap-git]
directory = spvref directory = spvref
url = https://github.com/KhronosGroup/SPIRV-Reflect url = https://github.com/KhronosGroup/SPIRV-Reflect
revision = vulkan-sdk-1.4.309.0 revision = main
depth = 1 depth = 1
patch_directory = spvref patch_directory = spvref
+1 -4
View File
@@ -1,10 +1,7 @@
[wrap-git] [wrap-git]
directory = vma directory = vma
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
revision = v3.3.0 revision = master
depth = 1 depth = 1
patch_directory = vma patch_directory = vma
[provide]
dependency_names = vma
+1 -2
View File
@@ -1,8 +1,7 @@
[wrap-git] [wrap-git]
directory = volk directory = volk
url = https://github.com/zeux/volk url = https://github.com/zeux/volk
revision = vulkan-sdk-1.4.309.0 revision = master
depth = 1
patch_directory = volk patch_directory = volk