First reconstruction prototype (rgb444, ugly!)
This commit is contained in:
parent
a1bca32cd8
commit
ff64abd209
5 changed files with 84 additions and 40 deletions
|
@ -10,9 +10,9 @@ layout (constant_id = 1) const float height = 1080;
|
|||
const vec2 in_res = vec2(width,height);
|
||||
|
||||
|
||||
layout (binding = 0, r8) uniform image2D resultImage;
|
||||
layout (binding = 1, rg8) uniform image2D resultImage2;
|
||||
layout (binding = 2, rgba8) uniform image2D reconstructionImage;
|
||||
layout (binding = 0, r16) writeonly uniform image2D resultImage;
|
||||
layout (binding = 1, rg16) writeonly uniform image2D resultImage2;
|
||||
layout (binding = 2, rgba8) writeonly uniform image2D reconstructionImage;
|
||||
layout (binding = 3) uniform UBO
|
||||
{
|
||||
float frameNum;
|
||||
|
@ -45,6 +45,7 @@ vec4 samplef(float x0, float y0)
|
|||
vec3 e = vec3(-0.2, -0.3 ,-0.5);
|
||||
vec3 f = vec3(2.1, 2.0, 3.0);
|
||||
vec3 g = vec3(0.0, 0.1, 0.0);
|
||||
t = sqrt(t);
|
||||
return vec4( d + e*cos( 6.28318*(f*t+g) ) ,1.0);
|
||||
}
|
||||
|
||||
|
@ -81,7 +82,7 @@ void main() {
|
|||
float cd1 = cb - cd;
|
||||
|
||||
imageStore(resultImage, ivec2(gl_GlobalInvocationID.x * 2 + i, gl_GlobalInvocationID.y * 2 + j), vec4(ca1/4,0,0,0));
|
||||
imageStore(reconstructionImage, ivec2(gl_GlobalInvocationID.x * 2 + i, gl_GlobalInvocationID.y * 2 + j), vec4(cb1/ 4 + 0.5,cc1/4 + 0.5,cd1/4 + 0.5,1));
|
||||
imageStore(reconstructionImage, ivec2(gl_GlobalInvocationID.x * 2 + i, gl_GlobalInvocationID.y * 2 + j), vec4(cb1/2 + 0.533333,cc1/2 + 0.533333,cd1 + 0.533333,cd1 + 0.5333));
|
||||
// if(i == 0 && j == 0)
|
||||
// cl = r;
|
||||
cl += r1 + r2 + r3 + r4;
|
||||
|
|
|
@ -7,7 +7,7 @@ layout (local_size_x = WORKGROUP_SIZE, local_size_y = WORKGROUP_SIZE, local_size
|
|||
layout (binding = 0) uniform sampler2D ycbcrSampler;
|
||||
// todo: should it be sampler?
|
||||
layout (binding = 1, rgba8) uniform image2D inputImage;
|
||||
layout (binding = 2, rgba8) uniform image2D resultImage;
|
||||
layout (binding = 2, rgba8) writeonly uniform image2D resultImage;
|
||||
layout (constant_id = 0) const float width = 1920;
|
||||
layout (constant_id = 1) const float height = 1080;
|
||||
const vec2 in_res = vec2(width,height);
|
||||
|
@ -18,13 +18,13 @@ vec4 convertYuv(float y, float u, float v)
|
|||
|
||||
void main()
|
||||
{
|
||||
vec2 uv = vec2(gl_GlobalInvocationID.xy)/in_res;
|
||||
vec2 uv =(vec2(gl_GlobalInvocationID.xy) + vec2(0.5,0.5))/in_res;
|
||||
vec3 yuv = texture(ycbcrSampler,uv).xyz;
|
||||
vec3 rec = vec3(imageLoad(inputImage, ivec2(gl_GlobalInvocationID.xy)).xyz);
|
||||
float ca1 = yuv.y;
|
||||
float cb1 = rec.x - 0.5;
|
||||
float cc1 = rec.y - 0.5;
|
||||
float cd1 = rec.z - 0.5;
|
||||
float cb1 = (rec.x - 0.533333)/2;
|
||||
float cc1 = (rec.y - 0.533333)/2;
|
||||
float cd1 = (rec.z - 0.533333)/4;
|
||||
float ca = ca1 + cb1;
|
||||
float cb = cc1 + cd1;
|
||||
float cc = ca1 - cb1;
|
||||
|
|
|
@ -695,7 +695,7 @@ struct VaapiEncoderHEVC: VaapiEncoder
|
|||
pic.pic_fields.bits.transform_skip_enabled_flag = 1;
|
||||
// pic
|
||||
pic.collocated_ref_pic_index = 0;//255;
|
||||
pic.pic_init_qp = 26;
|
||||
pic.pic_init_qp = 5;
|
||||
pic.nal_unit_type = NALU_IDR_W_DLP;
|
||||
pic.pic_fields.bits.idr_pic_flag = 1;
|
||||
pic.pic_fields.bits.coding_type = 1;
|
||||
|
@ -787,7 +787,8 @@ struct VaapiEncoderHEVC: VaapiEncoder
|
|||
.bits_per_second = 150*1024*1024,
|
||||
.target_percentage = 66,
|
||||
.window_size = 1000,
|
||||
.initial_qp = 25
|
||||
.initial_qp = 1,
|
||||
.max_qp = 1
|
||||
});
|
||||
VABufferID ppps[2];
|
||||
VABufferID pvps[2];
|
||||
|
|
|
@ -42,29 +42,34 @@
|
|||
struct ComputeApplicationPipeline: BaseVulkanPipeline
|
||||
{
|
||||
|
||||
void Init(VkDevice dev)
|
||||
void Init(VkDevice dev, uint32_t width, uint32_t height)
|
||||
{
|
||||
|
||||
device = dev;
|
||||
CreateDescriptorSetLayout(
|
||||
BasicBinding(0, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,1,VK_SHADER_STAGE_COMPUTE_BIT),
|
||||
BasicBinding(1, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,1,VK_SHADER_STAGE_COMPUTE_BIT),
|
||||
BasicBinding(2, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,1,VK_SHADER_STAGE_COMPUTE_BIT)
|
||||
BasicBinding(2, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,1,VK_SHADER_STAGE_COMPUTE_BIT),
|
||||
BasicBinding(3, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,1,VK_SHADER_STAGE_COMPUTE_BIT)
|
||||
);
|
||||
CreatePool(CHAIN_SIZE,
|
||||
BasicPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,CHAIN_SIZE*2),
|
||||
BasicPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,CHAIN_SIZE*3),
|
||||
BasicPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, CHAIN_SIZE*1));
|
||||
float specData[2] = {(float)width,(float)height};
|
||||
VkSpecializationMapEntry specs[2] = {{0, 0, sizeof(float)},1,sizeof(float),sizeof(float)};
|
||||
VkSpecializationInfo sinfo = {2, specs, sizeof(specData), specData };
|
||||
VkShaderModule shader;
|
||||
CreateComputePipeline(ShaderFromFile(shader, "image.spv", VK_SHADER_STAGE_COMPUTE_BIT));
|
||||
CreateComputePipeline(ShaderFromFile(shader, "image-decomposite.comp.spv", VK_SHADER_STAGE_COMPUTE_BIT, &sinfo));
|
||||
// todo: should not we destroy shader internally?
|
||||
vkDestroyShaderModule(device, shader, NULL);
|
||||
}
|
||||
void UpdateDescriptors(VkDescriptorSet dstSet, VkImageView imageView0, VkImageView imageView1, const VkDescriptorBufferInfo &buffer)
|
||||
void UpdateDescriptors(VkDescriptorSet dstSet, VkImageView imageView0, VkImageView imageView1, VkImageView imageView2, const VkDescriptorBufferInfo &buffer)
|
||||
{
|
||||
WriteDescriptors(
|
||||
ImageWrite(dstSet, 0, ImageDescriptor(imageView0, VK_IMAGE_LAYOUT_GENERAL)),
|
||||
ImageWrite(dstSet, 1, ImageDescriptor(imageView1, VK_IMAGE_LAYOUT_GENERAL)),
|
||||
BufferWrite(dstSet, 2, buffer));
|
||||
ImageWrite(dstSet, 2, ImageDescriptor(imageView2, VK_IMAGE_LAYOUT_GENERAL)),
|
||||
BufferWrite(dstSet, 3, buffer));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -89,20 +94,42 @@ struct ComputeApplication {
|
|||
{
|
||||
VkDescriptorSet descriptorSet;
|
||||
VulkanBuffer uboBuf;
|
||||
VulkanTexture texture0, texture1;
|
||||
VulkanTexture texture0, texture1, texture2;
|
||||
VkCommandBuffer commandBuffer;
|
||||
VkFence fence;
|
||||
bool running = false;
|
||||
uint8_t *pReconstructionData;
|
||||
|
||||
} chain[CHAIN_SIZE];
|
||||
|
||||
void ImportVaapiImage(VulkanTexture &texture0, VulkanTexture &texture1, int fd, uint64_t mod, uint32_t size, uint32_t offset, uint32_t pitch1, uint32_t pitch2, bool p010)
|
||||
void CreateReconstructionImage(VulkanTexture &image, VkFormat format, unsigned int width, unsigned int height, uint8_t **ppReconstructionData)
|
||||
{
|
||||
CallWith(Image2dInfo(VK_IMAGE_USAGE_STORAGE_BIT, format, width, height,
|
||||
$(tiling) = VK_IMAGE_TILING_LINEAR,
|
||||
$(initialLayout) = VK_IMAGE_LAYOUT_UNDEFINED ),
|
||||
vkCreateImage(dev.device, &ref,NULL, &image.image));
|
||||
VkMemoryRequirements mem_reqs;
|
||||
vkGetImageMemoryRequirements(dev.device, image.image, &mem_reqs);
|
||||
VkMemoryAllocateInfo info = AllocateInfo(mem_reqs.size);
|
||||
dev.GetMemoryType(mem_reqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &info.memoryTypeIndex);
|
||||
vkAllocateMemory(dev.device, &info, NULL, &image.device_memory);
|
||||
vkMapMemory(dev.device, image.device_memory, 0, mem_reqs.size, 0, (void**)ppReconstructionData);
|
||||
vkBindImageMemory(dev.device, image.image, image.device_memory, 0);
|
||||
CallWith($M(VkImageViewCreateInfo{VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO},
|
||||
$(image) = image.image, $(viewType) = VK_IMAGE_VIEW_TYPE_2D,
|
||||
$(format) = format,
|
||||
$(subresourceRange) = SubresourceRange()),
|
||||
vkCreateImageView(dev.device, &ref, NULL, &image.view));
|
||||
image.owning_device = dev.device;
|
||||
}
|
||||
|
||||
void ImportVaapiImage(VulkanTexture &texture0, VulkanTexture &texture1, unsigned int width, unsigned int height, int fd, uint64_t mod, uint32_t size, uint32_t offset, uint32_t pitch1, uint32_t pitch2, bool p010)
|
||||
{
|
||||
$Sc layout = SubresourceLayout(pitch1);
|
||||
$Sc iinfo{Image2dInfo(
|
||||
VK_IMAGE_USAGE_STORAGE_BIT,
|
||||
p010?VK_FORMAT_R16_UNORM:VK_FORMAT_R8_UNORM,
|
||||
WIDTH, HEIGHT,
|
||||
width, height,
|
||||
$(tiling) = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT),
|
||||
$Vk<VkExternalMemoryImageCreateInfo>(
|
||||
$(handleTypes) = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT),
|
||||
|
@ -113,7 +140,7 @@ struct ComputeApplication {
|
|||
|
||||
VK_CHECK_RESULT(vkCreateImage(dev.device, &iinfo, NULL, &texture0.image)); // create image.
|
||||
$F(iinfo,$(format) = p010?VK_FORMAT_R16G16_UNORM:VK_FORMAT_R8G8_UNORM,
|
||||
$(extent) = VkExtent3D{ WIDTH/2, HEIGHT/2, 1 });
|
||||
$(extent) = VkExtent3D{ width/2, height/2, 1 });
|
||||
$F(layout,$(offset) = 0, $(rowPitch) = pitch2 );
|
||||
VK_CHECK_RESULT(vkCreateImage(dev.device, &iinfo, NULL, &texture1.image)); // create image.
|
||||
|
||||
|
@ -137,10 +164,10 @@ struct ComputeApplication {
|
|||
VK_CHECK_RESULT(vkBindImageMemory(dev.device, texture0.image, texture0.device_memory, 0));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(dev.device, texture1.image, texture0.device_memory, offset));
|
||||
$F(texture0,
|
||||
$(width) = WIDTH, $(height) = HEIGHT,
|
||||
$(width) = width, $(height) = height,
|
||||
$(mip_levels), $(layer_count));
|
||||
$F(texture1,
|
||||
$(width) = WIDTH/2, $(height) = HEIGHT/2,
|
||||
$(width) = width/2, $(height) = height/2,
|
||||
$(mip_levels), $(layer_count));
|
||||
texture0.CreateImageView(dev.device, p010?VK_FORMAT_R16_UNORM:VK_FORMAT_R8_UNORM);
|
||||
texture1.CreateImageView(dev.device, p010?VK_FORMAT_R16G16_UNORM:VK_FORMAT_R8G8_UNORM);
|
||||
|
@ -148,7 +175,7 @@ struct ComputeApplication {
|
|||
|
||||
void createDescriptorSet(int chidx) {
|
||||
chain[chidx].descriptorSet = computePipeline.AllocateSingleDescriptorSet();
|
||||
computePipeline.UpdateDescriptors(chain[chidx].descriptorSet, chain[chidx].texture0.view, chain[chidx].texture1.view, chain[chidx].uboBuf.descriptor);
|
||||
computePipeline.UpdateDescriptors(chain[chidx].descriptorSet, chain[chidx].texture0.view, chain[chidx].texture1.view, chain[chidx].texture2.view, chain[chidx].uboBuf.descriptor);
|
||||
}
|
||||
|
||||
void prepareImage(int chidx)
|
||||
|
@ -156,6 +183,7 @@ struct ComputeApplication {
|
|||
VkCommandBuffer commandBuffer = dev.CreateCommandBuffer();
|
||||
VulkanTexture::SetImageLayout(commandBuffer,chain[chidx].texture0.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL, { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 });
|
||||
VulkanTexture::SetImageLayout(commandBuffer,chain[chidx].texture1.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL, { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 });
|
||||
VulkanTexture::SetImageLayout(commandBuffer,chain[chidx].texture2.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL, { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 });
|
||||
dev.FlushCommandBuffer(commandBuffer, dev.defautQueue);
|
||||
}
|
||||
|
||||
|
@ -168,7 +196,7 @@ struct ComputeApplication {
|
|||
*/
|
||||
vkCmdBindPipeline(chain[chidx].commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, computePipeline.pipeline);
|
||||
vkCmdBindDescriptorSets(chain[chidx].commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, computePipeline.pipelineLayout, 0, 1, &chain[chidx].descriptorSet, 0, NULL);
|
||||
vkCmdDispatch(chain[chidx].commandBuffer, (uint32_t)ceil(WIDTH/2 / float(WORKGROUP_SIZE)), (uint32_t)ceil(HEIGHT/2 / float(WORKGROUP_SIZE)), 1);
|
||||
vkCmdDispatch(chain[chidx].commandBuffer, (uint32_t)ceil(WIDTH/4 / float(WORKGROUP_SIZE)), (uint32_t)ceil(HEIGHT/4 / float(WORKGROUP_SIZE)), 1);
|
||||
VK_CHECK_RESULT(vkEndCommandBuffer(chain[chidx].commandBuffer)); // end recording commands.
|
||||
$Sc fenceCreateInfo = FenceInfo();
|
||||
VK_CHECK_RESULT(vkCreateFence(dev.device, &fenceCreateInfo, NULL, &chain[chidx].fence));
|
||||
|
@ -206,14 +234,15 @@ struct ComputeApplication {
|
|||
int count = dev.GetAvailiableModifiersList(modifiers, 32, p010?VK_FORMAT_R16_UNORM:VK_FORMAT_R8_UNORM);
|
||||
Codec enc = {};
|
||||
|
||||
enc.Setup(drm_fd, WIDTH, HEIGHT, filename, fd, &mod, &size, &offset, &pitch1, &pitch2, modifiers, count, p010);
|
||||
enc.Setup(drm_fd, WIDTH/2, HEIGHT/2, filename, fd, &mod, &size, &offset, &pitch1, &pitch2, modifiers, count, p010);
|
||||
for(int i = 0; i < CHAIN_SIZE; i++)
|
||||
{
|
||||
dev.CreateAndMap(chain[i].uboBuf, sizeof(UBO));
|
||||
ImportVaapiImage(chain[i].texture0, chain[i].texture1, fd[i], mod, size, offset, pitch1, pitch2, p010);
|
||||
ImportVaapiImage(chain[i].texture0, chain[i].texture1, WIDTH/2, HEIGHT/2, fd[i], mod, size, offset, pitch1, pitch2, p010);
|
||||
CreateReconstructionImage(chain[i].texture2, VK_FORMAT_R4G4B4A4_UNORM_PACK16, WIDTH/2, HEIGHT/2, &chain[i].pReconstructionData);
|
||||
}
|
||||
|
||||
computePipeline.Init(dev.device);
|
||||
computePipeline.Init(dev.device, WIDTH, HEIGHT);
|
||||
for(int i = 0; i < CHAIN_SIZE; i++)
|
||||
{
|
||||
prepareImage(i);
|
||||
|
@ -221,6 +250,7 @@ struct ComputeApplication {
|
|||
createCommandBuffer(i);
|
||||
}
|
||||
int frameNum = 0;
|
||||
FILE *reconstructionStream = fopen("reconstruction.bin", "wb");
|
||||
|
||||
while(frameNum++ < 1000)
|
||||
{
|
||||
|
@ -230,6 +260,9 @@ struct ComputeApplication {
|
|||
#ifndef SKIP_FENCE_SYNC
|
||||
waitFence(chidx);
|
||||
#endif
|
||||
uint32_t imageSize = (WIDTH/2) * (HEIGHT/2) * 2;
|
||||
fwrite(&imageSize, sizeof(imageSize), 1, reconstructionStream);
|
||||
fwrite(chain[chidx].pReconstructionData, 1, imageSize, reconstructionStream);
|
||||
//recorder_frame4(r, chidx);
|
||||
if(frameNum == 1)
|
||||
enc.EncodeIDR(chidx);
|
||||
|
@ -238,11 +271,13 @@ struct ComputeApplication {
|
|||
((UBO*)chain[chidx].uboBuf.mapped)->frameNum = frameNum;
|
||||
|
||||
}
|
||||
fclose(reconstructionStream);
|
||||
for(int i = 0; i < CHAIN_SIZE; i++)
|
||||
{
|
||||
waitFence(i);
|
||||
vkDestroyFence(dev.device, chain[i].fence, NULL);
|
||||
chain[i].uboBuf.Destroy();
|
||||
chain[i].texture2.Destroy();
|
||||
chain[i].texture1.Destroy();
|
||||
chain[i].texture0.Destroy();
|
||||
}
|
||||
|
|
31
vkplayer.cpp
31
vkplayer.cpp
|
@ -287,14 +287,14 @@ void SetupReconstructionImages(VulkanDevice &dev, VkFormat format, unsigned int
|
|||
for(int i = 0; i < RECONSTRUCTION_SOURCE_FRAMES; i++)
|
||||
{
|
||||
ReconsructionSource &image = gReconstruction.sources[i];
|
||||
CallWith(Image2dInfo(VK_IMAGE_USAGE_SAMPLED_BIT, format, width, height,
|
||||
CallWith(Image2dInfo(VK_IMAGE_USAGE_STORAGE_BIT, format, width, height,
|
||||
$(tiling) = VK_IMAGE_TILING_LINEAR,
|
||||
$(initialLayout) = VK_IMAGE_LAYOUT_UNDEFINED ),
|
||||
vkCreateImage(dev.device, &ref,NULL, &image.image));
|
||||
VkMemoryRequirements mem_reqs;
|
||||
vkGetImageMemoryRequirements(dev.device, image.image, &mem_reqs);
|
||||
VkMemoryAllocateInfo info = AllocateInfo(mem_reqs.size);
|
||||
dev.GetMemoryType(mem_reqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &info.memoryTypeIndex);
|
||||
dev.GetMemoryType(mem_reqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, &info.memoryTypeIndex);
|
||||
vkAllocateMemory(dev.device, &info, NULL, &image.image_memory);
|
||||
vkMapMemory(dev.device, image.image_memory, 0, mem_reqs.size, 0, (void**)&image.pMappedData);
|
||||
vkBindImageMemory(dev.device, image.image, image.image_memory, 0);
|
||||
|
@ -303,6 +303,9 @@ void SetupReconstructionImages(VulkanDevice &dev, VkFormat format, unsigned int
|
|||
$(format) = format,
|
||||
$(subresourceRange) = SubresourceRange()),
|
||||
vkCreateImageView(dev.device, &ref, NULL, &image.image_view));
|
||||
VkCommandBuffer cbuf = dev.CreateCommandBuffer();
|
||||
VulkanTexture::SetImageLayout(cbuf, image.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL, { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 });
|
||||
dev.FlushCommandBuffer(cbuf,dev.defautQueue);
|
||||
}
|
||||
gReconstruction.reconstructionStream = fopen("reconstruction.bin", "rb");
|
||||
}
|
||||
|
@ -378,26 +381,28 @@ struct ComputeApplicationPipeline: BaseVulkanPipeline
|
|||
device = dev;
|
||||
CreateDescriptorSetLayout(
|
||||
BasicBinding(0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,1,VK_SHADER_STAGE_COMPUTE_BIT, pImmutableSamplers),
|
||||
BasicBinding(1, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,1,VK_SHADER_STAGE_COMPUTE_BIT)
|
||||
BasicBinding(1, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,1,VK_SHADER_STAGE_COMPUTE_BIT),
|
||||
BasicBinding(2, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,1,VK_SHADER_STAGE_COMPUTE_BIT)
|
||||
);
|
||||
CreatePool((count1 + count3) * count2,
|
||||
BasicPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, count2 * count3),
|
||||
BasicPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, count3 * count2 * count1));
|
||||
BasicPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, count3 * count2 * count1*2));
|
||||
// todo: wrapper for specialization arrays...
|
||||
float specData[2] = {(float)width,(float)height};
|
||||
VkSpecializationMapEntry specs[2] = {{0, 0, sizeof(float)},1,sizeof(float),sizeof(float)};
|
||||
VkSpecializationInfo sinfo = {2, specs, sizeof(specData), specData };
|
||||
VkShaderModule shader;
|
||||
// todo: combined reconstruction/foveation shader? (maybe ineffective for compute pipeline)
|
||||
CreateComputePipeline(ShaderFromFile(shader, "quad.comp.spv", VK_SHADER_STAGE_COMPUTE_BIT, &sinfo));
|
||||
CreateComputePipeline(ShaderFromFile(shader, "reconstruction.comp.spv", VK_SHADER_STAGE_COMPUTE_BIT, &sinfo));
|
||||
// todo: should not we destroy shader internally?
|
||||
vkDestroyShaderModule(device, shader, NULL);
|
||||
}
|
||||
void UpdateDescriptors(VkDescriptorSet dstSet, VkImageView imageView, VkSampler sampler, VkImageView imageView1)
|
||||
void UpdateDescriptors(VkDescriptorSet dstSet, VkImageView imageView, VkSampler sampler, VkImageView imageView1, VkImageView imageView2)
|
||||
{
|
||||
WriteDescriptors(
|
||||
ImageWrite(dstSet, 0, ImageDescriptor(imageView, VK_IMAGE_LAYOUT_GENERAL, sampler), VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER),
|
||||
ImageWrite(dstSet, 1, ImageDescriptor(imageView1, VK_IMAGE_LAYOUT_GENERAL)));
|
||||
ImageWrite(dstSet, 1, ImageDescriptor(imageView1, VK_IMAGE_LAYOUT_GENERAL)),
|
||||
ImageWrite(dstSet, 2, ImageDescriptor(imageView2, VK_IMAGE_LAYOUT_GENERAL)));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -568,8 +573,8 @@ struct GraphicsApplication
|
|||
// on edges and may increase bandwidth to much
|
||||
int rwidth_out = 1920; // fov
|
||||
int rheight_out = 1080; // fov
|
||||
int rwidth_in = 1920; // /2
|
||||
int rheight_in = 1080; // /2
|
||||
int rwidth_in = 1920/2;
|
||||
int rheight_in = 1080/2;
|
||||
SetupReconstructionImages(dev, VK_FORMAT_R4G4B4A4_UNORM_PACK16, rwidth_in, rheight_in);
|
||||
|
||||
CreateWindow("demo", width, height, false);
|
||||
|
@ -608,7 +613,8 @@ struct GraphicsApplication
|
|||
{
|
||||
int ci = MAX_DECODER_FRAMES * i + j;
|
||||
swapchainDescriptorSets[ci] = computePipeline.AllocateSingleDescriptorSet();
|
||||
computePipeline.UpdateDescriptors(swapchainDescriptorSets[ci], gFF.images[j].image_view, gFF.ycbcr_sampler, swapchainFbs[i].color_view);
|
||||
// todo: reconstruction sources are incorrect here!
|
||||
computePipeline.UpdateDescriptors(swapchainDescriptorSets[ci], gFF.images[j].image_view, gFF.ycbcr_sampler, gReconstruction.sources[i].image_view, swapchainFbs[i].color_view);
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < RECONSTRUCTION_TARGET_FRAMES; i++)
|
||||
|
@ -623,7 +629,7 @@ struct GraphicsApplication
|
|||
{
|
||||
int ci = MAX_DECODER_FRAMES * i + j;
|
||||
reconstructionDescriptorSets[ci] = computePipeline.AllocateSingleDescriptorSet();
|
||||
computePipeline.UpdateDescriptors(reconstructionDescriptorSets[ci], gFF.images[j].image_view, gFF.ycbcr_sampler, reconstructionFbs[i].color_view);
|
||||
computePipeline.UpdateDescriptors(reconstructionDescriptorSets[ci], gFF.images[j].image_view, gFF.ycbcr_sampler, gReconstruction.sources[i].image_view, reconstructionFbs[i].color_view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -749,6 +755,7 @@ struct GraphicsApplication
|
|||
|
||||
if(separateReconstruction)
|
||||
{
|
||||
ridx = ReadReconstructionFrame() & 3;
|
||||
CallWith(
|
||||
SubmitInfo(
|
||||
reconstructionCommandBuffers[ridx * MAX_DECODER_FRAMES + decoder_idx],$(waitSemaphoreCount), $(signalSemaphoreCount),
|
||||
|
@ -763,7 +770,7 @@ struct GraphicsApplication
|
|||
$(pSignalSemaphores) = &swapchainPresentSemaphore[idx],
|
||||
$(pWaitDstStageMask) = &waitDstStageMask),
|
||||
vkQueueSubmit(dev.defautQueue, 1, &ref, chainFences[sem_idx]));
|
||||
ridx = (ridx + 1) & 3;
|
||||
//ridx = (ridx + 1) & 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue