VGT_INDX_OFFSET actually means index/vertex offset

Fixup depth resolves
This commit is contained in:
Dr. Chat 2016-06-24 14:35:24 -05:00
parent 036df2ce12
commit ab4245c6af
2 changed files with 23 additions and 42 deletions

View File

@ -258,34 +258,6 @@ TextureCache::Texture* TextureCache::AllocateTexture(
texture->memory_offset = 0;
texture->memory_size = mem_requirements.size;
texture->texture_info = texture_info;
// Create a default view, just for kicks.
VkImageViewCreateInfo view_info;
view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
view_info.pNext = nullptr;
view_info.flags = 0;
view_info.image = image;
view_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
view_info.format = image_info.format;
view_info.components = {
VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B,
VK_COMPONENT_SWIZZLE_A,
};
view_info.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
VkImageView view;
err = vkCreateImageView(*device_, &view_info, nullptr, &view);
CheckResult(err, "vkCreateImageView");
if (err == VK_SUCCESS) {
auto texture_view = std::make_unique<TextureView>();
texture_view->texture = texture;
texture_view->view = view;
texture_view->swiz_x = 0;
texture_view->swiz_y = 1;
texture_view->swiz_z = 2;
texture_view->swiz_w = 3;
texture->views.push_back(std::move(texture_view));
}
return texture;
}
@ -537,6 +509,12 @@ TextureCache::TextureView* TextureCache::DemandView(Texture* texture,
swiz_component_map[(swizzle >> 9) & 0x7],
};
view_info.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
if (texture->format == VK_FORMAT_D24_UNORM_S8_UINT) {
// This applies to any depth/stencil format, but we only use D24S8.
view_info.subresourceRange.aspectMask =
VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
}
VkImageView view;
auto status = vkCreateImageView(*device_, &view_info, nullptr, &view);
CheckResult(status, "vkCreateImageView");

View File

@ -582,9 +582,9 @@ bool VulkanCommandProcessor::IssueDraw(PrimitiveType primitive_type,
} else {
// Index buffer draw.
uint32_t instance_count = 1;
uint32_t first_index =
uint32_t first_index = 0;
uint32_t vertex_offset =
register_file_->values[XE_GPU_REG_VGT_INDX_OFFSET].u32;
uint32_t vertex_offset = 0;
uint32_t first_instance = 0;
vkCmdDrawIndexed(command_buffer, index_count, instance_count, first_index,
vertex_offset, first_instance);
@ -788,8 +788,8 @@ bool VulkanCommandProcessor::IssueCopy() {
assert_true(copy_dest_array == 0);
uint32_t copy_dest_slice = (copy_dest_info >> 4) & 0x7;
assert_true(copy_dest_slice == 0);
auto copy_dest_format =
static_cast<ColorFormat>((copy_dest_info >> 7) & 0x3F);
auto copy_dest_format = ColorFormatToTextureFormat(
static_cast<ColorFormat>((copy_dest_info >> 7) & 0x3F));
uint32_t copy_dest_number = (copy_dest_info >> 13) & 0x7;
// assert_true(copy_dest_number == 0); // ?
uint32_t copy_dest_bias = (copy_dest_info >> 16) & 0x3F;
@ -840,7 +840,7 @@ bool VulkanCommandProcessor::IssueCopy() {
window_offset_y |= 0x8000;
}
size_t read_size = GetTexelSize(ColorFormatToTextureFormat(copy_dest_format));
size_t read_size = GetTexelSize(copy_dest_format);
// Adjust the copy base offset to point to the beginning of the texture, so
// we don't run into hiccups down the road (e.g. resolving the last part going
@ -916,6 +916,9 @@ bool VulkanCommandProcessor::IssueCopy() {
depth_format =
static_cast<DepthRenderTargetFormat>((depth_info >> 16) & 0x1);
if (!depth_clear_enabled) {
copy_dest_format = TextureFormat::k_24_8;
}
}
// Demand a resolve texture from the texture cache.
@ -925,8 +928,7 @@ bool VulkanCommandProcessor::IssueCopy() {
tex_info.height = dest_logical_height - 1;
tex_info.dimension = gpu::Dimension::k2D;
tex_info.input_length = copy_dest_pitch * copy_dest_height * 4;
tex_info.format_info =
FormatInfo::Get(uint32_t(ColorFormatToTextureFormat(copy_dest_format)));
tex_info.format_info = FormatInfo::Get(uint32_t(copy_dest_format));
tex_info.size_2d.logical_width = dest_logical_width;
tex_info.size_2d.logical_height = dest_logical_height;
tex_info.size_2d.block_width = dest_block_width;
@ -934,8 +936,8 @@ bool VulkanCommandProcessor::IssueCopy() {
tex_info.size_2d.input_width = dest_block_width;
tex_info.size_2d.input_height = dest_block_height;
tex_info.size_2d.input_pitch = copy_dest_pitch * 4;
auto texture = texture_cache_->DemandResolveTexture(
tex_info, ColorFormatToTextureFormat(copy_dest_format), nullptr);
auto texture =
texture_cache_->DemandResolveTexture(tex_info, copy_dest_format, nullptr);
assert_not_null(texture);
texture->in_flight_fence = current_batch_fence_;
@ -1001,6 +1003,7 @@ bool VulkanCommandProcessor::IssueCopy() {
uint32_t src_format = copy_src_select <= 3
? static_cast<uint32_t>(color_format)
: static_cast<uint32_t>(depth_format);
VkFilter filter = copy_src_select <= 3 ? VK_FILTER_LINEAR : VK_FILTER_NEAREST;
switch (copy_command) {
case CopyCommand::kRaw:
/*
@ -1010,11 +1013,11 @@ bool VulkanCommandProcessor::IssueCopy() {
break;
*/
case CopyCommand::kConvert:
render_cache_->BlitToImage(
command_buffer, edram_base, surface_pitch, resolve_extent.height,
surface_msaa, texture->image, texture->image_layout,
copy_src_select <= 3, src_format, VK_FILTER_LINEAR, resolve_offset,
resolve_extent);
render_cache_->BlitToImage(command_buffer, edram_base, surface_pitch,
resolve_extent.height, surface_msaa,
texture->image, texture->image_layout,
copy_src_select <= 3, src_format, filter,
resolve_offset, resolve_extent);
break;
case CopyCommand::kConstantOne: