Commit b52fac03 by Geoff Lang Committed by Commit Bot

Refactor ImageIndex to have separate type and target members.

BUG=angleproject:2169 Change-Id: Ib3fb699058f76d0eb810a9691ea1d64311dadbb1 Reviewed-on: https://chromium-review.googlesource.com/929650 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent bacaa714
......@@ -151,7 +151,7 @@ bool CheckAttachmentSampleCompleteness(const Context *context,
// ES3.1 (section 9.4) requires that the value of TEXTURE_FIXED_SAMPLE_LOCATIONS should be
// the same for all attached textures.
bool fixedSampleloc = texture->getFixedSampleLocations(attachmentImageIndex.type,
bool fixedSampleloc = texture->getFixedSampleLocations(attachmentImageIndex.target,
attachmentImageIndex.mipIndex);
if (fixedSampleLocations->valid() && fixedSampleloc != fixedSampleLocations->value())
{
......
......@@ -236,7 +236,7 @@ GLenum FramebufferAttachment::cubeMapFace() const
ASSERT(mType == GL_TEXTURE);
const auto &index = mTarget.textureIndex();
return IsCubeMapTextureTarget(index.type) ? index.type : GL_NONE;
return index.type == GL_TEXTURE_CUBE_MAP ? index.target : GL_NONE;
}
GLint FramebufferAttachment::mipLevel() const
......@@ -250,12 +250,7 @@ GLint FramebufferAttachment::layer() const
ASSERT(mType == GL_TEXTURE);
const auto &index = mTarget.textureIndex();
if (index.type == GL_TEXTURE_2D_ARRAY || index.type == GL_TEXTURE_3D)
{
return index.layerIndex;
}
return 0;
return index.hasLayer() ? index.layerIndex : 0;
}
GLsizei FramebufferAttachment::getNumViews() const
......
......@@ -21,7 +21,10 @@ class ImageIndexIterator;
struct ImageIndex
{
GLenum type;
GLenum target;
GLint mipIndex;
GLint layerIndex;
GLint numLayers;
......@@ -30,6 +33,8 @@ struct ImageIndex
bool hasLayer() const { return layerIndex != ENTIRE_LEVEL; }
bool is3D() const;
GLint cubeMapFaceIndex() const;
bool valid() const;
static ImageIndex Make2D(GLint mipIndex);
static ImageIndex MakeRectangle(GLint mipIndex);
......@@ -44,16 +49,20 @@ struct ImageIndex
static const GLint ENTIRE_LEVEL = static_cast<GLint>(-1);
bool operator<(const ImageIndex &other) const;
bool operator==(const ImageIndex &other) const;
bool operator!=(const ImageIndex &other) const;
private:
friend class ImageIndexIterator;
ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn, GLint numLayersIn);
ImageIndex(GLenum typeIn,
GLenum targetIn,
GLint mipIndexIn,
GLint layerIndexIn,
GLint numLayersIn);
};
bool operator<(const ImageIndex &a, const ImageIndex &b);
bool operator==(const ImageIndex &a, const ImageIndex &b);
bool operator!=(const ImageIndex &a, const ImageIndex &b);
class ImageIndexIterator
{
public:
......@@ -71,19 +80,20 @@ class ImageIndexIterator
bool hasNext() const;
private:
ImageIndexIterator(GLenum type, const Range<GLint> &mipRange,
const Range<GLint> &layerRange, const GLsizei *layerCounts);
ImageIndexIterator(GLenum type,
const Range<GLenum> &targetRange,
const Range<GLint> &mipRange,
const Range<GLint> &layerRange,
const GLsizei *layerCounts);
GLint maxLayer() const;
void done();
GLenum mType;
Range<GLint> mMipRange;
Range<GLint> mLayerRange;
const GLsizei *mLayerCounts;
GLint mCurrentMip;
GLint mCurrentLayer;
const Range<GLenum> mTargetRange;
const Range<GLint> mMipRange;
const Range<GLint> mLayerRange;
const GLsizei *const mLayerCounts;
ImageIndex mCurrentIndex;
};
}
......
......@@ -33,6 +33,7 @@ TEST(ImageIndexTest, Iterator2D)
ImageIndex nextIndex = iter.next();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), nextIndex.type);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), nextIndex.target);
EXPECT_EQ(mip, nextIndex.mipIndex);
EXPECT_FALSE(nextIndex.hasLayer());
......@@ -47,23 +48,22 @@ TEST(ImageIndexTest, Iterator2D)
TEST(ImageIndexTest, IteratorCube)
{
ImageIndexIterator iter = ImageIndexIterator::MakeCube(0, 4);
ImageIndexIterator iter = ImageIndexIterator::MakeCube(minMip, maxMip);
ASSERT_GE(0, minMip);
for (GLint mip = minMip; mip < maxMip; mip++)
{
for (GLint layer = 0; layer < 6; layer++)
for (GLenum target = FirstCubeMapTextureTarget; target <= LastCubeMapTextureTarget;
target++)
{
EXPECT_TRUE(iter.hasNext());
ImageIndex nextIndex = iter.next();
GLenum cubeTarget = LayerIndexToCubeMapTextureTarget(layer);
EXPECT_EQ(cubeTarget, nextIndex.type);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP), nextIndex.type);
EXPECT_EQ(target, nextIndex.target);
EXPECT_EQ(mip, nextIndex.mipIndex);
EXPECT_EQ(layer, nextIndex.layerIndex);
EXPECT_TRUE(nextIndex.hasLayer());
EXPECT_FALSE(nextIndex.hasLayer());
}
}
......@@ -84,6 +84,7 @@ TEST(ImageIndexTest, Iterator3D)
ImageIndex nextIndex = iter.next();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_3D), nextIndex.type);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_3D), nextIndex.target);
EXPECT_EQ(mip, nextIndex.mipIndex);
EXPECT_EQ(layer, nextIndex.layerIndex);
EXPECT_TRUE(nextIndex.hasLayer());
......@@ -110,6 +111,7 @@ TEST(ImageIndexTest, Iterator2DArray)
ImageIndex nextIndex = iter.next();
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D_ARRAY), nextIndex.type);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D_ARRAY), nextIndex.target);
EXPECT_EQ(mip, nextIndex.mipIndex);
EXPECT_EQ(layer, nextIndex.layerIndex);
EXPECT_TRUE(nextIndex.hasLayer());
......
......@@ -499,7 +499,7 @@ void TextureState::setImageDesc(GLenum target, size_t level, const ImageDesc &de
const ImageDesc &TextureState::getImageDesc(const ImageIndex &imageIndex) const
{
return getImageDesc(imageIndex.type, imageIndex.mipIndex);
return getImageDesc(imageIndex.target, imageIndex.mipIndex);
}
void TextureState::setImageDescChain(GLuint baseLevel,
......@@ -1365,7 +1365,7 @@ const Format &Texture::getAttachmentFormat(GLenum /*binding*/, const ImageIndex
GLsizei Texture::getAttachmentSamples(const ImageIndex &imageIndex) const
{
return getSamples(imageIndex.type, 0);
return getSamples(imageIndex.target, 0);
}
void Texture::onAttach(const Context *context)
......@@ -1466,7 +1466,7 @@ void Texture::setInitState(const ImageIndex &imageIndex, InitState initState)
{
ImageDesc newDesc = mState.getImageDesc(imageIndex);
newDesc.initState = initState;
mState.setImageDesc(imageIndex.type, imageIndex.mipIndex, newDesc);
mState.setImageDesc(imageIndex.target, imageIndex.mipIndex, newDesc);
}
Error Texture::ensureSubImageInitialized(const Context *context,
......
......@@ -1553,8 +1553,8 @@ gl::ImageIndex TextureD3D_2D::getImageIndex(GLint mip, GLint /*layer*/) const
bool TextureD3D_2D::isValidIndex(const gl::ImageIndex &index) const
{
return (mTexStorage && index.type == GL_TEXTURE_2D &&
index.mipIndex >= 0 && index.mipIndex < mTexStorage->getLevelCount());
return (mTexStorage && index.type == GL_TEXTURE_2D && index.mipIndex >= 0 &&
index.mipIndex < mTexStorage->getLevelCount());
}
void TextureD3D_2D::markAllImagesDirty()
......@@ -1607,8 +1607,8 @@ ImageD3D *TextureD3D_Cube::getImage(int level, int layer) const
ImageD3D *TextureD3D_Cube::getImage(const gl::ImageIndex &index) const
{
ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(index.layerIndex >= 0 && index.layerIndex < 6);
return mImageArray[index.layerIndex][index.mipIndex].get();
ASSERT(gl::IsCubeMapTextureTarget(index.target));
return mImageArray[index.cubeMapFaceIndex()][index.mipIndex].get();
}
GLsizei TextureD3D_Cube::getLayerCount(int level) const
......@@ -1658,7 +1658,7 @@ gl::Error TextureD3D_Cube::setImage(const gl::Context *context,
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type);
gl::ImageIndex index = gl::ImageIndex::MakeCube(target, static_cast<GLint>(level));
ANGLE_TRY(redefineImage(context, index.layerIndex, static_cast<GLint>(level),
ANGLE_TRY(redefineImage(context, index.cubeMapFaceIndex(), static_cast<GLint>(level),
internalFormatInfo.sizedInternalFormat, size, false));
return setImageImpl(context, index, type, unpack, pixels, 0);
......@@ -2063,11 +2063,11 @@ gl::Error TextureD3D_Cube::getRenderTarget(const gl::Context *context,
const gl::ImageIndex &index,
RenderTargetD3D **outRT)
{
ASSERT(gl::IsCubeMapTextureTarget(index.type));
ASSERT(gl::IsCubeMapTextureTarget(index.target));
// ensure the underlying texture is created
ANGLE_TRY(ensureRenderTarget(context));
ANGLE_TRY(updateStorageFaceLevel(context, index.layerIndex, index.mipIndex));
ANGLE_TRY(updateStorageFaceLevel(context, index.cubeMapFaceIndex(), index.mipIndex));
return mTexStorage->getRenderTarget(context, index, outRT);
}
......@@ -2232,7 +2232,7 @@ bool TextureD3D_Cube::isFaceLevelComplete(int faceIndex, int level) const
bool TextureD3D_Cube::isImageComplete(const gl::ImageIndex &index) const
{
return isFaceLevelComplete(index.layerIndex, index.mipIndex);
return isFaceLevelComplete(index.cubeMapFaceIndex(), index.mipIndex);
}
gl::Error TextureD3D_Cube::updateStorageFaceLevel(const gl::Context *context,
......@@ -2299,8 +2299,9 @@ gl::ImageIndex TextureD3D_Cube::getImageIndex(GLint mip, GLint layer) const
bool TextureD3D_Cube::isValidIndex(const gl::ImageIndex &index) const
{
return (mTexStorage && gl::IsCubeMapTextureTarget(index.type) &&
index.mipIndex >= 0 && index.mipIndex < mTexStorage->getLevelCount());
return (mTexStorage && index.type == GL_TEXTURE_CUBE_MAP &&
gl::IsCubeMapTextureTarget(index.target) && index.mipIndex >= 0 &&
index.mipIndex < mTexStorage->getLevelCount());
}
void TextureD3D_Cube::markAllImagesDirty()
......@@ -2868,8 +2869,8 @@ gl::ImageIndex TextureD3D_3D::getImageIndex(GLint mip, GLint /*layer*/) const
bool TextureD3D_3D::isValidIndex(const gl::ImageIndex &index) const
{
return (mTexStorage && index.type == GL_TEXTURE_3D &&
index.mipIndex >= 0 && index.mipIndex < mTexStorage->getLevelCount());
return (mTexStorage && index.type == GL_TEXTURE_3D && index.mipIndex >= 0 &&
index.mipIndex < mTexStorage->getLevelCount());
}
void TextureD3D_3D::markAllImagesDirty()
......
......@@ -32,9 +32,8 @@ namespace
{
bool ImageIndexConflictsWithSRV(const gl::ImageIndex &index, D3D11_SHADER_RESOURCE_VIEW_DESC desc)
{
unsigned mipLevel = index.mipIndex;
GLint layerIndex = index.layerIndex;
GLenum type = index.type;
unsigned mipLevel = index.mipIndex;
GLenum textureType = index.type;
switch (desc.ViewDimension)
{
......@@ -45,15 +44,17 @@ bool ImageIndexConflictsWithSRV(const gl::ImageIndex &index, D3D11_SHADER_RESOUR
maxSrvMip = allLevels ? INT_MAX : maxSrvMip;
unsigned mipMin = index.mipIndex;
unsigned mipMax = (layerIndex == -1) ? INT_MAX : layerIndex;
unsigned mipMax = INT_MAX;
return type == GL_TEXTURE_2D &&
return textureType == GL_TEXTURE_2D &&
gl::RangeUI(mipMin, mipMax)
.intersects(gl::RangeUI(desc.Texture2D.MostDetailedMip, maxSrvMip));
}
case D3D11_SRV_DIMENSION_TEXTURE2DARRAY:
{
GLint layerIndex = index.layerIndex;
bool allLevels = (desc.Texture2DArray.MipLevels == std::numeric_limits<UINT>::max());
unsigned int maxSrvMip =
desc.Texture2DArray.MipLevels + desc.Texture2DArray.MostDetailedMip;
......@@ -62,7 +63,7 @@ bool ImageIndexConflictsWithSRV(const gl::ImageIndex &index, D3D11_SHADER_RESOUR
unsigned maxSlice = desc.Texture2DArray.FirstArraySlice + desc.Texture2DArray.ArraySize;
// Cube maps can be mapped to Texture2DArray SRVs
return (type == GL_TEXTURE_2D_ARRAY || gl::IsCubeMapTextureTarget(type)) &&
return (textureType == GL_TEXTURE_2D_ARRAY || textureType == GL_TEXTURE_CUBE_MAP) &&
desc.Texture2DArray.MostDetailedMip <= mipLevel && mipLevel < maxSrvMip &&
desc.Texture2DArray.FirstArraySlice <= static_cast<UINT>(layerIndex) &&
static_cast<UINT>(layerIndex) < maxSlice;
......@@ -74,7 +75,7 @@ bool ImageIndexConflictsWithSRV(const gl::ImageIndex &index, D3D11_SHADER_RESOUR
unsigned int maxSrvMip = desc.TextureCube.MipLevels + desc.TextureCube.MostDetailedMip;
maxSrvMip = allLevels ? INT_MAX : maxSrvMip;
return gl::IsCubeMapTextureTarget(type) &&
return textureType == GL_TEXTURE_CUBE_MAP &&
desc.TextureCube.MostDetailedMip <= mipLevel && mipLevel < maxSrvMip;
}
......@@ -84,7 +85,7 @@ bool ImageIndexConflictsWithSRV(const gl::ImageIndex &index, D3D11_SHADER_RESOUR
unsigned int maxSrvMip = desc.Texture3D.MipLevels + desc.Texture3D.MostDetailedMip;
maxSrvMip = allLevels ? INT_MAX : maxSrvMip;
return type == GL_TEXTURE_3D && desc.Texture3D.MostDetailedMip <= mipLevel &&
return textureType == GL_TEXTURE_3D && desc.Texture3D.MostDetailedMip <= mipLevel &&
mipLevel < maxSrvMip;
}
default:
......
......@@ -559,7 +559,7 @@ gl::Error TextureStorage11::updateSubresourceLevel(const gl::Context *context,
// If the zero-LOD workaround is active and we want to update a level greater than zero, then we
// should update the mipmapped texture, even if mapmaps are currently disabled.
if (index.mipIndex > 0 && mRenderer->getWorkarounds().zeroMaxLodWorkaround)
if (level > 0 && mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{
ANGLE_TRY(getMippedResource(context, &dstTexture));
}
......@@ -1046,7 +1046,6 @@ void TextureStorage11_2D::associateImage(Image11 *image, const gl::ImageIndex &i
const GLint level = index.mipIndex;
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
{
mAssociatedImages[level] = image;
......@@ -1191,7 +1190,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::Context *context,
if (mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{
ASSERT(index.mipIndex == 0);
ASSERT(level == 0);
ANGLE_TRY(useLevelZeroWorkaroundTexture(context, true));
}
......@@ -1908,10 +1907,10 @@ TextureStorage11_Cube::~TextureStorage11_Cube()
UINT TextureStorage11_Cube::getSubresourceIndex(const gl::ImageIndex &index) const
{
UINT arraySlice = index.cubeMapFaceIndex();
if (mRenderer->getWorkarounds().zeroMaxLodWorkaround && mUseLevelZeroTexture &&
index.mipIndex == 0)
{
UINT arraySlice = static_cast<UINT>(index.hasLayer() ? index.layerIndex : 0);
UINT subresource = D3D11CalcSubresource(0, arraySlice, 1);
ASSERT(subresource != std::numeric_limits<UINT>::max());
return subresource;
......@@ -1919,7 +1918,6 @@ UINT TextureStorage11_Cube::getSubresourceIndex(const gl::ImageIndex &index) con
else
{
UINT mipSlice = static_cast<UINT>(index.mipIndex + mTopLevel);
UINT arraySlice = static_cast<UINT>(index.hasLayer() ? index.layerIndex : 0);
UINT subresource = D3D11CalcSubresource(mipSlice, arraySlice, mMipLevels);
ASSERT(subresource != std::numeric_limits<UINT>::max());
return subresource;
......@@ -2026,7 +2024,7 @@ gl::Error TextureStorage11_Cube::useLevelZeroWorkaroundTexture(const gl::Context
void TextureStorage11_Cube::associateImage(Image11 *image, const gl::ImageIndex &index)
{
const GLint level = index.mipIndex;
const GLint layerTarget = index.layerIndex;
const GLint layerTarget = index.cubeMapFaceIndex();
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(0 <= layerTarget && layerTarget < static_cast<GLint>(gl::CUBE_FACE_COUNT));
......@@ -2044,7 +2042,7 @@ void TextureStorage11_Cube::verifyAssociatedImageValid(const gl::ImageIndex &ind
Image11 *expectedImage)
{
const GLint level = index.mipIndex;
const GLint layerTarget = index.layerIndex;
const GLint layerTarget = index.cubeMapFaceIndex();
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(0 <= layerTarget && layerTarget < static_cast<GLint>(gl::CUBE_FACE_COUNT));
......@@ -2057,7 +2055,7 @@ void TextureStorage11_Cube::verifyAssociatedImageValid(const gl::ImageIndex &ind
void TextureStorage11_Cube::disassociateImage(const gl::ImageIndex &index, Image11 *expectedImage)
{
const GLint level = index.mipIndex;
const GLint layerTarget = index.layerIndex;
const GLint layerTarget = index.cubeMapFaceIndex();
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(0 <= layerTarget && layerTarget < static_cast<GLint>(gl::CUBE_FACE_COUNT));
......@@ -2072,7 +2070,7 @@ gl::Error TextureStorage11_Cube::releaseAssociatedImage(const gl::Context *conte
Image11 *incomingImage)
{
const GLint level = index.mipIndex;
const GLint layerTarget = index.layerIndex;
const GLint layerTarget = index.cubeMapFaceIndex();
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(0 <= layerTarget && layerTarget < static_cast<GLint>(gl::CUBE_FACE_COUNT));
......@@ -2170,7 +2168,7 @@ gl::Error TextureStorage11_Cube::createRenderTargetSRV(const TextureHelper11 &te
srvDesc.Format = resourceFormat;
srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + index.mipIndex;
srvDesc.Texture2DArray.MipLevels = 1;
srvDesc.Texture2DArray.FirstArraySlice = index.layerIndex;
srvDesc.Texture2DArray.FirstArraySlice = index.cubeMapFaceIndex();
srvDesc.Texture2DArray.ArraySize = 1;
if (mRenderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_10_0)
......@@ -2191,7 +2189,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::Context *context,
const gl::ImageIndex &index,
RenderTargetD3D **outRT)
{
const int faceIndex = index.layerIndex;
const int faceIndex = index.cubeMapFaceIndex();
const int level = index.mipIndex;
ASSERT(level >= 0 && level < getLevelCount());
......
......@@ -461,36 +461,13 @@ gl::Error Image9::copyToStorage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Box &region)
{
gl::Error error = createSurface();
if (error.isError())
{
return error;
}
ANGLE_TRY(createSurface());
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
IDirect3DSurface9 *destSurface = nullptr;
ANGLE_TRY(storage9->getSurfaceLevel(context, index.target, index.mipIndex, true, &destSurface));
if (index.type == GL_TEXTURE_2D)
{
error =
storage9->getSurfaceLevel(context, GL_TEXTURE_2D, index.mipIndex, true, &destSurface);
if (error.isError())
{
return error;
}
}
else
{
ASSERT(gl::IsCubeMapTextureTarget(index.type));
error = storage9->getSurfaceLevel(context, index.type, index.mipIndex, true, &destSurface);
if (error.isError())
{
return error;
}
}
error = copyToSurface(destSurface, region);
gl::Error error = copyToSurface(destSurface, region);
SafeRelease(destSurface);
return error;
}
......
......@@ -10,15 +10,16 @@
#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h"
#include "libANGLE/formatutils.h"
#include "common/utilities.h"
#include "libANGLE/Texture.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/d3d/EGLImageD3D.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/renderer/d3d/d3d9/SwapChain9.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
namespace rx
{
......@@ -515,9 +516,11 @@ gl::Error TextureStorage9_Cube::getRenderTarget(const gl::Context *context,
{
ASSERT(outRT);
ASSERT(index.mipIndex == 0);
ASSERT(index.layerIndex >= 0 && static_cast<size_t>(index.layerIndex) < gl::CUBE_FACE_COUNT);
if (mRenderTarget[index.layerIndex] == nullptr && isRenderTarget())
ASSERT(index.type == GL_TEXTURE_CUBE_MAP && gl::IsCubeMapTextureTarget(index.target));
const size_t renderTargetIndex = index.cubeMapFaceIndex();
if (mRenderTarget[renderTargetIndex] == nullptr && isRenderTarget())
{
IDirect3DBaseTexture9 *baseTexture = nullptr;
gl::Error error = getBaseTexture(context, &baseTexture);
......@@ -527,20 +530,19 @@ gl::Error TextureStorage9_Cube::getRenderTarget(const gl::Context *context,
}
IDirect3DSurface9 *surface = nullptr;
error = getSurfaceLevel(context, GL_TEXTURE_CUBE_MAP_POSITIVE_X + index.layerIndex,
mTopLevel + index.mipIndex, false, &surface);
error = getSurfaceLevel(context, index.target, mTopLevel + index.mipIndex, false, &surface);
if (error.isError())
{
return error;
}
baseTexture->AddRef();
mRenderTarget[index.layerIndex] = new TextureRenderTarget9(
mRenderTarget[renderTargetIndex] = new TextureRenderTarget9(
baseTexture, mTopLevel + index.mipIndex, surface, mInternalFormat,
static_cast<GLsizei>(mTextureWidth), static_cast<GLsizei>(mTextureHeight), 1, 0);
}
*outRT = mRenderTarget[index.layerIndex];
*outRT = mRenderTarget[renderTargetIndex];
return gl::NoError();
}
......@@ -550,14 +552,14 @@ gl::Error TextureStorage9_Cube::generateMipmap(const gl::Context *context,
{
IDirect3DSurface9 *upper = nullptr;
gl::Error error =
getSurfaceLevel(context, sourceIndex.type, sourceIndex.mipIndex, false, &upper);
getSurfaceLevel(context, sourceIndex.target, sourceIndex.mipIndex, false, &upper);
if (error.isError())
{
return error;
}
IDirect3DSurface9 *lower = nullptr;
error = getSurfaceLevel(context, destIndex.type, destIndex.mipIndex, true, &lower);
error = getSurfaceLevel(context, destIndex.target, destIndex.mipIndex, true, &lower);
if (error.isError())
{
SafeRelease(upper);
......
......@@ -114,7 +114,7 @@ bool AreAllLayersActive(const FramebufferAttachment &attachment)
}
const ImageIndex &imageIndex = attachment.getTextureImageIndex();
int numLayers =
static_cast<int>(attachment.getTexture()->getDepth(imageIndex.type, imageIndex.mipIndex));
static_cast<int>(attachment.getTexture()->getDepth(imageIndex.target, imageIndex.mipIndex));
return (attachment.getNumViews() == numLayers);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment