mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 09:51:41 +00:00
[vulkan] Fix a pile of data upload issues
Copying data from the wrong buffer was the cause of the corrupted brush model vertices, and then lots of little errors (mostly forgetting to multiply by bpp) for textures.
This commit is contained in:
parent
dc79a8a935
commit
2acdaa0252
5 changed files with 14 additions and 11 deletions
|
@ -114,7 +114,7 @@ transfer_mips (byte *dst, const void *_src, const texture_t *tx)
|
|||
offset = tx->offsets[i] - sizeof (texture_t);
|
||||
count = width * height;
|
||||
Vulkan_ExpandPalette (dst, src + offset, vid.palette, 1, count);
|
||||
dst += count;
|
||||
dst += count * 4;
|
||||
width >>= 1;
|
||||
height >>= 1;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ copy_mips (qfv_packet_t *packet, texture_t *tx, qfv_tex_t *tex,
|
|||
{
|
||||
// base copy
|
||||
VkBufferImageCopy copy = {
|
||||
tex->offset, tx->width, 0,
|
||||
tex->offset, tx->width, tx->height,
|
||||
{VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||
{0, 0, 0}, {tx->width, tx->height, 1},
|
||||
};
|
||||
|
@ -153,14 +153,16 @@ copy_mips (qfv_packet_t *packet, texture_t *tx, qfv_tex_t *tex,
|
|||
if (is_sky) {
|
||||
__auto_type c = &copies->a[copies->size++];
|
||||
*c = copy;
|
||||
c->bufferOffset += sky_offset * 4;
|
||||
c->bufferOffset += sky_offset;
|
||||
c->imageSubresource.baseArrayLayer = 1;
|
||||
}
|
||||
copy.bufferOffset += size;
|
||||
size >>= 2;
|
||||
copy.bufferRowLength >>= 1;
|
||||
copy.bufferImageHeight >>= 1;
|
||||
copy.imageExtent.width >>= 1;
|
||||
copy.imageExtent.height >>= 1;
|
||||
copy.imageSubresource.mipLevel++;
|
||||
sky_offset >>= 1;
|
||||
}
|
||||
dfunc->vkCmdCopyBufferToImage (packet->cmd, packet->stage->buffer,
|
||||
|
@ -322,7 +324,7 @@ Vulkan_Mod_ProcessTexture (texture_t *tx, vulkan_ctx_t *ctx)
|
|||
|
||||
vulktex_t *tex = tx->render;
|
||||
tex->texture = tx;
|
||||
tex->tex = (qfv_tex_t *) (tx + 1);
|
||||
tex->tex = (qfv_tex_t *) (tex + 1);
|
||||
VkExtent3D extent = { tx->width, tx->height, 1 };
|
||||
|
||||
int layers = 1;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
compareEnable = false;
|
||||
compareOp = always;
|
||||
minLod = 0;
|
||||
maxLod = 1;
|
||||
maxLod = 4;
|
||||
borderColor = float_transparent_black;
|
||||
unnormalizedCoordinates = false;
|
||||
};
|
||||
|
|
|
@ -552,7 +552,7 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
|
|||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, 0, 1, &wr_barrier, 0, 0);
|
||||
VkBufferCopy copy_region = { packet->offset, 0, vertex_buffer_size };
|
||||
dfunc->vkCmdCopyBuffer (packet->cmd, ctx->staging->buffer,
|
||||
dfunc->vkCmdCopyBuffer (packet->cmd, stage->buffer,
|
||||
bctx->vertex_buffer, 1, ©_region);
|
||||
VkBufferMemoryBarrier rd_barrier = {
|
||||
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, 0,
|
||||
|
|
|
@ -164,9 +164,10 @@ Vulkan_BuildLightMap (msurface_t *surf, vulkan_ctx_t *ctx)
|
|||
surf->cached_light[maps] = scale; // 8.8 fraction
|
||||
out = block;
|
||||
for (i = 0; i < smax * tmax; i++) {
|
||||
*out++ += *lightmap++ * scale / 256.0;
|
||||
*out++ += *lightmap++ * scale / 256.0;
|
||||
*out++ += *lightmap++ * scale / 256.0;
|
||||
*out++ += *lightmap++ * scale / 65536.0;
|
||||
*out++ += *lightmap++ * scale / 65536.0;
|
||||
*out++ += *lightmap++ * scale / 65536.0;
|
||||
*out++ = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ Vulkan_ExpandPalette (byte *dst, const byte *src, const byte *palette,
|
|||
if (alpha) {
|
||||
while (count-- > 0) {
|
||||
byte pix = *src++;
|
||||
const byte *col = palette + pix;
|
||||
const byte *col = palette + pix * 3;
|
||||
*dst++ = *col++;
|
||||
*dst++ = *col++;
|
||||
*dst++ = *col++;
|
||||
|
@ -101,7 +101,7 @@ Vulkan_ExpandPalette (byte *dst, const byte *src, const byte *palette,
|
|||
} else {
|
||||
while (count-- > 0) {
|
||||
byte pix = *src++;
|
||||
const byte *col = palette + pix;
|
||||
const byte *col = palette + pix * 3;
|
||||
*dst++ = *col++;
|
||||
*dst++ = *col++;
|
||||
*dst++ = *col++;
|
||||
|
|
Loading…
Reference in a new issue