summaryrefslogtreecommitdiff
path: root/video.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'video.cpp')
-rw-r--r--video.cpp88
1 files changed, 83 insertions, 5 deletions
diff --git a/video.cpp b/video.cpp
index 165dd9b..f95fcaa 100644
--- a/video.cpp
+++ b/video.cpp
@@ -602,6 +602,7 @@ struct Texture_Vk : public Texture, public Late_Terminated {
Resource_State state;
void destroy(Device_Vk*) override;
+ void set_name(Device_Vk* dev, const char* name);
};
struct Buffer_Vk : public Buffer, public Late_Terminated {
@@ -612,6 +613,7 @@ struct Buffer_Vk : public Buffer, public Late_Terminated {
void init(Device_Vk* dev, int flags, VkDeviceSize size);
void destroy(Device_Vk* dev) override;
+ void set_name(Device_Vk* dev, const char* name);
static VkBufferUsageFlags get_usage(int flags) {
VkBufferUsageFlags r = 0;
@@ -816,6 +818,7 @@ struct Sampler_Vk : public Late_Terminated {
void init(Device_Vk* dev, const Sampler_State& s);
void destroy(Device_Vk* dev) override;
+ void set_name(Device_Vk* dev, const char* name);
static VkFilter get_filter(Filter_Mode mode);
static VkSamplerMipmapMode get_mipmap_mode(Filter_Mode mode);
@@ -899,7 +902,12 @@ struct Hash_Function<Sampler_Id> {
struct Shader_Loader : public Asset_Loader {
Device_Vk* dev;
void init(Device_Vk* d);
- Asset* load(Arena* a, Arena* s, Pack_File* f) override;
+ Asset* load(
+ Arena* a,
+ Arena* s,
+ const char* filename,
+ Pack_File* f
+ ) override;
void unload(Asset* a) override;
};
@@ -907,7 +915,12 @@ struct Texture_Loader : public Asset_Loader {
Device_Vk* dev;
static size_t calc_size(Texture_Format fmt, int w, int h);
void init(Device_Vk* d);
- Asset* load(Arena* a, Arena* s, Pack_File* f) override;
+ Asset* load(
+ Arena* a,
+ Arena* s,
+ const char* filename,
+ Pack_File* f
+ ) override;
void unload(Asset* a) override;
Buffer_Id upload(void* buf, size_t size);
@@ -1390,6 +1403,7 @@ void Device_Vk::create_depth(int w, int h) {
if (depth)
destroy_texture(depth);
depth = create_texture(
+ "default depth",
texture_format_d24s8,
Texture_Flags::sampleable | Texture_Flags::depth_stencil_target,
w,
@@ -3230,11 +3244,30 @@ void Buffer_Vk::destroy(Device_Vk* dev) {
dev->buffers.remove(id);
}
-Buffer_Id Device::create_buffer(size_t size, int flags) {
+void Buffer_Vk::set_name(Device_Vk* dev, const char* name) {
+#ifdef DEBUG
+ VkDebugUtilsObjectNameInfoEXT i{};
+ i.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
+ i.pObjectName = name;
+ i.objectType = VK_OBJECT_TYPE_BUFFER;
+ i.objectHandle = (uint64_t)buf;
+ vkSetDebugUtilsObjectNameEXT(dev->dev, &i);
+#else
+ (void)dev;
+ (void)name;
+#endif
+}
+
+Buffer_Id Device::create_buffer(
+ const char* name,
+ size_t size,
+ int flags
+) {
Device_Vk* dev = (Device_Vk*)this;
Buffer_Id id = dev->alloc_buffer();
Buffer_Vk& buf = *(Buffer_Vk*)&get_buffer(id);
buf.init(dev, flags, (VkDeviceSize)size);
+ buf.set_name(dev, name);
return id;
}
@@ -3275,6 +3308,7 @@ Buffer& Device::get_buffer(Buffer_Id id) {
}
Texture_Id Device::create_texture(
+ const char* name,
Texture_Format fmt,
int flags,
int w,
@@ -3344,9 +3378,26 @@ Texture_Id Device::create_texture(
ctx.transition(id, Resource_State::shader_read);
dev->submit(ctx);
}
+ tex.set_name(dev, name);
return id;
}
+void Texture_Vk::set_name(Device_Vk* dev, const char* name) {
+#ifdef DEBUG
+ VkDebugUtilsObjectNameInfoEXT i{};
+ i.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
+ i.pObjectName = name;
+ i.objectType = VK_OBJECT_TYPE_IMAGE;
+ i.objectHandle = (uint64_t)image;
+ vkSetDebugUtilsObjectNameEXT(dev->dev, &i);
+ i.objectType = VK_OBJECT_TYPE_IMAGE_VIEW;
+ i.objectHandle = (uint64_t)view;
+ vkSetDebugUtilsObjectNameEXT(dev->dev, &i);
+#else
+ (void)dev;
+ (void)name;
+#endif
+}
Shader& Device::get_shader(Shader_Id id) {
Device_Vk* dev = (Device_Vk*)this;
@@ -3355,11 +3406,15 @@ Shader& Device::get_shader(Shader_Id id) {
return dev->shaders[id];
}
-Sampler_Id Device::create_sampler(const Sampler_State& state) {
+Sampler_Id Device::create_sampler(
+ const char* name,
+ const Sampler_State& state
+) {
Device_Vk* dev = (Device_Vk*)this;
Sampler_Id id = dev->alloc_sampler();
Sampler_Vk& s = dev->samplers[id];
s.init(dev, state);
+ s.set_name(dev, name);
return id;
}
@@ -3382,12 +3437,14 @@ void Shader_Loader::init(Device_Vk* d) {
Asset* Shader_Loader::load(
Arena* a,
Arena* s,
+ const char* filename,
Pack_File* f
) {
Shader_Vk* shader;
Shader_Id id;
(void)s;
(void)a;
+ (void)filename;
id = dev->alloc_shader();
shader = (Shader_Vk*)&dev->get_shader(id);
if (!shader->init(dev, f)) {
@@ -3523,6 +3580,7 @@ size_t Texture_Loader::calc_size(
Buffer_Id Texture_Loader::upload(void* buf, size_t size) {
void* mem;
Buffer_Id id = dev->create_buffer(
+ "texture stage",
size,
Buffer_Flags::copy_src |
Buffer_Flags::cpu_readwrite
@@ -3533,7 +3591,12 @@ Buffer_Id Texture_Loader::upload(void* buf, size_t size) {
return id;
}
-Asset* Texture_Loader::load(Arena* a, Arena* s, Pack_File* f) {
+Asset* Texture_Loader::load(
+ Arena* a,
+ Arena* s,
+ const char* filename,
+ Pack_File* f
+) {
char magic[4];
void* data;
int w, h;
@@ -3550,6 +3613,7 @@ Asset* Texture_Loader::load(Arena* a, Arena* s, Pack_File* f) {
{
Buffer_Id buf = upload(data, size);
Texture_Id tex = dev->create_texture(
+ filename,
fmt,
Texture_Flags::sampleable | Texture_Flags::copy_dst,
w,
@@ -3647,6 +3711,20 @@ void Sampler_Vk::destroy(Device_Vk* dev) {
dev->samplers.remove(id);
}
+void Sampler_Vk::set_name(Device_Vk* dev, const char* name) {
+#ifdef DEBUG
+ VkDebugUtilsObjectNameInfoEXT i{};
+ i.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
+ i.pObjectName = name;
+ i.objectType = VK_OBJECT_TYPE_SAMPLER;
+ i.objectHandle = (uint64_t)sampler;
+ vkSetDebugUtilsObjectNameEXT(dev->dev, &i);
+#else
+ (void)dev;
+ (void)name;
+#endif
+}
+
void Vram_Allocator::Page::init(
Device_Vk* dev,
VkDeviceSize s,