Skip to content

Commit

Permalink
only set array length for texture view arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
SamoZ256 committed Nov 20, 2024
1 parent 9095035 commit d9f857b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Cafe/HW/Latte/Renderer/Metal/LatteTextureViewMtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Cafe/HW/Latte/Renderer/Metal/LatteTextureMtl.h"
#include "Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h"
#include "Cafe/HW/Latte/Renderer/Metal/LatteToMtl.h"
#include "Metal/MTLTexture.hpp"

uint32 LatteTextureMtl_AdjustTextureCompSel(Latte::E_GX2SURFFMT format, uint32 compSel)
{
Expand Down Expand Up @@ -158,21 +159,21 @@ MTL::Texture* LatteTextureViewMtl::CreateSwizzledView(uint32 gpuSamplerSwizzle)

uint32 baseLevel = firstMip;
uint32 levelCount = this->numMip;
uint32 baseLayer;
uint32 layerCount;
// TODO: check if base texture is 3D texture as well
uint32 baseLayer = 0;
uint32 layerCount = 1;

// TODO: check if base texture is 3D texture as well?
if (textureType == MTL::TextureType3D)
{
cemu_assert_debug(firstMip == 0);
cemu_assert_debug(this->numSlice == baseTexture->depth);
baseLayer = 0;
layerCount = 1;
}
else
{
baseLayer = firstSlice;
// Cube array needs to have layer count multiple of 6 as opposed to when creating a texture
else if (textureType == MTL::TextureTypeCubeArray || textureType == MTL::TextureType2DArray)
{
baseLayer = firstSlice;
layerCount = this->numSlice;
}
}

MTL::TextureSwizzleChannels swizzle;
swizzle.red = GetMtlTextureSwizzle(compSelR);
Expand Down

0 comments on commit d9f857b

Please sign in to comment.