Skip to content

Commit

Permalink
doors
Browse files Browse the repository at this point in the history
  • Loading branch information
psucien committed Sep 21, 2024
1 parent 183523a commit dbeb457
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/video_core/amdgpu/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,15 @@ struct Image {
return pitch + 1;
}

u32 NumLayers() const {
u32 NumLayers(bool is_array) const {
u32 slices = GetType() == ImageType::Color3D ? 1 : depth + 1;
if (GetType() == ImageType::Cube) {
slices = std::max(last_array + 1, 6);
if (is_array) {
slices = last_array + 1;
ASSERT(slices % 6 == 0);
} else {
slices = 6;
}
}
if (pow2pad) {
slices = std::bit_ceil(slices);
Expand Down
2 changes: 1 addition & 1 deletion src/video_core/renderer_vulkan/vk_pipeline_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void Pipeline::BindTextures(VideoCore::TextureCache& texture_cache, const Shader
for (const auto& image_desc : stage.images) {
const auto tsharp = image_desc.GetSharp(stage);
if (tsharp.GetDataFmt() != AmdGpu::DataFormat::FormatInvalid) {
VideoCore::ImageInfo image_info{tsharp, image_desc.is_depth};
VideoCore::ImageInfo image_info{tsharp, image_desc};
const auto image_id = texture_cache.FindImage(image_info);
auto& image = texture_cache.GetImage(image_id);
image.flags |= VideoCore::ImageFlagBits::Bound;
Expand Down
2 changes: 1 addition & 1 deletion src/video_core/texture_cache/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Image::Image(const Vulkan::Instance& instance_, Vulkan::Scheduler& scheduler_,
// the texture cache should re-create the resource with the usage requested
vk::ImageCreateFlags flags{vk::ImageCreateFlagBits::eMutableFormat |
vk::ImageCreateFlagBits::eExtendedUsage};
if (info.props.is_cube) {
if (info.props.is_cube || (info.type == vk::ImageType::e2D && info.resources.layers >= 6)) {
flags |= vk::ImageCreateFlagBits::eCubeCompatible;
} else if (info.props.is_volume) {
flags |= vk::ImageCreateFlagBits::e2DArrayCompatible;
Expand Down
6 changes: 3 additions & 3 deletions src/video_core/texture_cache/image_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ ImageInfo::ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer, u32 num_slice
mips_layout.emplace_back(depth_slice_sz, pitch, 0);
}

ImageInfo::ImageInfo(const AmdGpu::Image& image, bool force_depth /*= false*/) noexcept {
ImageInfo::ImageInfo(const AmdGpu::Image& image, const Shader::ImageResource& desc) noexcept {
tiling_mode = image.GetTilingMode();
pixel_format = LiverpoolToVK::SurfaceFormat(image.GetDataFmt(), image.GetNumberFmt());
// Override format if image is forced to be a depth target
if (force_depth) {
if (desc.is_depth) {
pixel_format = LiverpoolToVK::PromoteFormatToDepth(pixel_format);
}
type = ConvertImageType(image.GetType());
Expand All @@ -218,7 +218,7 @@ ImageInfo::ImageInfo(const AmdGpu::Image& image, bool force_depth /*= false*/) n
size.depth = props.is_volume ? image.depth + 1 : 1;
pitch = image.Pitch();
resources.levels = image.NumLevels();
resources.layers = image.NumLayers();
resources.layers = image.NumLayers(desc.is_array);
num_bits = NumBits(image.GetDataFmt());
usage.texture = true;

Expand Down
3 changes: 2 additions & 1 deletion src/video_core/texture_cache/image_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "common/types.h"
#include "core/libraries/videoout/buffer.h"
#include "shader_recompiler/info.h"
#include "video_core/amdgpu/liverpool.h"
#include "video_core/texture_cache/types.h"

Expand All @@ -19,7 +20,7 @@ struct ImageInfo {
const AmdGpu::Liverpool::CbDbExtent& hint = {}) noexcept;
ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer, u32 num_slices, VAddr htile_address,
const AmdGpu::Liverpool::CbDbExtent& hint = {}) noexcept;
ImageInfo(const AmdGpu::Image& image, bool force_depth = false) noexcept;
ImageInfo(const AmdGpu::Image& image, const Shader::ImageResource& desc) noexcept;

bool IsTiled() const {
return tiling_mode != AmdGpu::TilingMode::Display_Linear;
Expand Down

0 comments on commit dbeb457

Please sign in to comment.