Skip to content

Commit

Permalink
Blue noise dithering for 8 bit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Novum committed Jul 8, 2022
1 parent 6a8a467 commit ce065d8
Show file tree
Hide file tree
Showing 23 changed files with 23,139 additions and 16,446 deletions.
17 changes: 11 additions & 6 deletions Quake/gl_rmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,30 +1254,35 @@ void R_CreateDescriptorSetLayouts ()
}

{
VkDescriptorSetLayoutBinding screen_effects_layout_bindings[4];
VkDescriptorSetLayoutBinding screen_effects_layout_bindings[5];
memset (&screen_effects_layout_bindings, 0, sizeof (screen_effects_layout_bindings));
screen_effects_layout_bindings[0].binding = 0;
screen_effects_layout_bindings[0].descriptorCount = 1;
screen_effects_layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
screen_effects_layout_bindings[0].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
screen_effects_layout_bindings[1].binding = 1;
screen_effects_layout_bindings[1].descriptorCount = 1;
screen_effects_layout_bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
screen_effects_layout_bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
screen_effects_layout_bindings[1].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
screen_effects_layout_bindings[2].binding = 2;
screen_effects_layout_bindings[2].descriptorCount = 1;
screen_effects_layout_bindings[2].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
screen_effects_layout_bindings[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
screen_effects_layout_bindings[2].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
screen_effects_layout_bindings[3].binding = 3;
screen_effects_layout_bindings[3].descriptorCount = 1;
screen_effects_layout_bindings[3].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
screen_effects_layout_bindings[3].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
screen_effects_layout_bindings[3].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
screen_effects_layout_bindings[4].binding = 4;
screen_effects_layout_bindings[4].descriptorCount = 1;
screen_effects_layout_bindings[4].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
screen_effects_layout_bindings[4].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;

descriptor_set_layout_create_info.bindingCount = 4;

descriptor_set_layout_create_info.bindingCount = 5;
descriptor_set_layout_create_info.pBindings = screen_effects_layout_bindings;

memset (&vulkan_globals.screen_effects_set_layout, 0, sizeof (vulkan_globals.screen_effects_set_layout));
vulkan_globals.screen_effects_set_layout.num_combined_image_samplers = 1;
vulkan_globals.screen_effects_set_layout.num_combined_image_samplers = 2;
vulkan_globals.screen_effects_set_layout.num_storage_images = 1;

err = vkCreateDescriptorSetLayout (vulkan_globals.device, &descriptor_set_layout_create_info, NULL, &vulkan_globals.screen_effects_set_layout.handle);
Expand Down
173 changes: 172 additions & 1 deletion Quake/gl_texmgr.c

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Quake/gl_texmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ extern gltexture_t *notexture;
extern gltexture_t *nulltexture;
extern gltexture_t *whitetexture;
extern gltexture_t *greytexture;
extern gltexture_t *bluenoisetexture;

extern unsigned int d_8to24table[256];
extern unsigned int d_8to24table_fbright[256];
Expand Down
35 changes: 26 additions & 9 deletions Quake/gl_vidsdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,13 @@ static void GL_UpdateDescriptorSets (void)
palette_octree_info.offset = 0;
palette_octree_info.range = VK_WHOLE_SIZE;

VkWriteDescriptorSet screen_effects_writes[4];
VkDescriptorImageInfo blue_noise_image_info;
memset (&blue_noise_image_info, 0, sizeof (blue_noise_image_info));
blue_noise_image_info.imageView = bluenoisetexture->image_view;
blue_noise_image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
blue_noise_image_info.sampler = vulkan_globals.linear_sampler;

VkWriteDescriptorSet screen_effects_writes[5];
memset (screen_effects_writes, 0, sizeof (screen_effects_writes));
screen_effects_writes[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
screen_effects_writes[0].dstBinding = 0;
Expand All @@ -1772,29 +1778,40 @@ static void GL_UpdateDescriptorSets (void)
screen_effects_writes[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
screen_effects_writes[0].dstSet = vulkan_globals.screen_effects_desc_set;
screen_effects_writes[0].pImageInfo = &input_image_info;

screen_effects_writes[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
screen_effects_writes[1].dstBinding = 1;
screen_effects_writes[1].dstArrayElement = 0;
screen_effects_writes[1].descriptorCount = 1;
screen_effects_writes[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
screen_effects_writes[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
screen_effects_writes[1].dstSet = vulkan_globals.screen_effects_desc_set;
screen_effects_writes[1].pImageInfo = &output_image_info;
screen_effects_writes[1].pImageInfo = &blue_noise_image_info;

screen_effects_writes[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
screen_effects_writes[2].dstBinding = 2;
screen_effects_writes[2].dstArrayElement = 0;
screen_effects_writes[2].descriptorCount = 1;
screen_effects_writes[2].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
screen_effects_writes[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
screen_effects_writes[2].dstSet = vulkan_globals.screen_effects_desc_set;
screen_effects_writes[2].pTexelBufferView = &palette_buffer_view;
screen_effects_writes[2].pImageInfo = &output_image_info;

screen_effects_writes[3].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
screen_effects_writes[3].dstBinding = 3;
screen_effects_writes[3].dstArrayElement = 0;
screen_effects_writes[3].descriptorCount = 1;
screen_effects_writes[3].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
screen_effects_writes[3].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
screen_effects_writes[3].dstSet = vulkan_globals.screen_effects_desc_set;
screen_effects_writes[3].pBufferInfo = &palette_octree_info;
screen_effects_writes[3].pTexelBufferView = &palette_buffer_view;

screen_effects_writes[4].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
screen_effects_writes[4].dstBinding = 4;
screen_effects_writes[4].dstArrayElement = 0;
screen_effects_writes[4].descriptorCount = 1;
screen_effects_writes[4].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
screen_effects_writes[4].dstSet = vulkan_globals.screen_effects_desc_set;
screen_effects_writes[4].pBufferInfo = &palette_octree_info;

vkUpdateDescriptorSets (vulkan_globals.device, 4, screen_effects_writes, 0, NULL);
vkUpdateDescriptorSets (vulkan_globals.device, 5, screen_effects_writes, 0, NULL);
}

/*
Expand Down Expand Up @@ -3150,7 +3167,7 @@ void VID_Init (void)
R_InitSamplers ();
R_CreatePipelineLayouts ();
R_CreatePaletteOctreeBuffers (palette_octree_colors, NUM_PALETTE_OCTREE_COLORS, palette_octree_nodes, NUM_PALETTE_OCTREE_NODES);
GL_CreateRenderResources ();
//GL_CreateRenderResources ();

// johnfitz -- removed code creating "glquake" subdirectory

Expand Down
Loading

0 comments on commit ce065d8

Please sign in to comment.