mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[vulkan] Create some default textures
Black, white and magenta. This gets glow (full bright) maps working.
This commit is contained in:
parent
68b7341429
commit
93e9f89bd3
6 changed files with 56 additions and 18 deletions
|
@ -16,5 +16,7 @@ void Vulkan_ExpandPalette (byte *dst, const byte *src, const byte *palette,
|
|||
qfv_tex_t *Vulkan_LoadTex (struct vulkan_ctx_s *ctx, tex_t *tex, int mip);
|
||||
VkImageView Vulkan_TexImageView (qfv_tex_t *tex) __attribute__((pure));
|
||||
void Vulkan_UnloadTex (struct vulkan_ctx_s *ctx, qfv_tex_t *tex);
|
||||
void Vulkan_Texture_Init (struct vulkan_ctx_s *ctx);
|
||||
void Vulkan_Texture_Shutdown (struct vulkan_ctx_s *ctx);
|
||||
|
||||
#endif//__QF_Vulkan_qf_texture_h
|
||||
|
|
|
@ -75,6 +75,12 @@ typedef struct vulkan_ctx_s {
|
|||
size_t curFrame;
|
||||
vulkan_framebufferset_t framebuffers;
|
||||
|
||||
struct qfv_tex_s *default_black;
|
||||
struct qfv_tex_s *default_white;
|
||||
struct qfv_tex_s *default_magenta;
|
||||
struct qfv_tex_s *default_skysheet;
|
||||
struct qfv_tex_s *default_skybox;
|
||||
|
||||
// projection and view matrices (model is push constant)
|
||||
vulkan_matrices_t matrices;
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ vulkan_R_Init (void)
|
|||
// FIXME this should be staged so screen updates can begin while pipelines
|
||||
// are being built
|
||||
vulkan_ctx->pipeline = Vulkan_CreatePipeline (vulkan_ctx, "pipeline");
|
||||
Vulkan_Texture_Init (vulkan_ctx);
|
||||
Vulkan_Bsp_Init (vulkan_ctx);
|
||||
Vulkan_Draw_Init (vulkan_ctx);
|
||||
Vulkan_Particles_Init (vulkan_ctx);
|
||||
|
@ -607,6 +608,7 @@ vulkan_vid_render_shutdown (void)
|
|||
Vulkan_Draw_Shutdown (vulkan_ctx);
|
||||
Vulkan_Bsp_Shutdown (vulkan_ctx);
|
||||
Mod_ClearAll ();
|
||||
Vulkan_Texture_Shutdown (vulkan_ctx);
|
||||
Vulkan_Shutdown_Common (vulkan_ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -119,8 +119,6 @@ main (void)
|
|||
if (doLight) {
|
||||
c *= vec4 (texture (LightMap, l_st).xyz, 1);
|
||||
}
|
||||
//c += texture (GlowMap, t_st);
|
||||
//c = vec4(texture (LightMap, l_st).xyz, 1);
|
||||
//c = vec4(texture (Texture, t_st).xyz, 1);
|
||||
c += texture (GlowMap, t_st);
|
||||
frag_color = c;//fogBlend (c);
|
||||
}
|
||||
|
|
|
@ -788,12 +788,15 @@ draw_elechain (elechain_t *ec, VkPipelineLayout layout, qfv_devfuncs_t *dfunc,
|
|||
}
|
||||
|
||||
static VkImageView
|
||||
get_view (qfv_tex_t *tex, VkImageView default_view)
|
||||
get_view (qfv_tex_t *tex, qfv_tex_t *default_tex)
|
||||
{
|
||||
if (tex) {
|
||||
return tex->view;
|
||||
}
|
||||
return default_view;
|
||||
if (default_tex) {
|
||||
return default_tex->view;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -817,8 +820,10 @@ bsp_begin (vulkan_ctx_t *ctx)
|
|||
bframe->imageInfo[0].imageView = 0; // set by tex chain loop
|
||||
bframe->imageInfo[1].imageView = 0; // set by tex chain loop
|
||||
bframe->imageInfo[2].imageView = QFV_ScrapImageView (bctx->light_scrap);
|
||||
bframe->imageInfo[3].imageView = get_view (bctx->skysheet_tex, 0);
|
||||
bframe->imageInfo[4].imageView = get_view (bctx->skybox_tex, 0);
|
||||
bframe->imageInfo[3].imageView = get_view (bctx->skysheet_tex,
|
||||
ctx->default_skysheet);
|
||||
bframe->imageInfo[4].imageView = get_view (bctx->skybox_tex,
|
||||
ctx->default_skybox);
|
||||
|
||||
dfunc->vkResetCommandBuffer (cmd, 0);
|
||||
VkCommandBufferInheritanceInfo inherit = {
|
||||
|
@ -1108,22 +1113,17 @@ Vulkan_DrawWorld (vulkan_ctx_t *ctx)
|
|||
elechain_t *ec = 0;
|
||||
|
||||
tex = bctx->texture_chains.a[i];
|
||||
if (!tex->tex) {
|
||||
//FIXME bind to whit
|
||||
continue;
|
||||
}
|
||||
|
||||
build_tex_elechain (tex, bctx, bframe);
|
||||
|
||||
//XXX if (tex->elechain)
|
||||
//XXX qfeglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
|
||||
bframe->imageInfo[0].imageView = get_view (tex->tex, 0);
|
||||
bframe->imageInfo[1].imageView = get_view (tex->glow, 0);
|
||||
//XXX glow map
|
||||
bframe->imageInfo[0].imageView = get_view (tex->tex,
|
||||
ctx->default_white);
|
||||
bframe->imageInfo[1].imageView = get_view (tex->glow,
|
||||
ctx->default_black);
|
||||
dfunc->vkCmdPushDescriptorSetKHR (bframe->bsp_cmd,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
bctx->layout,
|
||||
0, 1, bframe->descriptors + 1);
|
||||
0, 2, bframe->descriptors + 1);
|
||||
|
||||
for (ec = tex->elechain; ec; ec = ec->next) {
|
||||
draw_elechain (ec, bctx->layout, dfunc, bframe->bsp_cmd);
|
||||
|
|
|
@ -170,6 +170,10 @@ Vulkan_LoadTex (vulkan_ctx_t *ctx, tex_t *tex, int mip)
|
|||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||
0, 0);
|
||||
QFV_BindImageMemory (device, qtex->image, qtex->memory, 0);
|
||||
qtex->view = QFV_CreateImageView (device, qtex->image,
|
||||
VK_IMAGE_VIEW_TYPE_2D,
|
||||
VK_FORMAT_R8G8B8A8_UNORM,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
|
||||
size_t bytes = bpp * tex->width * tex->height;
|
||||
qfv_packet_t *packet = QFV_PacketAcquire (ctx->staging);
|
||||
|
@ -241,8 +245,14 @@ Vulkan_LoadTex (vulkan_ctx_t *ctx, tex_t *tex, int mip)
|
|||
blit.dstOffsets[1].y = (blit.dstOffsets[1].y + 1) >> 1;
|
||||
barrier.subresourceRange.baseMipLevel++;
|
||||
}
|
||||
stages = imageLayoutTransitionStages[qfv_LT_TransferDst_to_ShaderReadOnly];
|
||||
barrier=imageLayoutTransitionBarriers[qfv_LT_TransferDst_to_ShaderReadOnly];
|
||||
barrier.image = qtex->image;
|
||||
dfunc->vkCmdPipelineBarrier (packet->cmd, stages.src, stages.dst,
|
||||
0, 0, 0, 0, 0,
|
||||
1, &barrier);
|
||||
QFV_PacketSubmit (packet);
|
||||
return 0;
|
||||
return qtex;
|
||||
}
|
||||
|
||||
VkImageView
|
||||
|
@ -262,3 +272,23 @@ Vulkan_UnloadTex (vulkan_ctx_t *ctx, qfv_tex_t *tex)
|
|||
dfunc->vkFreeMemory (device->dev, tex->memory, 0);
|
||||
free (tex);
|
||||
}
|
||||
|
||||
static tex_t default_black_tex = {1, 1, tex_rgba, 1, 0, {0, 0, 0, 0 }};
|
||||
static tex_t default_white_tex = {1, 1, tex_rgba, 1, 0, {255, 255, 255, 255 }};
|
||||
static tex_t default_magenta_tex = {1, 1, tex_rgba, 1, 0, {255, 0, 255, 255 }};
|
||||
|
||||
void
|
||||
Vulkan_Texture_Init (vulkan_ctx_t *ctx)
|
||||
{
|
||||
ctx->default_black = Vulkan_LoadTex (ctx, &default_black_tex, 1);
|
||||
ctx->default_white = Vulkan_LoadTex (ctx, &default_white_tex, 1);
|
||||
ctx->default_magenta = Vulkan_LoadTex (ctx, &default_magenta_tex, 1);
|
||||
}
|
||||
|
||||
void
|
||||
Vulkan_Texture_Shutdown (vulkan_ctx_t *ctx)
|
||||
{
|
||||
Vulkan_UnloadTex (ctx, ctx->default_black);
|
||||
Vulkan_UnloadTex (ctx, ctx->default_white);
|
||||
Vulkan_UnloadTex (ctx, ctx->default_magenta);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue