Hash :
95faa233
Author :
Date :
2016-06-07T14:01:53
Do not apply UNPACK_SKIP_IMAGES for 2D textures on D3D Resubmitted with test skip added for Intel OpenGL. GLES 3.0.4 section 3.8.3: "For the purposes of decoding the texture image, TexImage2D is equivalent to calling TexImage3D with corresponding arguments and depth of 1, except that UNPACK_SKIP_IMAGES is ignored." An "applySkipImages" boolean parameter is added to the functions in the D3D backend that apply skip offset to the unpack pointer. In case 2D texture data is uploaded, the parameter is set to false and UNPACK_SKIP_IMAGES is not applied. BUG=angleproject:1406 TEST=angle_end2end_tests Change-Id: I5878439e3d38dbae89cc2452a056c2d6bbf9e0b3 Reviewed-on: https://chromium-review.googlesource.com/351330 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
//
// Copyright 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ImageIndex.cpp: Implementation for ImageIndex methods.
#include "libANGLE/ImageIndex.h"
#include "libANGLE/Constants.h"
#include "common/utilities.h"
namespace gl
{
ImageIndex::ImageIndex(const ImageIndex &other)
: type(other.type),
mipIndex(other.mipIndex),
layerIndex(other.layerIndex)
{}
ImageIndex &ImageIndex::operator=(const ImageIndex &other)
{
type = other.type;
mipIndex = other.mipIndex;
layerIndex = other.layerIndex;
return *this;
}
bool ImageIndex::is3D() const
{
return type == GL_TEXTURE_3D || type == GL_TEXTURE_2D_ARRAY;
}
ImageIndex ImageIndex::Make2D(GLint mipIndex)
{
return ImageIndex(GL_TEXTURE_2D, mipIndex, ENTIRE_LEVEL);
}
ImageIndex ImageIndex::MakeCube(GLenum target, GLint mipIndex)
{
ASSERT(gl::IsCubeMapTextureTarget(target));
return ImageIndex(target, mipIndex,
static_cast<GLint>(CubeMapTextureTargetToLayerIndex(target)));
}
ImageIndex ImageIndex::Make2DArray(GLint mipIndex, GLint layerIndex)
{
return ImageIndex(GL_TEXTURE_2D_ARRAY, mipIndex, layerIndex);
}
ImageIndex ImageIndex::Make3D(GLint mipIndex, GLint layerIndex)
{
return ImageIndex(GL_TEXTURE_3D, mipIndex, layerIndex);
}
ImageIndex ImageIndex::MakeGeneric(GLenum target, GLint mipIndex)
{
GLint layerIndex = IsCubeMapTextureTarget(target)
? static_cast<GLint>(CubeMapTextureTargetToLayerIndex(target))
: ENTIRE_LEVEL;
return ImageIndex(target, mipIndex, layerIndex);
}
ImageIndex ImageIndex::MakeInvalid()
{
return ImageIndex(GL_NONE, -1, -1);
}
bool ImageIndex::operator<(const ImageIndex &other) const
{
if (type != other.type)
{
return type < other.type;
}
else if (mipIndex != other.mipIndex)
{
return mipIndex < other.mipIndex;
}
else
{
return layerIndex < other.layerIndex;
}
}
bool ImageIndex::operator==(const ImageIndex &other) const
{
return (type == other.type) && (mipIndex == other.mipIndex) && (layerIndex == other.layerIndex);
}
bool ImageIndex::operator!=(const ImageIndex &other) const
{
return !(*this == other);
}
ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn)
: type(typeIn),
mipIndex(mipIndexIn),
layerIndex(layerIndexIn)
{}
ImageIndexIterator ImageIndexIterator::Make2D(GLint minMip, GLint maxMip)
{
return ImageIndexIterator(GL_TEXTURE_2D, Range<GLint>(minMip, maxMip),
Range<GLint>(ImageIndex::ENTIRE_LEVEL, ImageIndex::ENTIRE_LEVEL), NULL);
}
ImageIndexIterator ImageIndexIterator::MakeCube(GLint minMip, GLint maxMip)
{
return ImageIndexIterator(GL_TEXTURE_CUBE_MAP, Range<GLint>(minMip, maxMip), Range<GLint>(0, 6), NULL);
}
ImageIndexIterator ImageIndexIterator::Make3D(GLint minMip, GLint maxMip,
GLint minLayer, GLint maxLayer)
{
return ImageIndexIterator(GL_TEXTURE_3D, Range<GLint>(minMip, maxMip), Range<GLint>(minLayer, maxLayer), NULL);
}
ImageIndexIterator ImageIndexIterator::Make2DArray(GLint minMip, GLint maxMip,
const GLsizei *layerCounts)
{
return ImageIndexIterator(GL_TEXTURE_2D_ARRAY, Range<GLint>(minMip, maxMip),
Range<GLint>(0, IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS), layerCounts);
}
ImageIndexIterator::ImageIndexIterator(GLenum type, const Range<GLint> &mipRange,
const Range<GLint> &layerRange, const GLsizei *layerCounts)
: mType(type),
mMipRange(mipRange),
mLayerRange(layerRange),
mLayerCounts(layerCounts),
mCurrentMip(mipRange.start),
mCurrentLayer(layerRange.start)
{}
GLint ImageIndexIterator::maxLayer() const
{
return (mLayerCounts ? static_cast<GLint>(mLayerCounts[mCurrentMip]) : mLayerRange.end);
}
ImageIndex ImageIndexIterator::next()
{
ASSERT(hasNext());
ImageIndex value = current();
// Iterate layers in the inner loop for now. We can add switchable
// layer or mip iteration if we need it.
if (mCurrentLayer != ImageIndex::ENTIRE_LEVEL)
{
if (mCurrentLayer < maxLayer()-1)
{
mCurrentLayer++;
}
else if (mCurrentMip < mMipRange.end-1)
{
mCurrentMip++;
mCurrentLayer = mLayerRange.start;
}
}
else if (mCurrentMip < mMipRange.end-1)
{
mCurrentMip++;
mCurrentLayer = mLayerRange.start;
}
return value;
}
ImageIndex ImageIndexIterator::current() const
{
ImageIndex value(mType, mCurrentMip, mCurrentLayer);
if (mType == GL_TEXTURE_CUBE_MAP)
{
value.type = LayerIndexToCubeMapTextureTarget(mCurrentLayer);
}
return value;
}
bool ImageIndexIterator::hasNext() const
{
return (mCurrentMip < mMipRange.end || mCurrentLayer < maxLayer());
}
}