mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-30 02:32:46 +01:00
texture_cache: Pass TIC to texture cache
This commit is contained in:
parent
3a450c1395
commit
2424eefad2
4 changed files with 25 additions and 27 deletions
|
@ -1022,7 +1022,7 @@ bool RasterizerOpenGL::SetupTexture(const Shader& shader, u32 binding,
|
||||||
auto& unit{state.texture_units[binding]};
|
auto& unit{state.texture_units[binding]};
|
||||||
unit.sampler = sampler_cache.GetSampler(texture.tsc);
|
unit.sampler = sampler_cache.GetSampler(texture.tsc);
|
||||||
|
|
||||||
const auto view = texture_cache.GetTextureSurface(texture, entry);
|
const auto view = texture_cache.GetImageSurface(texture.tic, entry);
|
||||||
if (!view) {
|
if (!view) {
|
||||||
// Can occur when texture addr is null or its memory is unmapped/invalid
|
// Can occur when texture addr is null or its memory is unmapped/invalid
|
||||||
unit.texture = 0;
|
unit.texture = 0;
|
||||||
|
|
|
@ -61,18 +61,17 @@ constexpr u32 GetMipmapSize(bool uncompressed, u32 mip_size, u32 tile) {
|
||||||
}
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
SurfaceParams SurfaceParams::CreateForTexture(Core::System& system,
|
SurfaceParams SurfaceParams::CreateForImage(const Tegra::Texture::TICEntry& tic,
|
||||||
const Tegra::Texture::FullTextureInfo& config,
|
|
||||||
const VideoCommon::Shader::Sampler& entry) {
|
const VideoCommon::Shader::Sampler& entry) {
|
||||||
SurfaceParams params;
|
SurfaceParams params;
|
||||||
params.is_tiled = config.tic.IsTiled();
|
params.is_tiled = tic.IsTiled();
|
||||||
params.srgb_conversion = config.tic.IsSrgbConversionEnabled();
|
params.srgb_conversion = tic.IsSrgbConversionEnabled();
|
||||||
params.block_width = params.is_tiled ? config.tic.BlockWidth() : 0,
|
params.block_width = params.is_tiled ? tic.BlockWidth() : 0,
|
||||||
params.block_height = params.is_tiled ? config.tic.BlockHeight() : 0,
|
params.block_height = params.is_tiled ? tic.BlockHeight() : 0,
|
||||||
params.block_depth = params.is_tiled ? config.tic.BlockDepth() : 0,
|
params.block_depth = params.is_tiled ? tic.BlockDepth() : 0,
|
||||||
params.tile_width_spacing = params.is_tiled ? (1 << config.tic.tile_width_spacing.Value()) : 1;
|
params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1;
|
||||||
params.pixel_format = PixelFormatFromTextureFormat(config.tic.format, config.tic.r_type.Value(),
|
params.pixel_format =
|
||||||
params.srgb_conversion);
|
PixelFormatFromTextureFormat(tic.format, tic.r_type.Value(), params.srgb_conversion);
|
||||||
params.type = GetFormatType(params.pixel_format);
|
params.type = GetFormatType(params.pixel_format);
|
||||||
if (entry.IsShadow() && params.type == SurfaceType::ColorTexture) {
|
if (entry.IsShadow() && params.type == SurfaceType::ColorTexture) {
|
||||||
switch (params.pixel_format) {
|
switch (params.pixel_format) {
|
||||||
|
@ -92,25 +91,25 @@ SurfaceParams SurfaceParams::CreateForTexture(Core::System& system,
|
||||||
}
|
}
|
||||||
params.type = GetFormatType(params.pixel_format);
|
params.type = GetFormatType(params.pixel_format);
|
||||||
}
|
}
|
||||||
params.component_type = ComponentTypeFromTexture(config.tic.r_type.Value());
|
params.component_type = ComponentTypeFromTexture(tic.r_type.Value());
|
||||||
params.type = GetFormatType(params.pixel_format);
|
params.type = GetFormatType(params.pixel_format);
|
||||||
// TODO: on 1DBuffer we should use the tic info.
|
// TODO: on 1DBuffer we should use the tic info.
|
||||||
if (!config.tic.IsBuffer()) {
|
if (!tic.IsBuffer()) {
|
||||||
params.target = TextureType2SurfaceTarget(entry.GetType(), entry.IsArray());
|
params.target = TextureType2SurfaceTarget(entry.GetType(), entry.IsArray());
|
||||||
params.width = config.tic.Width();
|
params.width = tic.Width();
|
||||||
params.height = config.tic.Height();
|
params.height = tic.Height();
|
||||||
params.depth = config.tic.Depth();
|
params.depth = tic.Depth();
|
||||||
params.pitch = params.is_tiled ? 0 : config.tic.Pitch();
|
params.pitch = params.is_tiled ? 0 : tic.Pitch();
|
||||||
if (params.target == SurfaceTarget::TextureCubemap ||
|
if (params.target == SurfaceTarget::TextureCubemap ||
|
||||||
params.target == SurfaceTarget::TextureCubeArray) {
|
params.target == SurfaceTarget::TextureCubeArray) {
|
||||||
params.depth *= 6;
|
params.depth *= 6;
|
||||||
}
|
}
|
||||||
params.num_levels = config.tic.max_mip_level + 1;
|
params.num_levels = tic.max_mip_level + 1;
|
||||||
params.emulated_levels = std::min(params.num_levels, params.MaxPossibleMipmap());
|
params.emulated_levels = std::min(params.num_levels, params.MaxPossibleMipmap());
|
||||||
params.is_layered = params.IsLayered();
|
params.is_layered = params.IsLayered();
|
||||||
} else {
|
} else {
|
||||||
params.target = SurfaceTarget::TextureBuffer;
|
params.target = SurfaceTarget::TextureBuffer;
|
||||||
params.width = config.tic.Width();
|
params.width = tic.Width();
|
||||||
params.pitch = params.width * params.GetBytesPerPixel();
|
params.pitch = params.width * params.GetBytesPerPixel();
|
||||||
params.height = 1;
|
params.height = 1;
|
||||||
params.depth = 1;
|
params.depth = 1;
|
||||||
|
|
|
@ -23,8 +23,7 @@ using VideoCore::Surface::SurfaceCompression;
|
||||||
class SurfaceParams {
|
class SurfaceParams {
|
||||||
public:
|
public:
|
||||||
/// Creates SurfaceCachedParams from a texture configuration.
|
/// Creates SurfaceCachedParams from a texture configuration.
|
||||||
static SurfaceParams CreateForTexture(Core::System& system,
|
static SurfaceParams CreateForImage(const Tegra::Texture::TICEntry& tic,
|
||||||
const Tegra::Texture::FullTextureInfo& config,
|
|
||||||
const VideoCommon::Shader::Sampler& entry);
|
const VideoCommon::Shader::Sampler& entry);
|
||||||
|
|
||||||
/// Creates SurfaceCachedParams for a depth buffer configuration.
|
/// Creates SurfaceCachedParams for a depth buffer configuration.
|
||||||
|
|
|
@ -89,14 +89,14 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TView GetTextureSurface(const Tegra::Texture::FullTextureInfo& config,
|
TView GetImageSurface(const Tegra::Texture::TICEntry& tic,
|
||||||
const VideoCommon::Shader::Sampler& entry) {
|
const VideoCommon::Shader::Sampler& entry) {
|
||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
const auto gpu_addr{config.tic.Address()};
|
const auto gpu_addr{tic.Address()};
|
||||||
if (!gpu_addr) {
|
if (!gpu_addr) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const auto params{SurfaceParams::CreateForTexture(system, config, entry)};
|
const auto params{SurfaceParams::CreateForImage(tic, entry)};
|
||||||
const auto [surface, view] = GetSurface(gpu_addr, params, true, false);
|
const auto [surface, view] = GetSurface(gpu_addr, params, true, false);
|
||||||
if (guard_samplers) {
|
if (guard_samplers) {
|
||||||
sampled_textures.push_back(surface);
|
sampled_textures.push_back(surface);
|
||||||
|
|
Loading…
Reference in a new issue