Made navmesh compile on Windows

Small updates to remove warnings
Testing nonuniform descriptor access in shader
This commit is contained in:
2025-10-05 01:31:39 +01:00
parent 175f4da59b
commit 2c67896cf2
9 changed files with 22533 additions and 22521 deletions

View File

@@ -65,13 +65,13 @@ int main(int argc, char **argv) {
G_Vertex *vertices = cast(G_Vertex *) vbo->data;
vertices[0] = (G_Vertex) { -0.25f, -0.25f, 1.0f, 1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 0};
vertices[1] = (G_Vertex) { 0.25f, -0.25f, 1.0f, 1.0f, 1.0f, 0.0f, 0xFFFFFFFF, 0};
vertices[2] = (G_Vertex) { -0.25f, 0.25f, 1.0f, 1.0f, 0.0f, 1.0f, 0xFFFFFFFF, 0};
vertices[0] = (G_Vertex) { -0.25f, -0.25f, 1.0f, 1.0f, 0.0f, 0.0f, 0xFFFFFFFF, 1};
vertices[1] = (G_Vertex) { 0.25f, -0.25f, 1.0f, 1.0f, 1.0f, 0.0f, 0xFFFFFFFF, 1};
vertices[2] = (G_Vertex) { -0.25f, 0.25f, 1.0f, 1.0f, 0.0f, 1.0f, 0xFFFFFFFF, 1};
vertices[3] = (G_Vertex) { 0.25f, -0.25f, 1.0f, 1.0f, 1.0f, 0.0f, 0xFFFFFFFF, 0};
vertices[4] = (G_Vertex) { 0.25f, 0.25f, 1.0f, 1.0f, 1.0f, 1.0f, 0xFFFFFFFF, 0};
vertices[5] = (G_Vertex) { -0.25f, 0.25f, 1.0f, 1.0f, 0.0f, 1.0f, 0xFFFFFFFF, 0};
vertices[3] = (G_Vertex) { 0.25f, -0.25f, 1.0f, 1.0f, 1.0f, 0.0f, 0xFFFFFFFF, 1};
vertices[4] = (G_Vertex) { 0.25f, 0.25f, 1.0f, 1.0f, 1.0f, 1.0f, 0xFFFFFFFF, 1};
vertices[5] = (G_Vertex) { -0.25f, 0.25f, 1.0f, 1.0f, 0.0f, 1.0f, 0xFFFFFFFF, 1};
}
bool running = true;
@@ -100,6 +100,7 @@ int main(int argc, char **argv) {
.navMesh = TestNavMesh,
.npcPOI = {100}
};
while (running)
{
SDL_Event e;
@@ -111,7 +112,8 @@ int main(int argc, char **argv) {
running = false;
}
}
UpdateNPCs(1.0/60.0, &world);
UpdateNPCs(1.0f / 60.0f, &world);
int w, h;
SDL_GetWindowSizeInPixels(window, &w, &h);
@@ -154,7 +156,7 @@ int main(int argc, char **argv) {
vk.AllocateDescriptorSets(vk.device, &alloc_info, &set);
// 'update' the descriptor sets for binding
{
M_TempScope(0, 0) {
VkWriteDescriptorSet writes[2] = { 0 };
VkDescriptorBufferInfo vbo_info = { 0 };
@@ -162,10 +164,13 @@ int main(int argc, char **argv) {
vbo_info.offset = 0;
vbo_info.range = 256;
VkDescriptorImageInfo image_info = { 0 };
image_info.imageView = img->image.view;
image_info.sampler = vk.sampler;
image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
VkDescriptorImageInfo *image_info = M_ArenaPush(temp.arena, VkDescriptorImageInfo, .count = game->n_images);
for (U32 it = 0; it < game->n_images; ++it) {
image_info[it].imageView = game->images[it].image.view;
image_info[it].sampler = vk.sampler;
image_info[it].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}
writes[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writes[0].dstSet = set;
@@ -177,9 +182,9 @@ int main(int argc, char **argv) {
writes[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writes[1].dstSet = set;
writes[1].dstBinding = 1;
writes[1].descriptorCount = 1;
writes[1].descriptorCount = game->n_images;
writes[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
writes[1].pImageInfo = &image_info;
writes[1].pImageInfo = image_info;
vk.UpdateDescriptorSets(vk.device, ArraySize(writes), writes, 0, 0);
}

View File

@@ -161,7 +161,7 @@ void G_PipelinesLoad(G_State *game) {
bindings[1].binding = 1;
bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
bindings[1].descriptorCount = 1;
bindings[1].descriptorCount = game->n_images;
bindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
VkDescriptorSetLayoutCreateInfo set_info = { 0 };

View File

@@ -42,8 +42,8 @@ void updateNPC(F32 delta, NPC *npc, World *world) {
}
void UpdateNPCs(F32 delta, World *world) {
for(int i = 0; i < world->npcCount; i++) {
for(U32 i = 0; i < world->npcCount; i++) {
updateNPC(delta, &world->npcs[i], world);
}
}
}

View File

@@ -4,7 +4,7 @@
#include "nav.h"
#include "../core/types.h"
#define NPC_SPEED 0.2
#define NPC_SPEED 0.2f
typedef enum NPC_ACTION NPC_ACTION;
enum NPC_ACTION {

File diff suppressed because it is too large Load Diff

View File

@@ -180,6 +180,7 @@ bool Vk_Setup(SDL_Window *window) {
features12.storageBuffer8BitAccess = VK_TRUE;
features12.uniformAndStorageBuffer8BitAccess = VK_TRUE;
features12.descriptorIndexing = VK_TRUE;
features12.runtimeDescriptorArray = VK_TRUE;
// @Todo: we will probably need to enable some of the 'nonuniform' indexing features

View File

@@ -1,12 +1,15 @@
#version 460 core
#extension GL_EXT_nonuniform_qualifier : enable
layout(location = 0) in vec2 frag_uv;
layout(location = 1) in vec4 frag_c;
layout(location = 2) in flat uint idx;
layout(location = 0) out vec4 framebuffer;
layout(binding = 1) uniform sampler2D u_image;
layout(binding = 1) uniform sampler2D u_image[];
void main() {
framebuffer = frag_c * texture(u_image, frag_uv);
framebuffer = frag_c * texture(u_image[idx], frag_uv);
}

View File

@@ -16,6 +16,7 @@ readonly buffer Vertices {
layout(location = 0) out vec2 frag_uv;
layout(location = 1) out vec4 frag_c;
layout(location = 2) out flat uint idx;
void main() {
Vertex v = vtx[gl_VertexIndex];
@@ -25,4 +26,6 @@ void main() {
frag_uv = v.uv;
frag_c = vec4((v.c >> 24) & 0xFF, (v.c >> 16) & 0xFF, (v.c >> 8) & 0xFF, (v.c >> 0) & 0xFF) / 255.0f;
frag_c = frag_c.abgr;
idx = v.pad;
}

View File

@@ -67,7 +67,7 @@ glslangValidator -o "assets\shaders\basic.frag.spv" --target-env vulkan1.3 "..\c
ECHO [Building source]
SET COMPILER_OPTS=-nologo -W4 -I"deps\SDL3\include" -I"deps\stb" -I"%VULKAN_SDK%\Include" -I"..\code"
SET COMPILER_OPTS=-nologo /F8388608 -W4 -I"deps\SDL3\include" -I"deps\stb" -I"%VULKAN_SDK%\Include" -I"..\code"
SET LINKER_OPTS=-LIBPATH:"deps\SDL3\lib" SDL3.lib Ole32.lib Shell32.lib
IF %release% equ 1 (