Vulkan: Alias all input textures on the same binding
This commit is contained in:
parent
60664d86fc
commit
75b34b83a6
|
@ -214,12 +214,13 @@ void SpirvShaderTranslator::StartTranslation() {
|
||||||
b.makeArrayType(tex_t[2], b.makeUintConstant(32), 0),
|
b.makeArrayType(tex_t[2], b.makeUintConstant(32), 0),
|
||||||
b.makeArrayType(tex_t[3], b.makeUintConstant(32), 0)};
|
b.makeArrayType(tex_t[3], b.makeUintConstant(32), 0)};
|
||||||
|
|
||||||
|
// Create 4 texture types, all aliased on the same binding
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
tex_[i] = b.createVariable(spv::StorageClass::StorageClassUniformConstant,
|
tex_[i] = b.createVariable(spv::StorageClass::StorageClassUniformConstant,
|
||||||
tex_a_t[i],
|
tex_a_t[i],
|
||||||
xe::format_string("textures%dD", i + 1).c_str());
|
xe::format_string("textures%dD", i + 1).c_str());
|
||||||
b.addDecoration(tex_[i], spv::Decoration::DecorationDescriptorSet, 1);
|
b.addDecoration(tex_[i], spv::Decoration::DecorationDescriptorSet, 1);
|
||||||
b.addDecoration(tex_[i], spv::Decoration::DecorationBinding, i);
|
b.addDecoration(tex_[i], spv::Decoration::DecorationBinding, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interpolators.
|
// Interpolators.
|
||||||
|
@ -1401,6 +1402,12 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case FetchOpcode::kSetTextureLod: {
|
||||||
|
// <lod register> = src1.x
|
||||||
|
// ... immediately after
|
||||||
|
// tfetch UseRegisterLOD=true
|
||||||
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// TODO: the rest of these
|
// TODO: the rest of these
|
||||||
assert_unhandled_case(instr.opcode);
|
assert_unhandled_case(instr.opcode);
|
||||||
|
|
|
@ -140,16 +140,14 @@ TextureCache::TextureCache(Memory* memory, RegisterFile* register_file,
|
||||||
|
|
||||||
// Create the descriptor set layout used for rendering.
|
// Create the descriptor set layout used for rendering.
|
||||||
// We always have the same number of samplers but only some are used.
|
// We always have the same number of samplers but only some are used.
|
||||||
VkDescriptorSetLayoutBinding bindings[4];
|
// The shaders will alias the bindings to the 4 dimensional types.
|
||||||
for (int i = 0; i < xe::countof(bindings); ++i) {
|
VkDescriptorSetLayoutBinding bindings[1];
|
||||||
auto& texture_binding = bindings[i];
|
bindings[0].binding = 0;
|
||||||
texture_binding.binding = i;
|
bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
texture_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
bindings[0].descriptorCount = kMaxTextureSamplers;
|
||||||
texture_binding.descriptorCount = kMaxTextureSamplers;
|
bindings[0].stageFlags =
|
||||||
texture_binding.stageFlags =
|
|
||||||
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
|
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
texture_binding.pImmutableSamplers = nullptr;
|
bindings[0].pImmutableSamplers = nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo descriptor_set_layout_info;
|
VkDescriptorSetLayoutCreateInfo descriptor_set_layout_info;
|
||||||
descriptor_set_layout_info.sType =
|
descriptor_set_layout_info.sType =
|
||||||
|
@ -330,7 +328,7 @@ TextureCache::Texture* TextureCache::DemandResolveTexture(
|
||||||
VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
|
VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
|
||||||
xe::format_string(
|
xe::format_string(
|
||||||
"0x%.8X - 0x%.8X", texture_info.guest_address,
|
"0x%.8X - 0x%.8X", texture_info.guest_address,
|
||||||
texture_info.guest_address + texture_info.output_length));
|
texture_info.guest_address + texture_info.input_length));
|
||||||
|
|
||||||
// Setup an access watch. If this texture is touched, it is destroyed.
|
// Setup an access watch. If this texture is touched, it is destroyed.
|
||||||
texture->access_watch_handle = memory_->AddPhysicalAccessWatch(
|
texture->access_watch_handle = memory_->AddPhysicalAccessWatch(
|
||||||
|
@ -1356,22 +1354,7 @@ bool TextureCache::SetupTextureBinding(VkCommandBuffer command_buffer,
|
||||||
update_set_info->image_write_count++;
|
update_set_info->image_write_count++;
|
||||||
|
|
||||||
image_write->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
image_write->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
|
|
||||||
switch (texture_info.dimension) {
|
|
||||||
case Dimension::k1D:
|
|
||||||
image_write->dstBinding = 0;
|
image_write->dstBinding = 0;
|
||||||
break;
|
|
||||||
case Dimension::k2D:
|
|
||||||
image_write->dstBinding = 1;
|
|
||||||
break;
|
|
||||||
case Dimension::k3D:
|
|
||||||
image_write->dstBinding = 2;
|
|
||||||
break;
|
|
||||||
case Dimension::kCube:
|
|
||||||
image_write->dstBinding = 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
image_write->dstArrayElement = binding.fetch_constant;
|
image_write->dstArrayElement = binding.fetch_constant;
|
||||||
image_write->descriptorCount = 1;
|
image_write->descriptorCount = 1;
|
||||||
image_write->descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
image_write->descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
|
|
Loading…
Reference in New Issue