Commit e4634a13 by Jamie Madill Committed by Commit Bot

Apply code formatting.

Several files were formatted by the code generation script. Bug: angleproject:2957 Change-Id: I8a5cbf2c17297a3644686004a8981ab2305c1ada Reviewed-on: https://chromium-review.googlesource.com/c/1334428Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent b56ddbb7
...@@ -173,7 +173,6 @@ class TextureImpl : public FramebufferAttachmentObjectImpl ...@@ -173,7 +173,6 @@ class TextureImpl : public FramebufferAttachmentObjectImpl
protected: protected:
const gl::TextureState &mState; const gl::TextureState &mState;
}; };
} }
#endif // LIBANGLE_RENDERER_TEXTUREIMPL_H_ #endif // LIBANGLE_RENDERER_TEXTUREIMPL_H_
...@@ -126,7 +126,6 @@ class MockTextureImpl : public TextureImpl ...@@ -126,7 +126,6 @@ class MockTextureImpl : public TextureImpl
protected: protected:
gl::TextureState mMockState; gl::TextureState mMockState;
}; };
} }
#endif // LIBANGLE_RENDERER_TEXTUREIMPLMOCK_H_ #endif // LIBANGLE_RENDERER_TEXTUREIMPLMOCK_H_
...@@ -304,7 +304,8 @@ bool FramebufferD3D::checkStatus(const gl::Context *context) const ...@@ -304,7 +304,8 @@ bool FramebufferD3D::checkStatus(const gl::Context *context) const
// D3D11 does not allow for overlapping RenderTargetViews. // D3D11 does not allow for overlapping RenderTargetViews.
// If WebGL compatibility is enabled, this has already been checked at a higher level. // If WebGL compatibility is enabled, this has already been checked at a higher level.
ASSERT(!context->getExtensions().webglCompatibility || mState.colorAttachmentsAreUniqueImages()); ASSERT(!context->getExtensions().webglCompatibility ||
mState.colorAttachmentsAreUniqueImages());
if (!context->getExtensions().webglCompatibility) if (!context->getExtensions().webglCompatibility)
{ {
if (!mState.colorAttachmentsAreUniqueImages()) if (!mState.colorAttachmentsAreUniqueImages())
......
...@@ -42,11 +42,13 @@ angle::Result GetUnpackPointer(const gl::Context *context, ...@@ -42,11 +42,13 @@ angle::Result GetUnpackPointer(const gl::Context *context,
{ {
if (unpackBuffer) if (unpackBuffer)
{ {
// Do a CPU readback here, if we have an unpack buffer bound and the fast GPU path is not supported // Do a CPU readback here, if we have an unpack buffer bound and the fast GPU path is not
// supported
ptrdiff_t offset = reinterpret_cast<ptrdiff_t>(pixels); ptrdiff_t offset = reinterpret_cast<ptrdiff_t>(pixels);
// TODO: this is the only place outside of renderer that asks for a buffers raw data. // TODO: this is the only place outside of renderer that asks for a buffers raw data.
// This functionality should be moved into renderer and the getData method of BufferImpl removed. // This functionality should be moved into renderer and the getData method of BufferImpl
// removed.
BufferD3D *bufferD3D = GetImplAs<BufferD3D>(unpackBuffer); BufferD3D *bufferD3D = GetImplAs<BufferD3D>(unpackBuffer);
ASSERT(bufferD3D); ASSERT(bufferD3D);
const uint8_t *bufferData = nullptr; const uint8_t *bufferData = nullptr;
...@@ -71,7 +73,6 @@ bool IsRenderTargetUsage(GLenum usage) ...@@ -71,7 +73,6 @@ bool IsRenderTargetUsage(GLenum usage)
{ {
return (usage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE); return (usage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
} }
} }
TextureD3D::TextureD3D(const gl::TextureState &state, RendererD3D *renderer) TextureD3D::TextureD3D(const gl::TextureState &state, RendererD3D *renderer)
...@@ -227,8 +228,9 @@ angle::Result TextureD3D::setImageImpl(const gl::Context *context, ...@@ -227,8 +228,9 @@ angle::Result TextureD3D::setImageImpl(const gl::Context *context,
return angle::Result::Continue(); return angle::Result::Continue();
} }
// We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains. // We no longer need the "GLenum format" parameter to TexImage to determine what data format
// From our image internal format we know how many channels to expect, and "type" gives the format of pixel's components. // "pixels" contains. From our image internal format we know how many channels to expect, and
// "type" gives the format of pixel's components.
const uint8_t *pixelData = nullptr; const uint8_t *pixelData = nullptr;
ANGLE_TRY(GetUnpackPointer(context, unpack, unpackBuffer, pixels, layerOffset, &pixelData)); ANGLE_TRY(GetUnpackPointer(context, unpack, unpackBuffer, pixels, layerOffset, &pixelData));
...@@ -241,7 +243,8 @@ angle::Result TextureD3D::setImageImpl(const gl::Context *context, ...@@ -241,7 +243,8 @@ angle::Result TextureD3D::setImageImpl(const gl::Context *context,
} }
else else
{ {
gl::Box fullImageArea(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth()); gl::Box fullImageArea(0, 0, 0, image->getWidth(), image->getHeight(),
image->getDepth());
ANGLE_TRY(image->loadData(context, fullImageArea, unpack, type, pixelData, ANGLE_TRY(image->loadData(context, fullImageArea, unpack, type, pixelData,
index.usesTex3D())); index.usesTex3D()));
} }
...@@ -298,8 +301,9 @@ angle::Result TextureD3D::setCompressedImageImpl(const gl::Context *context, ...@@ -298,8 +301,9 @@ angle::Result TextureD3D::setCompressedImageImpl(const gl::Context *context,
return angle::Result::Continue(); return angle::Result::Continue();
} }
// We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains. // We no longer need the "GLenum format" parameter to TexImage to determine what data format
// From our image internal format we know how many channels to expect, and "type" gives the format of pixel's components. // "pixels" contains. From our image internal format we know how many channels to expect, and
// "type" gives the format of pixel's components.
const uint8_t *pixelData = nullptr; const uint8_t *pixelData = nullptr;
gl::Buffer *unpackBuffer = gl::Buffer *unpackBuffer =
context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack); context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack);
...@@ -367,8 +371,8 @@ angle::Result TextureD3D::fastUnpackPixels(const gl::Context *context, ...@@ -367,8 +371,8 @@ angle::Result TextureD3D::fastUnpackPixels(const gl::Context *context,
return angle::Result::Continue(); return angle::Result::Continue();
} }
// In order to perform the fast copy through the shader, we must have the right format, and be able // In order to perform the fast copy through the shader, we must have the right format, and be
// to create a render target. // able to create a render target.
ASSERT(mRenderer->supportsFastCopyBufferToTexture(sizedInternalFormat)); ASSERT(mRenderer->supportsFastCopyBufferToTexture(sizedInternalFormat));
uintptr_t offset = reinterpret_cast<uintptr_t>(pixels); uintptr_t offset = reinterpret_cast<uintptr_t>(pixels);
...@@ -481,12 +485,15 @@ angle::Result TextureD3D::generateMipmapUsingImages(const gl::Context *context, ...@@ -481,12 +485,15 @@ angle::Result TextureD3D::generateMipmapUsingImages(const gl::Context *context,
} }
} }
// TODO: Decouple this from zeroMaxLodWorkaround. This is a 9_3 restriction, unrelated to zeroMaxLodWorkaround. // TODO: Decouple this from zeroMaxLodWorkaround. This is a 9_3 restriction, unrelated to
// The restriction is because Feature Level 9_3 can't create SRVs on individual levels of the texture. // zeroMaxLodWorkaround. The restriction is because Feature Level 9_3 can't create SRVs on
// As a result, even if the storage is a rendertarget, we can't use the GPU to generate the mipmaps without further work. // individual levels of the texture. As a result, even if the storage is a rendertarget, we
// The D3D9 renderer works around this by copying each level of the texture into its own single-layer GPU texture (in Blit9::boxFilter). // can't use the GPU to generate the mipmaps without further work. The D3D9 renderer works
// Feature Level 9_3 could do something similar, or it could continue to use CPU-side mipmap generation, or something else. // around this by copying each level of the texture into its own single-layer GPU texture (in
bool renderableStorage = (mTexStorage && mTexStorage->isRenderTarget() && !(mRenderer->getWorkarounds().zeroMaxLodWorkaround)); // Blit9::boxFilter). Feature Level 9_3 could do something similar, or it could continue to use
// CPU-side mipmap generation, or something else.
bool renderableStorage = (mTexStorage && mTexStorage->isRenderTarget() &&
!(mRenderer->getWorkarounds().zeroMaxLodWorkaround));
for (GLint layer = 0; layer < layerCount; ++layer) for (GLint layer = 0; layer < layerCount; ++layer)
{ {
...@@ -929,7 +936,8 @@ angle::Result TextureD3D_2D::setCompressedImage(const gl::Context *context, ...@@ -929,7 +936,8 @@ angle::Result TextureD3D_2D::setCompressedImage(const gl::Context *context,
{ {
ASSERT(index.getTarget() == gl::TextureTarget::_2D && size.depth == 1); ASSERT(index.getTarget() == gl::TextureTarget::_2D && size.depth == 1);
// compressed formats don't have separate sized internal formats-- we can just use the compressed format directly // compressed formats don't have separate sized internal formats-- we can just use the
// compressed format directly
ANGLE_TRY(redefineImage(context, index.getLevelIndex(), internalFormat, size, false)); ANGLE_TRY(redefineImage(context, index.getLevelIndex(), internalFormat, size, false));
return setCompressedImageImpl(context, index, unpack, pixels, 0); return setCompressedImageImpl(context, index, unpack, pixels, 0);
...@@ -988,8 +996,8 @@ angle::Result TextureD3D_2D::copyImage(const gl::Context *context, ...@@ -988,8 +996,8 @@ angle::Result TextureD3D_2D::copyImage(const gl::Context *context,
gl::Offset destOffset(clippedArea.x - sourceArea.x, clippedArea.y - sourceArea.y, 0); gl::Offset destOffset(clippedArea.x - sourceArea.x, clippedArea.y - sourceArea.y, 0);
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders, // If the zero max LOD workaround is active, then we can't sample from individual layers of the
// so we should use the non-rendering copy path. // framebuffer in shaders, so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround) if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{ {
ANGLE_TRY(mImageArray[index.getLevelIndex()]->copyFromFramebuffer(context, destOffset, ANGLE_TRY(mImageArray[index.getLevelIndex()]->copyFromFramebuffer(context, destOffset,
...@@ -1029,11 +1037,12 @@ angle::Result TextureD3D_2D::copySubImage(const gl::Context *context, ...@@ -1029,11 +1037,12 @@ angle::Result TextureD3D_2D::copySubImage(const gl::Context *context,
const gl::Offset clippedOffset(destOffset.x + clippedArea.x - sourceArea.x, const gl::Offset clippedOffset(destOffset.x + clippedArea.x - sourceArea.x,
destOffset.y + clippedArea.y - sourceArea.y, 0); destOffset.y + clippedArea.y - sourceArea.y, 0);
// can only make our texture storage to a render target if level 0 is defined (with a width & height) and // can only make our texture storage to a render target if level 0 is defined (with a width &
// the current level we're copying to is defined (with appropriate format, width & height) // height) and the current level we're copying to is defined (with appropriate format, width &
// height)
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders, // If the zero max LOD workaround is active, then we can't sample from individual layers of the
// so we should use the non-rendering copy path. // framebuffer in shaders, so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround) if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{ {
ANGLE_TRY(mImageArray[index.getLevelIndex()]->copyFromFramebuffer(context, clippedOffset, ANGLE_TRY(mImageArray[index.getLevelIndex()]->copyFromFramebuffer(context, clippedOffset,
...@@ -1196,8 +1205,7 @@ angle::Result TextureD3D_2D::setStorage(const gl::Context *context, ...@@ -1196,8 +1205,7 @@ angle::Result TextureD3D_2D::setStorage(const gl::Context *context,
for (size_t level = 0; level < levels; level++) for (size_t level = 0; level < levels; level++)
{ {
gl::Extents levelSize(std::max(1, size.width >> level), gl::Extents levelSize(std::max(1, size.width >> level), std::max(1, size.height >> level),
std::max(1, size.height >> level),
1); 1);
ANGLE_TRY(redefineImage(context, level, internalFormat, levelSize, true)); ANGLE_TRY(redefineImage(context, level, internalFormat, levelSize, true));
} }
...@@ -1417,8 +1425,8 @@ angle::Result TextureD3D_2D::createCompleteStorage(bool renderTarget, ...@@ -1417,8 +1425,8 @@ angle::Result TextureD3D_2D::createCompleteStorage(bool renderTarget,
bool hintLevelZeroOnly = false; bool hintLevelZeroOnly = false;
if (mRenderer->getWorkarounds().zeroMaxLodWorkaround) if (mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{ {
// If any of the CPU images (levels >= 1) are dirty, then the textureStorage2D should use the mipped texture to begin with. // If any of the CPU images (levels >= 1) are dirty, then the textureStorage2D should use
// Otherwise, it should use the level-zero-only texture. // the mipped texture to begin with. Otherwise, it should use the level-zero-only texture.
hintLevelZeroOnly = true; hintLevelZeroOnly = true;
for (int level = 1; level < levels && hintLevelZeroOnly; level++) for (int level = 1; level < levels && hintLevelZeroOnly; level++)
{ {
...@@ -1677,7 +1685,8 @@ angle::Result TextureD3D_Cube::setCompressedImage(const gl::Context *context, ...@@ -1677,7 +1685,8 @@ angle::Result TextureD3D_Cube::setCompressedImage(const gl::Context *context,
{ {
ASSERT(size.depth == 1); ASSERT(size.depth == 1);
// compressed formats don't have separate sized internal formats-- we can just use the compressed format directly // compressed formats don't have separate sized internal formats-- we can just use the
// compressed format directly
ANGLE_TRY(redefineImage(context, index.cubeMapFaceIndex(), index.getLevelIndex(), ANGLE_TRY(redefineImage(context, index.cubeMapFaceIndex(), index.getLevelIndex(),
internalFormat, size, false)); internalFormat, size, false));
...@@ -1737,8 +1746,8 @@ angle::Result TextureD3D_Cube::copyImage(const gl::Context *context, ...@@ -1737,8 +1746,8 @@ angle::Result TextureD3D_Cube::copyImage(const gl::Context *context,
gl::Offset destOffset(clippedArea.x - sourceArea.x, clippedArea.y - sourceArea.y, 0); gl::Offset destOffset(clippedArea.x - sourceArea.x, clippedArea.y - sourceArea.y, 0);
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders, // If the zero max LOD workaround is active, then we can't sample from individual layers of the
// so we should use the non-rendering copy path. // framebuffer in shaders, so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround) if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{ {
ANGLE_TRY(mImageArray[faceIndex][index.getLevelIndex()]->copyFromFramebuffer( ANGLE_TRY(mImageArray[faceIndex][index.getLevelIndex()]->copyFromFramebuffer(
...@@ -1780,8 +1789,8 @@ angle::Result TextureD3D_Cube::copySubImage(const gl::Context *context, ...@@ -1780,8 +1789,8 @@ angle::Result TextureD3D_Cube::copySubImage(const gl::Context *context,
GLint faceIndex = index.cubeMapFaceIndex(); GLint faceIndex = index.cubeMapFaceIndex();
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders, // If the zero max LOD workaround is active, then we can't sample from individual layers of the
// so we should use the non-rendering copy path. // framebuffer in shaders, so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround) if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{ {
ANGLE_TRY(mImageArray[faceIndex][index.getLevelIndex()]->copyFromFramebuffer( ANGLE_TRY(mImageArray[faceIndex][index.getLevelIndex()]->copyFromFramebuffer(
...@@ -1974,9 +1983,8 @@ bool TextureD3D_Cube::isCubeComplete() const ...@@ -1974,9 +1983,8 @@ bool TextureD3D_Cube::isCubeComplete() const
{ {
const ImageD3D &faceBaseImage = *mImageArray[faceIndex][getBaseLevel()]; const ImageD3D &faceBaseImage = *mImageArray[faceIndex][getBaseLevel()];
if (faceBaseImage.getWidth() != baseWidth || if (faceBaseImage.getWidth() != baseWidth || faceBaseImage.getHeight() != baseHeight ||
faceBaseImage.getHeight() != baseHeight || faceBaseImage.getInternalFormat() != baseFormat)
faceBaseImage.getInternalFormat() != baseFormat )
{ {
return false; return false;
} }
...@@ -2073,14 +2081,15 @@ angle::Result TextureD3D_Cube::createCompleteStorage(bool renderTarget, ...@@ -2073,14 +2081,15 @@ angle::Result TextureD3D_Cube::createCompleteStorage(bool renderTarget,
bool hintLevelZeroOnly = false; bool hintLevelZeroOnly = false;
if (mRenderer->getWorkarounds().zeroMaxLodWorkaround) if (mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{ {
// If any of the CPU images (levels >= 1) are dirty, then the textureStorage should use the mipped texture to begin with. // If any of the CPU images (levels >= 1) are dirty, then the textureStorage should use the
// Otherwise, it should use the level-zero-only texture. // mipped texture to begin with. Otherwise, it should use the level-zero-only texture.
hintLevelZeroOnly = true; hintLevelZeroOnly = true;
for (size_t faceIndex = 0; faceIndex < gl::kCubeFaceCount && hintLevelZeroOnly; faceIndex++) for (size_t faceIndex = 0; faceIndex < gl::kCubeFaceCount && hintLevelZeroOnly; faceIndex++)
{ {
for (int level = 1; level < levels && hintLevelZeroOnly; level++) for (int level = 1; level < levels && hintLevelZeroOnly; level++)
{ {
hintLevelZeroOnly = !(mImageArray[faceIndex][level]->isDirty() && isFaceLevelComplete(faceIndex, level)); hintLevelZeroOnly = !(mImageArray[faceIndex][level]->isDirty() &&
isFaceLevelComplete(faceIndex, level));
} }
} }
} }
...@@ -2457,7 +2466,8 @@ angle::Result TextureD3D_3D::setCompressedImage(const gl::Context *context, ...@@ -2457,7 +2466,8 @@ angle::Result TextureD3D_3D::setCompressedImage(const gl::Context *context,
{ {
ASSERT(index.getTarget() == gl::TextureTarget::_3D); ASSERT(index.getTarget() == gl::TextureTarget::_3D);
// compressed formats don't have separate sized internal formats-- we can just use the compressed format directly // compressed formats don't have separate sized internal formats-- we can just use the
// compressed format directly
ANGLE_TRY(redefineImage(context, index.getLevelIndex(), internalFormat, size, false)); ANGLE_TRY(redefineImage(context, index.getLevelIndex(), internalFormat, size, false));
return setCompressedImageImpl(context, index, unpack, pixels, 0); return setCompressedImageImpl(context, index, unpack, pixels, 0);
...@@ -2650,8 +2660,7 @@ angle::Result TextureD3D_3D::setStorage(const gl::Context *context, ...@@ -2650,8 +2660,7 @@ angle::Result TextureD3D_3D::setStorage(const gl::Context *context,
for (size_t level = 0; level < levels; level++) for (size_t level = 0; level < levels; level++)
{ {
gl::Extents levelSize(std::max(1, size.width >> level), gl::Extents levelSize(std::max(1, size.width >> level), std::max(1, size.height >> level),
std::max(1, size.height >> level),
std::max(1, size.depth >> level)); std::max(1, size.depth >> level));
mImageArray[level]->redefine(gl::TextureType::_3D, internalFormat, levelSize, true); mImageArray[level]->redefine(gl::TextureType::_3D, internalFormat, levelSize, true);
} }
...@@ -2767,7 +2776,8 @@ angle::Result TextureD3D_3D::createCompleteStorage(bool renderTarget, ...@@ -2767,7 +2776,8 @@ angle::Result TextureD3D_3D::createCompleteStorage(bool renderTarget,
ASSERT(width > 0 && height > 0 && depth > 0); ASSERT(width > 0 && height > 0 && depth > 0);
// use existing storage level count, when previously specified by TexStorage*D // use existing storage level count, when previously specified by TexStorage*D
GLint levels = (mTexStorage ? mTexStorage->getLevelCount() : creationLevels(width, height, depth)); GLint levels =
(mTexStorage ? mTexStorage->getLevelCount() : creationLevels(width, height, depth));
// TODO: Verify creation of the storage succeeded // TODO: Verify creation of the storage succeeded
outStorage->reset(mRenderer->createTextureStorage3D(internalFormat, renderTarget, width, height, outStorage->reset(mRenderer->createTextureStorage3D(internalFormat, renderTarget, width, height,
...@@ -2976,8 +2986,7 @@ TextureD3D_2DArray::~TextureD3D_2DArray() ...@@ -2976,8 +2986,7 @@ TextureD3D_2DArray::~TextureD3D_2DArray()
ImageD3D *TextureD3D_2DArray::getImage(int level, int layer) const ImageD3D *TextureD3D_2DArray::getImage(int level, int layer) const
{ {
ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT((layer == 0 && mLayerCounts[level] == 0) || ASSERT((layer == 0 && mLayerCounts[level] == 0) || layer < mLayerCounts[level]);
layer < mLayerCounts[level]);
return (mImageArray[level] ? mImageArray[level][layer] : nullptr); return (mImageArray[level] ? mImageArray[level][layer] : nullptr);
} }
...@@ -3001,17 +3010,23 @@ GLsizei TextureD3D_2DArray::getLayerCount(int level) const ...@@ -3001,17 +3010,23 @@ GLsizei TextureD3D_2DArray::getLayerCount(int level) const
GLsizei TextureD3D_2DArray::getWidth(GLint level) const GLsizei TextureD3D_2DArray::getWidth(GLint level) const
{ {
return (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS && mLayerCounts[level] > 0) ? mImageArray[level][0]->getWidth() : 0; return (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS && mLayerCounts[level] > 0)
? mImageArray[level][0]->getWidth()
: 0;
} }
GLsizei TextureD3D_2DArray::getHeight(GLint level) const GLsizei TextureD3D_2DArray::getHeight(GLint level) const
{ {
return (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS && mLayerCounts[level] > 0) ? mImageArray[level][0]->getHeight() : 0; return (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS && mLayerCounts[level] > 0)
? mImageArray[level][0]->getHeight()
: 0;
} }
GLenum TextureD3D_2DArray::getInternalFormat(GLint level) const GLenum TextureD3D_2DArray::getInternalFormat(GLint level) const
{ {
return (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS && mLayerCounts[level] > 0) ? mImageArray[level][0]->getInternalFormat() : GL_NONE; return (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS && mLayerCounts[level] > 0)
? mImageArray[level][0]->getInternalFormat()
: GL_NONE;
} }
bool TextureD3D_2DArray::isDepth(GLint level) const bool TextureD3D_2DArray::isDepth(GLint level) const
...@@ -3111,7 +3126,8 @@ angle::Result TextureD3D_2DArray::setCompressedImage(const gl::Context *context, ...@@ -3111,7 +3126,8 @@ angle::Result TextureD3D_2DArray::setCompressedImage(const gl::Context *context,
ContextD3D *contextD3D = GetImplAs<ContextD3D>(context); ContextD3D *contextD3D = GetImplAs<ContextD3D>(context);
// compressed formats don't have separate sized internal formats-- we can just use the compressed format directly // compressed formats don't have separate sized internal formats-- we can just use the
// compressed format directly
ANGLE_TRY(redefineImage(context, index.getLevelIndex(), internalFormat, size, false)); ANGLE_TRY(redefineImage(context, index.getLevelIndex(), internalFormat, size, false));
const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalFormat); const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalFormat);
...@@ -3367,15 +3383,14 @@ angle::Result TextureD3D_2DArray::setStorage(const gl::Context *context, ...@@ -3367,15 +3383,14 @@ angle::Result TextureD3D_2DArray::setStorage(const gl::Context *context,
for (size_t level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++) for (size_t level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
{ {
gl::Extents levelLayerSize(std::max(1, size.width >> level), gl::Extents levelLayerSize(std::max(1, size.width >> level),
std::max(1, size.height >> level), std::max(1, size.height >> level), 1);
1);
mLayerCounts[level] = (level < levels ? size.depth : 0); mLayerCounts[level] = (level < levels ? size.depth : 0);
if (mLayerCounts[level] > 0) if (mLayerCounts[level] > 0)
{ {
// Create new images for this level // Create new images for this level
mImageArray[level] = new ImageD3D*[mLayerCounts[level]]; mImageArray[level] = new ImageD3D *[mLayerCounts[level]];
for (int layer = 0; layer < mLayerCounts[level]; layer++) for (int layer = 0; layer < mLayerCounts[level]; layer++)
{ {
...@@ -3430,8 +3445,7 @@ angle::Result TextureD3D_2DArray::initMipmapImages(const gl::Context *context) ...@@ -3430,8 +3445,7 @@ angle::Result TextureD3D_2DArray::initMipmapImages(const gl::Context *context)
{ {
ASSERT((baseWidth >> level) > 0 || (baseHeight >> level) > 0); ASSERT((baseWidth >> level) > 0 || (baseHeight >> level) > 0);
gl::Extents levelLayerSize(std::max(baseWidth >> level, 1), gl::Extents levelLayerSize(std::max(baseWidth >> level, 1),
std::max(baseHeight >> level, 1), std::max(baseHeight >> level, 1), baseDepth);
baseDepth);
ANGLE_TRY(redefineImage(context, level, baseFormat, levelLayerSize, false)); ANGLE_TRY(redefineImage(context, level, baseFormat, levelLayerSize, false));
} }
...@@ -3659,7 +3673,7 @@ angle::Result TextureD3D_2DArray::redefineImage(const gl::Context *context, ...@@ -3659,7 +3673,7 @@ angle::Result TextureD3D_2DArray::redefineImage(const gl::Context *context,
if (size.depth > 0) if (size.depth > 0)
{ {
mImageArray[level] = new ImageD3D*[size.depth]; mImageArray[level] = new ImageD3D *[size.depth];
for (int layer = 0; layer < mLayerCounts[level]; layer++) for (int layer = 0; layer < mLayerCounts[level]; layer++)
{ {
mImageArray[level][layer] = mRenderer->createImage(); mImageArray[level][layer] = mRenderer->createImage();
......
...@@ -703,8 +703,9 @@ class TextureD3D_2DArray : public TextureD3D ...@@ -703,8 +703,9 @@ class TextureD3D_2DArray : public TextureD3D
// Storing images as an array of single depth textures since D3D11 treats each array level of a // Storing images as an array of single depth textures since D3D11 treats each array level of a
// Texture2D object as a separate subresource. Each layer would have to be looped over // Texture2D object as a separate subresource. Each layer would have to be looped over
// to update all the texture layers since they cannot all be updated at once and it makes the most // to update all the texture layers since they cannot all be updated at once and it makes the
// sense for the Image class to not have to worry about layer subresource as well as mip subresources. // most sense for the Image class to not have to worry about layer subresource as well as mip
// subresources.
GLsizei mLayerCounts[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; GLsizei mLayerCounts[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
ImageD3D **mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; ImageD3D **mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
}; };
......
...@@ -22,14 +22,14 @@ ...@@ -22,14 +22,14 @@
namespace namespace
{ {
// Precompiled shaders // Precompiled shaders
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/standardvs.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/passthroughps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/luminanceps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/luminancepremultps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/luminanceunmultps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/componentmaskps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/componentmaskpremultps.h" #include "libANGLE/renderer/d3d/d3d9/shaders/compiled/componentmaskpremultps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/componentmaskps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/componentmaskunmultps.h" #include "libANGLE/renderer/d3d/d3d9/shaders/compiled/componentmaskunmultps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/luminancepremultps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/luminanceps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/luminanceunmultps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/passthroughps.h"
#include "libANGLE/renderer/d3d/d3d9/shaders/compiled/standardvs.h"
const BYTE *const g_shaderCode[] = { const BYTE *const g_shaderCode[] = {
g_vs20_standardvs, g_vs20_standardvs,
...@@ -88,13 +88,7 @@ angle::Result Blit9::initialize(Context9 *context9) ...@@ -88,13 +88,7 @@ angle::Result Blit9::initialize(Context9 *context9)
return angle::Result::Continue(); return angle::Result::Continue();
} }
static const float quad[] = static const float quad[] = {-1, -1, -1, 1, 1, -1, 1, 1};
{
-1, -1,
-1, 1,
1, -1,
1, 1
};
IDirect3DDevice9 *device = mRenderer->getDevice(); IDirect3DDevice9 *device = mRenderer->getDevice();
...@@ -112,11 +106,8 @@ angle::Result Blit9::initialize(Context9 *context9) ...@@ -112,11 +106,8 @@ angle::Result Blit9::initialize(Context9 *context9)
memcpy(lockPtr, quad, sizeof(quad)); memcpy(lockPtr, quad, sizeof(quad));
mQuadVertexBuffer->Unlock(); mQuadVertexBuffer->Unlock();
static const D3DVERTEXELEMENT9 elements[] = static const D3DVERTEXELEMENT9 elements[] = {
{ {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, D3DDECL_END()};
{ 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
D3DDECL_END()
};
result = device->CreateVertexDeclaration(elements, &mQuadVertexDeclaration); result = device->CreateVertexDeclaration(elements, &mQuadVertexDeclaration);
ANGLE_TRY_HR(context9, result, "Failed to create internal blit vertex shader declaration"); ANGLE_TRY_HR(context9, result, "Failed to create internal blit vertex shader declaration");
...@@ -141,11 +132,11 @@ angle::Result Blit9::setShader(Context9 *context9, ...@@ -141,11 +132,11 @@ angle::Result Blit9::setShader(Context9 *context9,
if (mCompiledShaders[source] != nullptr) if (mCompiledShaders[source] != nullptr)
{ {
shader = static_cast<D3DShaderType*>(mCompiledShaders[source]); shader = static_cast<D3DShaderType *>(mCompiledShaders[source]);
} }
else else
{ {
const BYTE* shaderCode = g_shaderCode[source]; const BYTE *shaderCode = g_shaderCode[source];
size_t shaderSize = g_shaderSize[source]; size_t shaderSize = g_shaderSize[source];
ANGLE_TRY((mRenderer->*createShader)(context9, reinterpret_cast<const DWORD *>(shaderCode), ANGLE_TRY((mRenderer->*createShader)(context9, reinterpret_cast<const DWORD *>(shaderCode),
shaderSize, &shader)); shaderSize, &shader));
...@@ -358,7 +349,9 @@ angle::Result Blit9::copy(Context9 *context9, ...@@ -358,7 +349,9 @@ angle::Result Blit9::copy(Context9 *context9,
d3d9_gl::IsFormatChannelEquivalent(destDesc.Format, destFormat) && !flipY && d3d9_gl::IsFormatChannelEquivalent(destDesc.Format, destFormat) && !flipY &&
premultiplyAlpha == unmultiplyAlpha) premultiplyAlpha == unmultiplyAlpha)
{ {
RECT destRect = { destOffset.x, destOffset.y, destOffset.x + (sourceRect.right - sourceRect.left), destOffset.y + (sourceRect.bottom - sourceRect.top)}; RECT destRect = {destOffset.x, destOffset.y,
destOffset.x + (sourceRect.right - sourceRect.left),
destOffset.y + (sourceRect.bottom - sourceRect.top)};
HRESULT result = device->StretchRect(source, &sourceRect, dest, &destRect, D3DTEXF_POINT); HRESULT result = device->StretchRect(source, &sourceRect, dest, &destRect, D3DTEXF_POINT);
ANGLE_TRY_HR(context9, result, "StretchRect failed to blit between textures"); ANGLE_TRY_HR(context9, result, "StretchRect failed to blit between textures");
return angle::Result::Continue(); return angle::Result::Continue();
...@@ -482,12 +475,18 @@ angle::Result Blit9::setFormatConvertShaders(Context9 *context9, ...@@ -482,12 +475,18 @@ angle::Result Blit9::setFormatConvertShaders(Context9 *context9,
UNREACHABLE(); UNREACHABLE();
} }
enum { X = 0, Y = 1, Z = 2, W = 3 }; enum
{
X = 0,
Y = 1,
Z = 2,
W = 3
};
// The meaning of this constant depends on the shader that was selected. // The meaning of this constant depends on the shader that was selected.
// See the shader assembly code above for details. // See the shader assembly code above for details.
// Allocate one array for both registers and split it into two float4's. // Allocate one array for both registers and split it into two float4's.
float psConst[8] = { 0 }; float psConst[8] = {0};
float *multConst = &psConst[0]; float *multConst = &psConst[0];
float *addConst = &psConst[4]; float *addConst = &psConst[4];
...@@ -571,7 +570,8 @@ angle::Result Blit9::setFormatConvertShaders(Context9 *context9, ...@@ -571,7 +570,8 @@ angle::Result Blit9::setFormatConvertShaders(Context9 *context9,
addConst[W] = 0; addConst[W] = 0;
break; break;
default: UNREACHABLE(); default:
UNREACHABLE();
} }
mRenderer->getDevice()->SetPixelShaderConstantF(0, psConst, 2); mRenderer->getDevice()->SetPixelShaderConstantF(0, psConst, 2);
...@@ -652,7 +652,9 @@ void Blit9::setCommonBlitState() ...@@ -652,7 +652,9 @@ void Blit9::setCommonBlitState()
device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0); device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED); device->SetRenderState(D3DRS_COLORWRITEENABLE,
D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE |
D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE); device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);
device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
...@@ -662,10 +664,11 @@ void Blit9::setCommonBlitState() ...@@ -662,10 +664,11 @@ void Blit9::setCommonBlitState()
device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
RECT scissorRect = {0}; // Scissoring is disabled for flipping, but we need this to capture and restore the old rectangle RECT scissorRect = {0}; // Scissoring is disabled for flipping, but we need this to capture and
// restore the old rectangle
device->SetScissorRect(&scissorRect); device->SetScissorRect(&scissorRect);
for(int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{ {
device->SetStreamSourceFreq(i, 1); device->SetStreamSourceFreq(i, 1);
} }
...@@ -698,7 +701,7 @@ void Blit9::saveState() ...@@ -698,7 +701,7 @@ void Blit9::saveState()
setCommonBlitState(); setCommonBlitState();
static const float dummyConst[8] = { 0 }; static const float dummyConst[8] = {0};
device->SetVertexShader(nullptr); device->SetVertexShader(nullptr);
device->SetVertexShaderConstantF(0, dummyConst, 2); device->SetVertexShaderConstantF(0, dummyConst, 2);
...@@ -751,5 +754,4 @@ void Blit9::restoreState() ...@@ -751,5 +754,4 @@ void Blit9::restoreState()
mSavedStateBlock->Apply(); mSavedStateBlock->Apply();
} }
} }
} }
...@@ -139,9 +139,10 @@ angle::Result Image9::CopyLockableSurfaces(Context9 *context9, ...@@ -139,9 +139,10 @@ angle::Result Image9::CopyLockableSurfaces(Context9 *context9,
ASSERT(bytes <= static_cast<unsigned int>(sourceLock.Pitch) && ASSERT(bytes <= static_cast<unsigned int>(sourceLock.Pitch) &&
bytes <= static_cast<unsigned int>(destLock.Pitch)); bytes <= static_cast<unsigned int>(destLock.Pitch));
for(unsigned int i = 0; i < rows; i++) for (unsigned int i = 0; i < rows; i++)
{ {
memcpy((char*)destLock.pBits + destLock.Pitch * i, (char*)sourceLock.pBits + sourceLock.Pitch * i, bytes); memcpy((char *)destLock.pBits + destLock.Pitch * i,
(char *)sourceLock.pBits + sourceLock.Pitch * i, bytes);
} }
source->UnlockRect(); source->UnlockRect();
...@@ -227,11 +228,8 @@ bool Image9::redefine(gl::TextureType type, ...@@ -227,11 +228,8 @@ bool Image9::redefine(gl::TextureType type,
// Only 2D and cube texture are supported by the D3D9 backend. // Only 2D and cube texture are supported by the D3D9 backend.
ASSERT(type == gl::TextureType::_2D || type == gl::TextureType::CubeMap); ASSERT(type == gl::TextureType::_2D || type == gl::TextureType::CubeMap);
if (mWidth != size.width || if (mWidth != size.width || mHeight != size.height || mDepth != size.depth ||
mHeight != size.height || mInternalFormat != internalformat || forceRelease)
mDepth != size.depth ||
mInternalFormat != internalformat ||
forceRelease)
{ {
mWidth = size.width; mWidth = size.width;
mHeight = size.height; mHeight = size.height;
...@@ -347,8 +345,8 @@ D3DFORMAT Image9::getD3DFormat() const ...@@ -347,8 +345,8 @@ D3DFORMAT Image9::getD3DFormat() const
bool Image9::isDirty() const bool Image9::isDirty() const
{ {
// Make sure to that this image is marked as dirty even if the staging texture hasn't been created yet // Make sure to that this image is marked as dirty even if the staging texture hasn't been
// if initialization is required before use. // created yet if initialization is required before use.
return (mSurface || return (mSurface ||
d3d9::GetTextureFormatInfo(mInternalFormat).dataInitializerFunction != nullptr) && d3d9::GetTextureFormatInfo(mInternalFormat).dataInitializerFunction != nullptr) &&
mDirty; mDirty;
...@@ -472,8 +470,8 @@ angle::Result Image9::copyToSurface(Context9 *context9, ...@@ -472,8 +470,8 @@ angle::Result Image9::copyToSurface(Context9 *context9,
return angle::Result::Continue(); return angle::Result::Continue();
} }
// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input // Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as
// into the target pixel rectangle. // format/type at input into the target pixel rectangle.
angle::Result Image9::loadData(const gl::Context *context, angle::Result Image9::loadData(const gl::Context *context,
const gl::Box &area, const gl::Box &area,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -497,11 +495,7 @@ angle::Result Image9::loadData(const gl::Context *context, ...@@ -497,11 +495,7 @@ angle::Result Image9::loadData(const gl::Context *context,
const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat); const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
ASSERT(d3dFormatInfo.loadFunction != nullptr); ASSERT(d3dFormatInfo.loadFunction != nullptr);
RECT lockRect = RECT lockRect = {area.x, area.y, area.x + area.width, area.y + area.height};
{
area.x, area.y,
area.x + area.width, area.y + area.height
};
D3DLOCKED_RECT locked; D3DLOCKED_RECT locked;
ANGLE_TRY(lock(GetImplAs<Context9>(context), &locked, lockRect)); ANGLE_TRY(lock(GetImplAs<Context9>(context), &locked, lockRect));
...@@ -540,11 +534,7 @@ angle::Result Image9::loadCompressedData(const gl::Context *context, ...@@ -540,11 +534,7 @@ angle::Result Image9::loadCompressedData(const gl::Context *context,
ASSERT(d3d9FormatInfo.loadFunction != nullptr); ASSERT(d3d9FormatInfo.loadFunction != nullptr);
RECT lockRect = RECT lockRect = {area.x, area.y, area.x + area.width, area.y + area.height};
{
area.x, area.y,
area.x + area.width, area.y + area.height
};
D3DLOCKED_RECT locked; D3DLOCKED_RECT locked;
ANGLE_TRY(lock(GetImplAs<Context9>(context), &locked, lockRect)); ANGLE_TRY(lock(GetImplAs<Context9>(context), &locked, lockRect));
...@@ -558,7 +548,8 @@ angle::Result Image9::loadCompressedData(const gl::Context *context, ...@@ -558,7 +548,8 @@ angle::Result Image9::loadCompressedData(const gl::Context *context,
return angle::Result::Continue(); return angle::Result::Continue();
} }
// This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete textures // This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete
// textures
angle::Result Image9::copyFromRTInternal(Context9 *context9, angle::Result Image9::copyFromRTInternal(Context9 *context9,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
...@@ -593,8 +584,8 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9, ...@@ -593,8 +584,8 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9,
int width = sourceArea.width; int width = sourceArea.width;
int height = sourceArea.height; int height = sourceArea.height;
RECT sourceRect = { sourceArea.x, sourceArea.y, sourceArea.x + width, sourceArea.y + height }; RECT sourceRect = {sourceArea.x, sourceArea.y, sourceArea.x + width, sourceArea.y + height};
RECT destRect = { destOffset.x, destOffset.y, destOffset.x + width, destOffset.y + height }; RECT destRect = {destOffset.x, destOffset.y, destOffset.x + width, destOffset.y + height};
D3DLOCKED_RECT sourceLock = {0}; D3DLOCKED_RECT sourceLock = {0};
hr = renderTargetData->LockRect(&sourceLock, &sourceRect, 0); hr = renderTargetData->LockRect(&sourceLock, &sourceRect, 0);
...@@ -611,8 +602,8 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9, ...@@ -611,8 +602,8 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9,
ASSERT(destLock.pBits && sourceLock.pBits); ASSERT(destLock.pBits && sourceLock.pBits);
unsigned char *sourcePixels = (unsigned char*)sourceLock.pBits; unsigned char *sourcePixels = (unsigned char *)sourceLock.pBits;
unsigned char *destPixels = (unsigned char*)destLock.pBits; unsigned char *destPixels = (unsigned char *)destLock.pBits;
switch (description.Format) switch (description.Format)
{ {
...@@ -664,7 +655,7 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9, ...@@ -664,7 +655,7 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9,
{ {
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgb = ((unsigned short*)sourcePixels)[x]; unsigned short rgb = ((unsigned short *)sourcePixels)[x];
unsigned char red = static_cast<unsigned char>((rgb & 0xF800) >> 8); unsigned char red = static_cast<unsigned char>((rgb & 0xF800) >> 8);
unsigned char green = static_cast<unsigned char>((rgb & 0x07E0) >> 3); unsigned char green = static_cast<unsigned char>((rgb & 0x07E0) >> 3);
unsigned char blue = static_cast<unsigned char>((rgb & 0x001F) << 3); unsigned char blue = static_cast<unsigned char>((rgb & 0x001F) << 3);
...@@ -701,7 +692,7 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9, ...@@ -701,7 +692,7 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9,
{ {
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short argb = ((unsigned short*)sourcePixels)[x]; unsigned short argb = ((unsigned short *)sourcePixels)[x];
unsigned char red = static_cast<unsigned char>((argb & 0x7C00) >> 7); unsigned char red = static_cast<unsigned char>((argb & 0x7C00) >> 7);
unsigned char green = static_cast<unsigned char>((argb & 0x03E0) >> 2); unsigned char green = static_cast<unsigned char>((argb & 0x03E0) >> 2);
unsigned char blue = static_cast<unsigned char>((argb & 0x001F) << 3); unsigned char blue = static_cast<unsigned char>((argb & 0x001F) << 3);
...@@ -719,7 +710,7 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9, ...@@ -719,7 +710,7 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9,
{ {
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short argb = ((unsigned short*)sourcePixels)[x]; unsigned short argb = ((unsigned short *)sourcePixels)[x];
unsigned char red = static_cast<unsigned char>((argb & 0x7C00) >> 7); unsigned char red = static_cast<unsigned char>((argb & 0x7C00) >> 7);
unsigned char green = static_cast<unsigned char>((argb & 0x03E0) >> 2); unsigned char green = static_cast<unsigned char>((argb & 0x03E0) >> 2);
unsigned char blue = static_cast<unsigned char>((argb & 0x001F) << 3); unsigned char blue = static_cast<unsigned char>((argb & 0x001F) << 3);
......
...@@ -80,8 +80,9 @@ angle::Result RenderbufferGL::setStorageMultisample(const gl::Context *context, ...@@ -80,8 +80,9 @@ angle::Result RenderbufferGL::setStorageMultisample(const gl::Context *context,
const gl::TextureCaps &formatCaps = mTextureCaps.get(internalformat); const gl::TextureCaps &formatCaps = mTextureCaps.get(internalformat);
if (samples > formatCaps.getMaxSamples()) if (samples > formatCaps.getMaxSamples())
{ {
// Before version 4.2, it is unknown if the specific internal format can support the requested number // Before version 4.2, it is unknown if the specific internal format can support the
// of samples. It is expected that GL_OUT_OF_MEMORY is returned if the renderbuffer cannot be created. // requested number of samples. It is expected that GL_OUT_OF_MEMORY is returned if the
// renderbuffer cannot be created.
GLenum error = GL_NO_ERROR; GLenum error = GL_NO_ERROR;
do do
{ {
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#ifndef LIBANGLE_RENDERER_GL_TEXTUREGL_H_ #ifndef LIBANGLE_RENDERER_GL_TEXTUREGL_H_
#define LIBANGLE_RENDERER_GL_TEXTUREGL_H_ #define LIBANGLE_RENDERER_GL_TEXTUREGL_H_
#include "libANGLE/Texture.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/renderer/TextureImpl.h" #include "libANGLE/renderer/TextureImpl.h"
#include "libANGLE/Texture.h"
namespace rx namespace rx
{ {
...@@ -246,7 +246,6 @@ class TextureGL : public TextureImpl ...@@ -246,7 +246,6 @@ class TextureGL : public TextureImpl
GLuint mTextureID; GLuint mTextureID;
}; };
} }
#endif // LIBANGLE_RENDERER_GL_TEXTUREGL_H_ #endif // LIBANGLE_RENDERER_GL_TEXTUREGL_H_
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
// vertex buffer. // vertex buffer.
// //
#include "libANGLE/angletypes.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/d3d/IndexDataManager.h"
#include "libANGLE/renderer/d3d/d3d11/Buffer11.h" #include "libANGLE/renderer/d3d/d3d11/Buffer11.h"
#include "libANGLE/renderer/d3d/d3d11/Context11.h" #include "libANGLE/renderer/d3d/d3d11/Context11.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h" #include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/IndexDataManager.h"
#include "test_utils/ANGLETest.h" #include "test_utils/ANGLETest.h"
#include "test_utils/angle_test_instantiate.h" #include "test_utils/angle_test_instantiate.h"
...@@ -25,7 +25,6 @@ namespace ...@@ -25,7 +25,6 @@ namespace
class D3D11EmulatedIndexedBufferTest : public ANGLETest class D3D11EmulatedIndexedBufferTest : public ANGLETest
{ {
protected: protected:
void SetUp() override void SetUp() override
{ {
ANGLETest::SetUp(); ANGLETest::SetUp();
...@@ -36,7 +35,7 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest ...@@ -36,7 +35,7 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest
mRenderer = context11->getRenderer(); mRenderer = context11->getRenderer();
mSourceBuffer = new rx::Buffer11(mBufferState, mRenderer); mSourceBuffer = new rx::Buffer11(mBufferState, mRenderer);
GLfloat testData[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; GLfloat testData[] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
angle::Result error = mSourceBuffer->setData(nullptr, gl::BufferBinding::Array, testData, angle::Result error = mSourceBuffer->setData(nullptr, gl::BufferBinding::Array, testData,
sizeof(testData), gl::BufferUsage::StaticDraw); sizeof(testData), gl::BufferUsage::StaticDraw);
ASSERT_EQ(angle::Result::Continue(), error); ASSERT_EQ(angle::Result::Continue(), error);
...@@ -62,7 +61,9 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest ...@@ -62,7 +61,9 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest
ANGLETest::TearDown(); ANGLETest::TearDown();
} }
void createMappableCompareBufferFromEmulatedBuffer(ID3D11Buffer *sourceBuffer, GLuint size, ID3D11Buffer **mappableBuffer) void createMappableCompareBufferFromEmulatedBuffer(ID3D11Buffer *sourceBuffer,
GLuint size,
ID3D11Buffer **mappableBuffer)
{ {
*mappableBuffer = nullptr; *mappableBuffer = nullptr;
...@@ -85,7 +86,8 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest ...@@ -85,7 +86,8 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest
srcBox.front = 0; srcBox.front = 0;
srcBox.back = 1; srcBox.back = 1;
mRenderer->getDeviceContext()->CopySubresourceRegion(*mappableBuffer, 0, 0, 0, 0, sourceBuffer, 0, &srcBox); mRenderer->getDeviceContext()->CopySubresourceRegion(*mappableBuffer, 0, 0, 0, 0,
sourceBuffer, 0, &srcBox);
} }
void compareContents(ID3D11Buffer *actual) void compareContents(ID3D11Buffer *actual)
...@@ -96,10 +98,11 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest ...@@ -96,10 +98,11 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest
&compareBuffer); &compareBuffer);
D3D11_MAPPED_SUBRESOURCE mappedResource; D3D11_MAPPED_SUBRESOURCE mappedResource;
HRESULT hr = mRenderer->getDeviceContext()->Map(compareBuffer, 0, D3D11_MAP_READ, 0, &mappedResource); HRESULT hr = mRenderer->getDeviceContext()->Map(compareBuffer, 0, D3D11_MAP_READ, 0,
&mappedResource);
ASSERT_TRUE(SUCCEEDED(hr)); ASSERT_TRUE(SUCCEEDED(hr));
GLfloat* compareData = static_cast<GLfloat*>(mappedResource.pData); GLfloat *compareData = static_cast<GLfloat *>(mappedResource.pData);
for (size_t i = 0; i < mExpectedExpandedData.size(); i++) for (size_t i = 0; i < mExpectedExpandedData.size(); i++)
{ {
EXPECT_EQ(mExpectedExpandedData[i], compareData[i]); EXPECT_EQ(mExpectedExpandedData[i], compareData[i]);
...@@ -161,7 +164,8 @@ TEST_P(D3D11EmulatedIndexedBufferTest, TestNativeToExpandedUsingGLuintIndices) ...@@ -161,7 +164,8 @@ TEST_P(D3D11EmulatedIndexedBufferTest, TestNativeToExpandedUsingGLuintIndices)
emulateAndCompare(&srcData); emulateAndCompare(&srcData);
} }
// This tests verifies that a Buffer11 contents remain unchanged after calling getEmulatedIndexedBuffer // This tests verifies that a Buffer11 contents remain unchanged after calling
// getEmulatedIndexedBuffer
TEST_P(D3D11EmulatedIndexedBufferTest, TestSourceBufferRemainsUntouchedAfterExpandOperation) TEST_P(D3D11EmulatedIndexedBufferTest, TestSourceBufferRemainsUntouchedAfterExpandOperation)
{ {
// Copy the original source buffer before any expand calls have been made // Copy the original source buffer before any expand calls have been made
...@@ -192,7 +196,6 @@ TEST_P(D3D11EmulatedIndexedBufferTest, TestSourceBufferRemainsUntouchedAfterExpa ...@@ -192,7 +196,6 @@ TEST_P(D3D11EmulatedIndexedBufferTest, TestSourceBufferRemainsUntouchedAfterExpa
SafeDelete(cleanSourceBuffer); SafeDelete(cleanSourceBuffer);
} }
ANGLE_INSTANTIATE_TEST(D3D11EmulatedIndexedBufferTest, ANGLE_INSTANTIATE_TEST(D3D11EmulatedIndexedBufferTest, ES2_D3D11());
ES2_D3D11());
} // anonymous namespace } // anonymous namespace
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