surface_view: Add constructor for ViewParams
This commit is contained in:
parent
16e8625a30
commit
549fd18ac4
|
@ -226,13 +226,8 @@ CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& param
|
||||||
target = GetTextureTarget(params.target);
|
target = GetTextureTarget(params.target);
|
||||||
texture = CreateTexture(params, target, internal_format);
|
texture = CreateTexture(params, target, internal_format);
|
||||||
DecorateSurfaceName();
|
DecorateSurfaceName();
|
||||||
ViewParams main{};
|
main_view = CreateView(
|
||||||
main.num_levels = params.num_levels;
|
ViewParams(params.target, 0, params.is_layered ? params.depth : 1, 0, params.num_levels));
|
||||||
main.base_level = 0;
|
|
||||||
main.base_layer = 0;
|
|
||||||
main.num_layers = params.is_layered ? params.depth : 1;
|
|
||||||
main.target = params.target;
|
|
||||||
main_view = CreateView(main);
|
|
||||||
main_view->DecorateViewName(gpu_addr,
|
main_view->DecorateViewName(gpu_addr,
|
||||||
params.TargetName() + "V:" + std::to_string(view_count++));
|
params.TargetName() + "V:" + std::to_string(view_count++));
|
||||||
}
|
}
|
||||||
|
@ -378,13 +373,11 @@ void CachedSurfaceView::Attach(GLenum attachment) const {
|
||||||
switch (owner_params.target) {
|
switch (owner_params.target) {
|
||||||
case SurfaceTarget::Texture1D:
|
case SurfaceTarget::Texture1D:
|
||||||
glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(),
|
glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(),
|
||||||
surface.GetTexture(),
|
surface.GetTexture(), params.base_level);
|
||||||
params.base_level);
|
|
||||||
break;
|
break;
|
||||||
case SurfaceTarget::Texture2D:
|
case SurfaceTarget::Texture2D:
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(),
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(),
|
||||||
surface.GetTexture(),
|
surface.GetTexture(), params.base_level);
|
||||||
params.base_level);
|
|
||||||
break;
|
break;
|
||||||
case SurfaceTarget::Texture1DArray:
|
case SurfaceTarget::Texture1DArray:
|
||||||
case SurfaceTarget::Texture2DArray:
|
case SurfaceTarget::Texture2DArray:
|
||||||
|
|
|
@ -253,45 +253,30 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
TView EmplaceOverview(const SurfaceParams& overview_params) {
|
TView EmplaceOverview(const SurfaceParams& overview_params) {
|
||||||
ViewParams vp{};
|
const u32 num_layers{params.is_layered && !overview_params.is_layered ? 1 : params.depth};
|
||||||
vp.base_level = 0;
|
const ViewParams view_params(overview_params.target, 0, num_layers, 0, params.num_levels);
|
||||||
vp.num_levels = params.num_levels;
|
return GetView(view_params);
|
||||||
vp.target = overview_params.target;
|
|
||||||
if (params.is_layered && !overview_params.is_layered) {
|
|
||||||
vp.base_layer = 0;
|
|
||||||
vp.num_layers = 1;
|
|
||||||
} else {
|
|
||||||
vp.base_layer = 0;
|
|
||||||
vp.num_layers = params.depth;
|
|
||||||
}
|
|
||||||
return GetView(vp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<TView> EmplaceView(const SurfaceParams& view_params, const GPUVAddr view_addr) {
|
std::optional<TView> EmplaceView(const SurfaceParams& view_params, const GPUVAddr view_addr) {
|
||||||
if (view_addr < gpu_addr)
|
if (view_addr < gpu_addr || params.target == SurfaceTarget::Texture3D ||
|
||||||
return {};
|
|
||||||
if (params.target == SurfaceTarget::Texture3D ||
|
|
||||||
view_params.target == SurfaceTarget::Texture3D) {
|
view_params.target == SurfaceTarget::Texture3D) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const std::size_t size = view_params.GetGuestSizeInBytes();
|
const std::size_t size{view_params.GetGuestSizeInBytes()};
|
||||||
auto layer_mipmap = GetLayerMipmap(view_addr);
|
const auto layer_mipmap{GetLayerMipmap(view_addr)};
|
||||||
if (!layer_mipmap) {
|
if (!layer_mipmap) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const u32 layer = (*layer_mipmap).first;
|
const u32 layer{layer_mipmap->first};
|
||||||
const u32 mipmap = (*layer_mipmap).second;
|
const u32 mipmap{layer_mipmap->second};
|
||||||
if (GetMipmapSize(mipmap) != size) {
|
if (GetMipmapSize(mipmap) != size) {
|
||||||
// TODO: the view may cover many mimaps, this case can still go on
|
// TODO: The view may cover many mimaps, this case can still go on.
|
||||||
|
// This edge-case can be safely be ignored since it will just result in worse
|
||||||
|
// performance.
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
ViewParams vp{};
|
return GetView(ViewParams(params.target, layer, 1, mipmap, 1));
|
||||||
vp.base_layer = layer;
|
|
||||||
vp.num_layers = 1;
|
|
||||||
vp.base_level = mipmap;
|
|
||||||
vp.num_levels = 1;
|
|
||||||
vp.target = view_params.target;
|
|
||||||
return {GetView(vp)};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TView GetMainView() const {
|
TView GetMainView() const {
|
||||||
|
|
|
@ -13,15 +13,21 @@
|
||||||
namespace VideoCommon {
|
namespace VideoCommon {
|
||||||
|
|
||||||
struct ViewParams {
|
struct ViewParams {
|
||||||
|
ViewParams(VideoCore::Surface::SurfaceTarget target, u32 base_layer, u32 num_layers,
|
||||||
|
u32 base_level, u32 num_levels)
|
||||||
|
: target{target}, base_layer{base_layer}, num_layers{num_layers}, base_level{base_level},
|
||||||
|
num_levels{num_levels} {}
|
||||||
|
|
||||||
std::size_t Hash() const;
|
std::size_t Hash() const;
|
||||||
|
|
||||||
bool operator==(const ViewParams& rhs) const;
|
bool operator==(const ViewParams& rhs) const;
|
||||||
|
|
||||||
|
VideoCore::Surface::SurfaceTarget target{};
|
||||||
u32 base_layer{};
|
u32 base_layer{};
|
||||||
u32 num_layers{};
|
u32 num_layers{};
|
||||||
u32 base_level{};
|
u32 base_level{};
|
||||||
u32 num_levels{};
|
u32 num_levels{};
|
||||||
VideoCore::Surface::SurfaceTarget target;
|
|
||||||
bool IsLayered() const {
|
bool IsLayered() const {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case VideoCore::Surface::SurfaceTarget::Texture1DArray:
|
case VideoCore::Surface::SurfaceTarget::Texture1DArray:
|
||||||
|
|
Loading…
Reference in a new issue