vk: fixup blue noise 3d texture refactoring

Fixed a bunch of validation and shader errors
This commit is contained in:
Ivan 'provod' Avdeev 2023-10-30 13:51:23 -04:00
parent df3c0e30ba
commit 23341c144c
5 changed files with 10 additions and 6 deletions

View File

@ -2,11 +2,12 @@
- [x] missing skybox
- [x] explicitly free default textures; and complain about any leftovers
- [x] use the new hash table in materials too, remove dummy textures
- [x] why are there references to \*unused
- [ ] restore blue noise
- [x] vk_texture_t blue_noise; 3d texture
- [x] separate binding similar to skybox in vk_rtx.c and shaders
- [x] patch shader function
- [x] why are there references to \*unused
- [ ] load 64xpngs into a single big pic
- [ ] massage texture code
- [ ] single return/goto cleanup
- [ ] pass args via structs?

View File

@ -8,8 +8,7 @@
vec4 blueNoise(ivec3 v) {
ivec3 size = textureSize(blue_noise_texture, 0);
v %= size.z;
return texelFetch(blue_noise_texture, v.xy % size.xy, 0);
return texelFetch(blue_noise_texture, v % size, 0);
}
#endif // ifndef BLUENOISE_H_INCLUDED

View File

@ -36,9 +36,10 @@ layout(set = 0, binding = 15, rgba16f) uniform image2D prev_temporal_diffuse;
layout(set = 0, binding = 16, rgba16f) uniform image2D out_temporal_specular;
layout(set = 0, binding = 17, rgba16f) uniform image2D prev_temporal_specular;
//#define DEBUG_NOISE
#ifdef DEBUG_NOISE
layout(set = 0, binding = 18) uniform sampler3D blue_noise_texture;
include "bluenoise.glsl"
#include "bluenoise.glsl"
#endif
//layout(set = 0, binding = 19) uniform sampler2D textures[MAX_TEXTURES];

View File

@ -32,6 +32,8 @@ r_vk_image_t R_VkImageCreate(const r_vk_image_create_t *create) {
const qboolean is_cubemap = !!(create->flags & kVkImageFlagIsCubemap);
const qboolean is_3d = create->depth > 1;
ASSERT(create->depth > 0);
ASSERT(is_cubemap + is_3d != 2);
const VkFormat unorm_format = unormFormatFor(create->format);

View File

@ -171,6 +171,7 @@ static void textureDestroy( unsigned int index );
void R_VkTexturesShutdown( void ) {
unloadSkybox();
R_VkTextureDestroy(-1, &g_vktextures.cubemap_placeholder);
R_VkTextureDestroy(-1, &g_vktextures.blue_noise);
for (int i = 0; i < COUNTOF(g_vktextures.samplers); ++i) {
if (g_vktextures.samplers[i].sampler != VK_NULL_HANDLE)
@ -377,7 +378,7 @@ static qboolean uploadRawKtx2( int tex_index, vk_texture_t *tex, const rgbdata_t
.debug_name = TEX_NAME(tex),
.width = header->pixelWidth,
.height = header->pixelHeight,
.depth = header->pixelDepth,
.depth = Q_max(1, header->pixelDepth),
.mips = header->levelCount,
.layers = 1, // TODO or 6 for cubemap; header->faceCount
.format = header->vkFormat,
@ -454,7 +455,7 @@ static qboolean uploadTexture(int index, vk_texture_t *tex, rgbdata_t *const *co
} else {
const int width = layers[0]->width;
const int height = layers[0]->height;
const int depth = layers[0]->depth;
const int depth = Q_max(1, layers[0]->depth);
const qboolean compute_mips = layers[0]->type == PF_RGBA_32 && layers[0]->numMips < 2;
const VkFormat format = VK_GetFormat(layers[0]->type, colorspace_hint);
const int mipCount = compute_mips ? CalcMipmapCount( width, height, depth, tex->flags, true ) : layers[0]->numMips;