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
......@@ -262,4 +262,4 @@ class ANGLE_NO_DISCARD Result
#include "Error.inl"
#endif // LIBANGLE_ERROR_H_
#endif // LIBANGLE_ERROR_H_
......@@ -165,7 +165,7 @@ GLuint ShaderProgramManager::createShader(rx::GLImplFactory *factory,
ShaderType type)
{
ASSERT(type != ShaderType::InvalidEnum);
GLuint handle = mHandleAllocator.allocate();
GLuint handle = mHandleAllocator.allocate();
mShaders.assign(handle, new Shader(this, factory, rendererLimitations, type, handle));
return handle;
}
......@@ -364,7 +364,7 @@ angle::Result PathManager::createPaths(Context *context, GLsizei range, GLuint *
for (GLsizei i = 0; i < range; ++i)
{
rx::PathImpl *impl = paths[static_cast<unsigned>(i)];
const auto id = client + i;
const auto id = client + i;
mPaths.assign(id, new Path(impl));
}
*createdOut = client;
......
......@@ -306,4 +306,4 @@ class ProgramPipelineManager
} // namespace gl
#endif // LIBANGLE_RESOURCEMANAGER_H_
#endif // LIBANGLE_RESOURCEMANAGER_H_
......@@ -173,7 +173,6 @@ class TextureImpl : public FramebufferAttachmentObjectImpl
protected:
const gl::TextureState &mState;
};
}
#endif // LIBANGLE_RENDERER_TEXTUREIMPL_H_
#endif // LIBANGLE_RENDERER_TEXTUREIMPL_H_
......@@ -126,7 +126,6 @@ class MockTextureImpl : public TextureImpl
protected:
gl::TextureState mMockState;
};
}
#endif // LIBANGLE_RENDERER_TEXTUREIMPLMOCK_H_
#endif // LIBANGLE_RENDERER_TEXTUREIMPLMOCK_H_
......@@ -185,11 +185,11 @@ angle::Result FramebufferD3D::clearBufferfi(const gl::Context *context,
GLint stencil)
{
// glClearBufferfi can only be called to clear a depth stencil buffer
ClearParameters clearParams = GetClearParameters(context->getGLState(), 0);
clearParams.clearDepth = true;
clearParams.depthValue = depth;
clearParams.clearStencil = true;
clearParams.stencilValue = stencil;
ClearParameters clearParams = GetClearParameters(context->getGLState(), 0);
clearParams.clearDepth = true;
clearParams.depthValue = depth;
clearParams.clearStencil = true;
clearParams.stencilValue = stencil;
return clearImpl(context, clearParams);
}
......@@ -304,7 +304,8 @@ bool FramebufferD3D::checkStatus(const gl::Context *context) const
// D3D11 does not allow for overlapping RenderTargetViews.
// 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 (!mState.colorAttachmentsAreUniqueImages())
......@@ -418,7 +419,7 @@ const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const gl:
}
}
mColorAttachmentsForRender = std::move(colorAttachmentsForRender);
mColorAttachmentsForRender = std::move(colorAttachmentsForRender);
mCurrentActiveProgramOutputs = activeProgramOutputs;
return mColorAttachmentsForRender.value();
......
......@@ -42,11 +42,13 @@ angle::Result GetUnpackPointer(const gl::Context *context,
{
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);
// 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);
ASSERT(bufferD3D);
const uint8_t *bufferData = nullptr;
......@@ -71,7 +73,6 @@ bool IsRenderTargetUsage(GLenum usage)
{
return (usage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
}
}
TextureD3D::TextureD3D(const gl::TextureState &state, RendererD3D *renderer)
......@@ -227,8 +228,9 @@ angle::Result TextureD3D::setImageImpl(const gl::Context *context,
return angle::Result::Continue();
}
// We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains.
// From our image internal format we know how many channels to expect, and "type" gives the format of pixel's components.
// We no longer need the "GLenum format" parameter to TexImage to determine what data format
// "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;
ANGLE_TRY(GetUnpackPointer(context, unpack, unpackBuffer, pixels, layerOffset, &pixelData));
......@@ -241,7 +243,8 @@ angle::Result TextureD3D::setImageImpl(const gl::Context *context,
}
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,
index.usesTex3D()));
}
......@@ -298,8 +301,9 @@ angle::Result TextureD3D::setCompressedImageImpl(const gl::Context *context,
return angle::Result::Continue();
}
// We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains.
// From our image internal format we know how many channels to expect, and "type" gives the format of pixel's components.
// We no longer need the "GLenum format" parameter to TexImage to determine what data format
// "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;
gl::Buffer *unpackBuffer =
context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack);
......@@ -367,8 +371,8 @@ angle::Result TextureD3D::fastUnpackPixels(const gl::Context *context,
return angle::Result::Continue();
}
// In order to perform the fast copy through the shader, we must have the right format, and be able
// to create a render target.
// In order to perform the fast copy through the shader, we must have the right format, and be
// able to create a render target.
ASSERT(mRenderer->supportsFastCopyBufferToTexture(sizedInternalFormat));
uintptr_t offset = reinterpret_cast<uintptr_t>(pixels);
......@@ -423,7 +427,7 @@ angle::Result TextureD3D::setImageExternal(const gl::Context *context,
angle::Result TextureD3D::generateMipmap(const gl::Context *context)
{
const GLuint baseLevel = mState.getEffectiveBaseLevel();
const GLuint maxLevel = mState.getMipmapMaxLevel();
const GLuint maxLevel = mState.getMipmapMaxLevel();
ASSERT(maxLevel > baseLevel); // Should be checked before calling this.
if (mTexStorage && mRenderer->getWorkarounds().zeroMaxLodWorkaround)
......@@ -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.
// The restriction is because Feature Level 9_3 can't create SRVs on individual levels of the texture.
// As a result, even if the storage is a rendertarget, we can't use the GPU to generate the mipmaps without further work.
// The D3D9 renderer works around this by copying each level of the texture into its own single-layer GPU texture (in 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));
// TODO: Decouple this from zeroMaxLodWorkaround. This is a 9_3 restriction, unrelated to
// zeroMaxLodWorkaround. The restriction is because Feature Level 9_3 can't create SRVs on
// individual levels of the texture. As a result, even if the storage is a rendertarget, we
// can't use the GPU to generate the mipmaps without further work. The D3D9 renderer works
// around this by copying each level of the texture into its own single-layer GPU texture (in
// 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)
{
......@@ -495,7 +502,7 @@ angle::Result TextureD3D::generateMipmapUsingImages(const gl::Context *context,
ASSERT(getLayerCount(mip) == layerCount);
gl::ImageIndex sourceIndex = getImageIndex(mip - 1, layer);
gl::ImageIndex destIndex = getImageIndex(mip, layer);
gl::ImageIndex destIndex = getImageIndex(mip, layer);
if (renderableStorage)
{
......@@ -625,7 +632,7 @@ angle::Result TextureD3D::setBaseLevel(const gl::Context *context, GLuint baseLe
// have been created based on the dimensions of the previous specified level range.
const int newStorageWidth = std::max(1, getLevelZeroWidth());
const int newStorageHeight = std::max(1, getLevelZeroHeight());
const int newStorageDepth = std::max(1, getLevelZeroDepth());
const int newStorageDepth = std::max(1, getLevelZeroDepth());
const int newStorageFormat = getBaseLevelInternalFormat();
if (mTexStorage &&
(newStorageWidth != oldStorageWidth || newStorageHeight != oldStorageHeight ||
......@@ -929,7 +936,8 @@ angle::Result TextureD3D_2D::setCompressedImage(const gl::Context *context,
{
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));
return setCompressedImageImpl(context, index, unpack, pixels, 0);
......@@ -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);
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders,
// so we should use the non-rendering copy path.
// If the zero max LOD workaround is active, then we can't sample from individual layers of the
// framebuffer in shaders, so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{
ANGLE_TRY(mImageArray[index.getLevelIndex()]->copyFromFramebuffer(context, destOffset,
......@@ -1029,11 +1037,12 @@ angle::Result TextureD3D_2D::copySubImage(const gl::Context *context,
const gl::Offset clippedOffset(destOffset.x + clippedArea.x - sourceArea.x,
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
// the current level we're copying to is defined (with appropriate format, width & height)
// can only make our texture storage to a render target if level 0 is defined (with a width &
// 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,
// so we should use the non-rendering copy path.
// If the zero max LOD workaround is active, then we can't sample from individual layers of the
// framebuffer in shaders, so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{
ANGLE_TRY(mImageArray[index.getLevelIndex()]->copyFromFramebuffer(context, clippedOffset,
......@@ -1100,7 +1109,7 @@ angle::Result TextureD3D_2D::copyTexture(const gl::Context *context,
ImageD3D *sourceImage = nullptr;
ANGLE_TRY(sourceD3D->getImageAndSyncFromStorage(context, sourceImageIndex, &sourceImage));
ImageD3D *destImage = nullptr;
ImageD3D *destImage = nullptr;
ANGLE_TRY(getImageAndSyncFromStorage(context, index, &destImage));
ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceBox, destOffset,
......@@ -1148,7 +1157,7 @@ angle::Result TextureD3D_2D::copySubTexture(const gl::Context *context,
ImageD3D *sourceImage = nullptr;
ANGLE_TRY(sourceD3D->getImageAndSyncFromStorage(context, sourceImageIndex, &sourceImage));
ImageD3D *destImage = nullptr;
ImageD3D *destImage = nullptr;
ANGLE_TRY(getImageAndSyncFromStorage(context, index, &destImage));
ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceBox, destOffset,
......@@ -1167,7 +1176,7 @@ angle::Result TextureD3D_2D::copyCompressedTexture(const gl::Context *context,
const gl::Texture *source)
{
gl::TextureTarget sourceTarget = NonCubeTextureTypeToTarget(source->getType());
GLint sourceLevel = 0;
GLint sourceLevel = 0;
GLint destLevel = 0;
......@@ -1196,8 +1205,7 @@ angle::Result TextureD3D_2D::setStorage(const gl::Context *context,
for (size_t level = 0; level < levels; level++)
{
gl::Extents levelSize(std::max(1, size.width >> level),
std::max(1, size.height >> level),
gl::Extents levelSize(std::max(1, size.width >> level), std::max(1, size.height >> level),
1);
ANGLE_TRY(redefineImage(context, level, internalFormat, levelSize, true));
}
......@@ -1235,7 +1243,7 @@ angle::Result TextureD3D_2D::bindTexImage(const gl::Context *context, egl::Surfa
SurfaceD3D *surfaceD3D = GetImplAs<SurfaceD3D>(surface);
ASSERT(surfaceD3D);
mTexStorage = mRenderer->createTextureStorage2D(surfaceD3D->getSwapChain());
mTexStorage = mRenderer->createTextureStorage2D(surfaceD3D->getSwapChain());
mEGLImageTarget = false;
mDirtyImages = false;
......@@ -1417,8 +1425,8 @@ angle::Result TextureD3D_2D::createCompleteStorage(bool renderTarget,
bool hintLevelZeroOnly = false;
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.
// Otherwise, it should use the level-zero-only texture.
// If any of the CPU images (levels >= 1) are dirty, then the textureStorage2D should use
// the mipped texture to begin with. Otherwise, it should use the level-zero-only texture.
hintLevelZeroOnly = true;
for (int level = 1; level < levels && hintLevelZeroOnly; level++)
{
......@@ -1677,7 +1685,8 @@ angle::Result TextureD3D_Cube::setCompressedImage(const gl::Context *context,
{
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(),
internalFormat, size, false));
......@@ -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);
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders,
// so we should use the non-rendering copy path.
// If the zero max LOD workaround is active, then we can't sample from individual layers of the
// framebuffer in shaders, so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{
ANGLE_TRY(mImageArray[faceIndex][index.getLevelIndex()]->copyFromFramebuffer(
......@@ -1780,8 +1789,8 @@ angle::Result TextureD3D_Cube::copySubImage(const gl::Context *context,
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,
// so we should use the non-rendering copy path.
// If the zero max LOD workaround is active, then we can't sample from individual layers of the
// framebuffer in shaders, so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{
ANGLE_TRY(mImageArray[faceIndex][index.getLevelIndex()]->copyFromFramebuffer(
......@@ -1961,8 +1970,8 @@ angle::Result TextureD3D_Cube::setStorage(const gl::Context *context,
// Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
bool TextureD3D_Cube::isCubeComplete() const
{
int baseWidth = getBaseLevelWidth();
int baseHeight = getBaseLevelHeight();
int baseWidth = getBaseLevelWidth();
int baseHeight = getBaseLevelHeight();
GLenum baseFormat = getBaseLevelInternalFormat();
if (baseWidth <= 0 || baseWidth != baseHeight)
......@@ -1974,9 +1983,8 @@ bool TextureD3D_Cube::isCubeComplete() const
{
const ImageD3D &faceBaseImage = *mImageArray[faceIndex][getBaseLevel()];
if (faceBaseImage.getWidth() != baseWidth ||
faceBaseImage.getHeight() != baseHeight ||
faceBaseImage.getInternalFormat() != baseFormat )
if (faceBaseImage.getWidth() != baseWidth || faceBaseImage.getHeight() != baseHeight ||
faceBaseImage.getInternalFormat() != baseFormat)
{
return false;
}
......@@ -2073,14 +2081,15 @@ angle::Result TextureD3D_Cube::createCompleteStorage(bool renderTarget,
bool hintLevelZeroOnly = false;
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.
// Otherwise, it should use the level-zero-only texture.
// If any of the CPU images (levels >= 1) are dirty, then the textureStorage should use the
// mipped texture to begin with. Otherwise, it should use the level-zero-only texture.
hintLevelZeroOnly = true;
for (size_t faceIndex = 0; faceIndex < gl::kCubeFaceCount && hintLevelZeroOnly; faceIndex++)
{
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,
{
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));
return setCompressedImageImpl(context, index, unpack, pixels, 0);
......@@ -2650,8 +2660,7 @@ angle::Result TextureD3D_3D::setStorage(const gl::Context *context,
for (size_t level = 0; level < levels; level++)
{
gl::Extents levelSize(std::max(1, size.width >> level),
std::max(1, size.height >> level),
gl::Extents levelSize(std::max(1, size.width >> level), std::max(1, size.height >> level),
std::max(1, size.depth >> level));
mImageArray[level]->redefine(gl::TextureType::_3D, internalFormat, levelSize, true);
}
......@@ -2767,7 +2776,8 @@ angle::Result TextureD3D_3D::createCompleteStorage(bool renderTarget,
ASSERT(width > 0 && height > 0 && depth > 0);
// 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
outStorage->reset(mRenderer->createTextureStorage3D(internalFormat, renderTarget, width, height,
......@@ -2780,7 +2790,7 @@ angle::Result TextureD3D_3D::setCompleteTexStorage(const gl::Context *context,
TextureStorage *newCompleteTexStorage)
{
ANGLE_TRY(releaseTexStorage(context));
mTexStorage = newCompleteTexStorage;
mTexStorage = newCompleteTexStorage;
mDirtyImages = true;
// We do not support managed 3D storage, as that is D3D9/ES2-only
......@@ -2892,9 +2902,9 @@ angle::Result TextureD3D_3D::redefineImage(const gl::Context *context,
bool forceRelease)
{
// If there currently is a corresponding storage texture image, it has these parameters
const int storageWidth = std::max(1, getLevelZeroWidth() >> level);
const int storageHeight = std::max(1, getLevelZeroHeight() >> level);
const int storageDepth = std::max(1, getLevelZeroDepth() >> level);
const int storageWidth = std::max(1, getLevelZeroWidth() >> level);
const int storageHeight = std::max(1, getLevelZeroHeight() >> level);
const int storageDepth = std::max(1, getLevelZeroDepth() >> level);
const GLenum storageFormat = getBaseLevelInternalFormat();
mImageArray[level]->redefine(gl::TextureType::_3D, internalformat, size, forceRelease);
......@@ -2976,8 +2986,7 @@ TextureD3D_2DArray::~TextureD3D_2DArray()
ImageD3D *TextureD3D_2DArray::getImage(int level, int layer) const
{
ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT((layer == 0 && mLayerCounts[level] == 0) ||
layer < mLayerCounts[level]);
ASSERT((layer == 0 && mLayerCounts[level] == 0) || layer < mLayerCounts[level]);
return (mImageArray[level] ? mImageArray[level][layer] : nullptr);
}
......@@ -3001,17 +3010,23 @@ GLsizei TextureD3D_2DArray::getLayerCount(int 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
{
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
{
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
......@@ -3086,7 +3101,7 @@ angle::Result TextureD3D_2DArray::setSubImage(const gl::Context *context,
for (int i = 0; i < area.depth; i++)
{
int layer = area.z + i;
int layer = area.z + i;
const ptrdiff_t layerOffset = (inputDepthPitch * i);
gl::Box layerArea(area.x, area.y, 0, area.width, area.height, 1);
......@@ -3111,7 +3126,8 @@ angle::Result TextureD3D_2DArray::setCompressedImage(const gl::Context *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));
const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalFormat);
......@@ -3151,7 +3167,7 @@ angle::Result TextureD3D_2DArray::setCompressedSubImage(const gl::Context *conte
for (int i = 0; i < area.depth; i++)
{
int layer = area.z + i;
int layer = area.z + i;
const ptrdiff_t layerOffset = (inputDepthPitch * i);
gl::Box layerArea(area.x, area.y, 0, area.width, area.height, 1);
......@@ -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++)
{
gl::Extents levelLayerSize(std::max(1, size.width >> level),
std::max(1, size.height >> level),
1);
std::max(1, size.height >> level), 1);
mLayerCounts[level] = (level < levels ? size.depth : 0);
if (mLayerCounts[level] > 0)
{
// 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++)
{
......@@ -3419,10 +3434,10 @@ angle::Result TextureD3D_2DArray::initMipmapImages(const gl::Context *context)
{
const GLuint baseLevel = mState.getEffectiveBaseLevel();
const GLuint maxLevel = mState.getMipmapMaxLevel();
int baseWidth = getLevelZeroWidth();
int baseHeight = getLevelZeroHeight();
int baseDepth = getLayerCount(getBaseLevel());
GLenum baseFormat = getBaseLevelInternalFormat();
int baseWidth = getLevelZeroWidth();
int baseHeight = getLevelZeroHeight();
int baseDepth = getLayerCount(getBaseLevel());
GLenum baseFormat = getBaseLevelInternalFormat();
// Purge array levels baseLevel + 1 through q and reset them to represent the generated mipmap
// levels.
......@@ -3430,8 +3445,7 @@ angle::Result TextureD3D_2DArray::initMipmapImages(const gl::Context *context)
{
ASSERT((baseWidth >> level) > 0 || (baseHeight >> level) > 0);
gl::Extents levelLayerSize(std::max(baseWidth >> level, 1),
std::max(baseHeight >> level, 1),
baseDepth);
std::max(baseHeight >> level, 1), baseDepth);
ANGLE_TRY(redefineImage(context, level, baseFormat, levelLayerSize, false));
}
......@@ -3502,7 +3516,7 @@ angle::Result TextureD3D_2DArray::setCompleteTexStorage(const gl::Context *conte
TextureStorage *newCompleteTexStorage)
{
ANGLE_TRY(releaseTexStorage(context));
mTexStorage = newCompleteTexStorage;
mTexStorage = newCompleteTexStorage;
mDirtyImages = true;
// We do not support managed 2D array storage, as managed storage is ES2/D3D9 only
......@@ -3636,9 +3650,9 @@ angle::Result TextureD3D_2DArray::redefineImage(const gl::Context *context,
bool forceRelease)
{
// If there currently is a corresponding storage texture image, it has these parameters
const int storageWidth = std::max(1, getLevelZeroWidth() >> level);
const int storageHeight = std::max(1, getLevelZeroHeight() >> level);
const GLuint baseLevel = getBaseLevel();
const int storageWidth = std::max(1, getLevelZeroWidth() >> level);
const int storageHeight = std::max(1, getLevelZeroHeight() >> level);
const GLuint baseLevel = getBaseLevel();
const GLenum storageFormat = getBaseLevelInternalFormat();
int storageDepth = 0;
......@@ -3659,7 +3673,7 @@ angle::Result TextureD3D_2DArray::redefineImage(const gl::Context *context,
if (size.depth > 0)
{
mImageArray[level] = new ImageD3D*[size.depth];
mImageArray[level] = new ImageD3D *[size.depth];
for (int layer = 0; layer < mLayerCounts[level]; layer++)
{
mImageArray[level][layer] = mRenderer->createImage();
......
......@@ -43,7 +43,7 @@ class TextureD3D : public TextureImpl
void resetDirty() { mDirtyImages = false; }
virtual ImageD3D *getImage(const gl::ImageIndex &index) const = 0;
virtual GLsizei getLayerCount(int level) const = 0;
virtual GLsizei getLayerCount(int level) const = 0;
angle::Result getImageAndSyncFromStorage(const gl::Context *context,
const gl::ImageIndex &index,
......@@ -78,7 +78,7 @@ class TextureD3D : public TextureImpl
// Returns an ImageIndex for a particular "Image". 3D Textures do not have images for
// slices of their depth texures, so 3D textures ignore the layer parameter.
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const = 0;
virtual bool isValidIndex(const gl::ImageIndex &index) const = 0;
virtual bool isValidIndex(const gl::ImageIndex &index) const = 0;
angle::Result setImageExternal(const gl::Context *context,
gl::TextureType type,
......@@ -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
// 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
// sense for the Image class to not have to worry about layer subresource as well as mip subresources.
// to update all the texture layers since they cannot all be updated at once and it makes the
// 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];
ImageD3D **mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
};
......@@ -896,4 +897,4 @@ class TextureD3D_2DMultisampleArray : public TextureD3DImmutableBase
};
}
#endif // LIBANGLE_RENDERER_D3D_TEXTURED3D_H_
#endif // LIBANGLE_RENDERER_D3D_TEXTURED3D_H_
......@@ -130,7 +130,7 @@ class Buffer11::BufferStorage : angle::NonCopyable
size_t length,
GLbitfield access,
uint8_t **mapPointerOut) = 0;
virtual void unmap() = 0;
virtual void unmap() = 0;
angle::Result setData(const gl::Context *context,
const uint8_t *data,
......@@ -1210,7 +1210,7 @@ angle::Result Buffer11::NativeStorage::map(const gl::Context *context,
ASSERT(isCPUAccessible(access));
D3D11_MAPPED_SUBRESOURCE mappedResource;
D3D11_MAP d3dMapType = gl_d3d11::GetD3DMapTypeFromBits(mUsage, access);
D3D11_MAP d3dMapType = gl_d3d11::GetD3DMapTypeFromBits(mUsage, access);
UINT d3dMapFlag = ((access & GL_MAP_UNSYNCHRONIZED_BIT) != 0 ? D3D11_MAP_FLAG_DO_NOT_WAIT : 0);
ANGLE_TRY(
......
......@@ -628,7 +628,7 @@ angle::Result Clear11::clearFramebuffer(const gl::Context *context,
dsv = depthStencilRenderTarget->getDepthStencilView().get();
ASSERT(dsv != nullptr);
const auto &nativeFormat = depthStencilRenderTarget->getFormatSet().format();
const auto &nativeFormat = depthStencilRenderTarget->getFormatSet().format();
const auto *stencilAttachment = fboData.getStencilAttachment();
uint32_t stencilUnmasked =
......@@ -701,7 +701,7 @@ angle::Result Clear11::clearFramebuffer(const gl::Context *context,
ANGLE_TRY(mRenderer->getBlendState(context, mBlendStateKey, &blendState));
const d3d11::DepthStencilState *dsState = nullptr;
const float *zValue = nullptr;
const float *zValue = nullptr;
if (dsv)
{
......@@ -772,10 +772,10 @@ angle::Result Clear11::clearFramebuffer(const gl::Context *context,
}
// Get Shaders
const d3d11::VertexShader *vs = nullptr;
const d3d11::VertexShader *vs = nullptr;
const d3d11::GeometryShader *gs = nullptr;
const d3d11::InputLayout *il = nullptr;
const d3d11::PixelShader *ps = nullptr;
const d3d11::InputLayout *il = nullptr;
const d3d11::PixelShader *ps = nullptr;
const bool hasLayeredLayout =
(fboData.getMultiviewLayout() == GL_FRAMEBUFFER_MULTIVIEW_LAYERED_ANGLE);
ANGLE_TRY(mShaderManager.getShadersAndLayout(context, mRenderer, clearParams.colorType, numRtvs,
......
......@@ -100,7 +100,7 @@ angle::Result Image11::CopyImage(const gl::Context *context,
gl::GetSizedInternalFormatInfo(sourceFormat.fboImplementationInternalFormat).pixelBytes;
GLenum destUnsizedFormat = gl::GetUnsizedFormat(dest->getInternalFormat());
const auto &destFormat = d3d11::Format::Get(dest->getInternalFormat(), rendererCaps).format();
const auto &destFormat = d3d11::Format::Get(dest->getInternalFormat(), rendererCaps).format();
const auto &destFormatInfo =
gl::GetSizedInternalFormatInfo(destFormat.fboImplementationInternalFormat);
GLuint destPixelBytes = destFormatInfo.pixelBytes;
......@@ -162,7 +162,7 @@ angle::Result Image11::copyToStorage(const gl::Context *context,
}
const TextureHelper11 *stagingTexture = nullptr;
unsigned int stagingSubresourceIndex = 0;
unsigned int stagingSubresourceIndex = 0;
ANGLE_TRY(getStagingTexture(context, &stagingTexture, &stagingSubresourceIndex));
ANGLE_TRY(storage11->updateSubresourceLevel(context, *stagingTexture, stagingSubresourceIndex,
index, region));
......@@ -411,7 +411,7 @@ angle::Result Image11::copyFromFramebuffer(const gl::Context *context,
const auto &destD3D11Format =
d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
auto loadFunction = destD3D11Format.getLoadFunctions()(destFormatInfo.type);
auto loadFunction = destD3D11Format.getLoadFunctions()(destFormatInfo.type);
angle::Result error = angle::Result::Continue();
if (loadFunction.requiresConversion)
{
......@@ -454,7 +454,7 @@ angle::Result Image11::copyWithoutConversion(const gl::Context *context,
{
// No conversion needed-- use copyback fastpath
const TextureHelper11 *stagingTexture = nullptr;
unsigned int stagingSubresourceIndex = 0;
unsigned int stagingSubresourceIndex = 0;
ANGLE_TRY(getStagingTexture(context, &stagingTexture, &stagingSubresourceIndex));
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
......@@ -634,7 +634,7 @@ angle::Result Image11::map(const gl::Context *context,
ANGLE_TRY(recoverFromAssociatedStorage(context));
const TextureHelper11 *stagingTexture = nullptr;
unsigned int subresourceIndex = 0;
unsigned int subresourceIndex = 0;
ANGLE_TRY(getStagingTexture(context, &stagingTexture, &subresourceIndex));
ASSERT(stagingTexture && stagingTexture->valid());
......
......@@ -1321,9 +1321,9 @@ angle::Result TextureStorage11_2D::createUAVForImage(const gl::Context *context,
{
ASSERT(outUAV);
D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc;
uavDesc.Format = format;
uavDesc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
uavDesc.Texture2D.MipSlice = mTopLevel + level;
uavDesc.Format = format;
uavDesc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
uavDesc.Texture2D.MipSlice = mTopLevel + level;
ANGLE_TRY(
mRenderer->allocateResource(GetImplAs<Context11>(context), uavDesc, texture.get(), outUAV));
outUAV->setDebugName("TexStorage2D.UAVForImage");
......
......@@ -22,14 +22,14 @@
namespace
{
// 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/componentmaskps.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[] = {
g_vs20_standardvs,
......@@ -88,13 +88,7 @@ angle::Result Blit9::initialize(Context9 *context9)
return angle::Result::Continue();
}
static const float quad[] =
{
-1, -1,
-1, 1,
1, -1,
1, 1
};
static const float quad[] = {-1, -1, -1, 1, 1, -1, 1, 1};
IDirect3DDevice9 *device = mRenderer->getDevice();
......@@ -104,7 +98,7 @@ angle::Result Blit9::initialize(Context9 *context9)
ANGLE_TRY_HR(context9, result, "Failed to create internal blit vertex shader");
void *lockPtr = nullptr;
result = mQuadVertexBuffer->Lock(0, 0, &lockPtr, 0);
result = mQuadVertexBuffer->Lock(0, 0, &lockPtr, 0);
ANGLE_TRY_HR(context9, result, "Failed to lock internal blit vertex shader");
ASSERT(lockPtr);
......@@ -112,11 +106,8 @@ angle::Result Blit9::initialize(Context9 *context9)
memcpy(lockPtr, quad, sizeof(quad));
mQuadVertexBuffer->Unlock();
static const D3DVERTEXELEMENT9 elements[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
D3DDECL_END()
};
static const D3DVERTEXELEMENT9 elements[] = {
{0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, D3DDECL_END()};
result = device->CreateVertexDeclaration(elements, &mQuadVertexDeclaration);
ANGLE_TRY_HR(context9, result, "Failed to create internal blit vertex shader declaration");
......@@ -141,12 +132,12 @@ angle::Result Blit9::setShader(Context9 *context9,
if (mCompiledShaders[source] != nullptr)
{
shader = static_cast<D3DShaderType*>(mCompiledShaders[source]);
shader = static_cast<D3DShaderType *>(mCompiledShaders[source]);
}
else
{
const BYTE* shaderCode = g_shaderCode[source];
size_t shaderSize = g_shaderSize[source];
const BYTE *shaderCode = g_shaderCode[source];
size_t shaderSize = g_shaderSize[source];
ANGLE_TRY((mRenderer->*createShader)(context9, reinterpret_cast<const DWORD *>(shaderCode),
shaderSize, &shader));
mCompiledShaders[source] = shader;
......@@ -177,9 +168,9 @@ RECT Blit9::getSurfaceRect(IDirect3DSurface9 *surface) const
surface->GetDesc(&desc);
RECT rect;
rect.left = 0;
rect.top = 0;
rect.right = desc.Width;
rect.left = 0;
rect.top = 0;
rect.right = desc.Width;
rect.bottom = desc.Height;
return rect;
......@@ -249,7 +240,7 @@ angle::Result Blit9::copy2D(const gl::Context *context,
ASSERT(source);
angle::ComPtr<IDirect3DSurface9> destSurface = nullptr;
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
ANGLE_TRY(
storage9->getSurfaceLevel(context, gl::TextureTarget::_2D, level, true, &destSurface));
ASSERT(destSurface);
......@@ -283,7 +274,7 @@ angle::Result Blit9::copyCube(const gl::Context *context,
ASSERT(source);
angle::ComPtr<IDirect3DSurface9> destSurface = nullptr;
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
ANGLE_TRY(storage9->getSurfaceLevel(context, target, level, true, &destSurface));
ASSERT(destSurface);
......@@ -358,7 +349,9 @@ angle::Result Blit9::copy(Context9 *context9,
d3d9_gl::IsFormatChannelEquivalent(destDesc.Format, destFormat) && !flipY &&
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);
ANGLE_TRY_HR(context9, result, "StretchRect failed to blit between textures");
return angle::Result::Continue();
......@@ -440,138 +433,145 @@ angle::Result Blit9::setFormatConvertShaders(Context9 *context9,
switch (destFormat)
{
case GL_RGBA:
case GL_BGRA_EXT:
case GL_RGB:
case GL_RG_EXT:
case GL_RED_EXT:
case GL_ALPHA:
if (premultiplyAlpha == unmultiplyAlpha)
{
ANGLE_TRY(setPixelShader(context9, SHADER_PS_COMPONENTMASK));
}
else if (premultiplyAlpha)
{
ANGLE_TRY(setPixelShader(context9, SHADER_PS_COMPONENTMASK_PREMULTIPLY_ALPHA));
}
else
{
ASSERT(unmultiplyAlpha);
ANGLE_TRY(setPixelShader(context9, SHADER_PS_COMPONENTMASK_UNMULTIPLY_ALPHA));
}
break;
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
if (premultiplyAlpha == unmultiplyAlpha)
{
ANGLE_TRY(setPixelShader(context9, SHADER_PS_LUMINANCE));
}
else if (premultiplyAlpha)
{
ANGLE_TRY(setPixelShader(context9, SHADER_PS_LUMINANCE_PREMULTIPLY_ALPHA));
}
else
{
ASSERT(unmultiplyAlpha);
ANGLE_TRY(setPixelShader(context9, SHADER_PS_LUMINANCE_UNMULTIPLY_ALPHA));
}
break;
default:
UNREACHABLE();
case GL_RGBA:
case GL_BGRA_EXT:
case GL_RGB:
case GL_RG_EXT:
case GL_RED_EXT:
case GL_ALPHA:
if (premultiplyAlpha == unmultiplyAlpha)
{
ANGLE_TRY(setPixelShader(context9, SHADER_PS_COMPONENTMASK));
}
else if (premultiplyAlpha)
{
ANGLE_TRY(setPixelShader(context9, SHADER_PS_COMPONENTMASK_PREMULTIPLY_ALPHA));
}
else
{
ASSERT(unmultiplyAlpha);
ANGLE_TRY(setPixelShader(context9, SHADER_PS_COMPONENTMASK_UNMULTIPLY_ALPHA));
}
break;
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
if (premultiplyAlpha == unmultiplyAlpha)
{
ANGLE_TRY(setPixelShader(context9, SHADER_PS_LUMINANCE));
}
else if (premultiplyAlpha)
{
ANGLE_TRY(setPixelShader(context9, SHADER_PS_LUMINANCE_PREMULTIPLY_ALPHA));
}
else
{
ASSERT(unmultiplyAlpha);
ANGLE_TRY(setPixelShader(context9, SHADER_PS_LUMINANCE_UNMULTIPLY_ALPHA));
}
break;
default:
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.
// See the shader assembly code above for details.
// 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 *addConst = &psConst[4];
float *addConst = &psConst[4];
switch (destFormat)
{
case GL_RGBA:
case GL_BGRA_EXT:
multConst[X] = 1;
multConst[Y] = 1;
multConst[Z] = 1;
multConst[W] = 1;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 0;
break;
case GL_RGB:
multConst[X] = 1;
multConst[Y] = 1;
multConst[Z] = 1;
multConst[W] = 0;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 1;
break;
case GL_RG_EXT:
multConst[X] = 1;
multConst[Y] = 1;
multConst[Z] = 0;
multConst[W] = 0;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 1;
break;
case GL_RED_EXT:
multConst[X] = 1;
multConst[Y] = 0;
multConst[Z] = 0;
multConst[W] = 0;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 1;
break;
case GL_ALPHA:
multConst[X] = 0;
multConst[Y] = 0;
multConst[Z] = 0;
multConst[W] = 1;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 0;
break;
case GL_LUMINANCE:
multConst[X] = 1;
multConst[Y] = 0;
multConst[Z] = 0;
multConst[W] = 0;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 1;
break;
case GL_LUMINANCE_ALPHA:
multConst[X] = 1;
multConst[Y] = 0;
multConst[Z] = 0;
multConst[W] = 1;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 0;
break;
default: UNREACHABLE();
case GL_RGBA:
case GL_BGRA_EXT:
multConst[X] = 1;
multConst[Y] = 1;
multConst[Z] = 1;
multConst[W] = 1;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 0;
break;
case GL_RGB:
multConst[X] = 1;
multConst[Y] = 1;
multConst[Z] = 1;
multConst[W] = 0;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 1;
break;
case GL_RG_EXT:
multConst[X] = 1;
multConst[Y] = 1;
multConst[Z] = 0;
multConst[W] = 0;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 1;
break;
case GL_RED_EXT:
multConst[X] = 1;
multConst[Y] = 0;
multConst[Z] = 0;
multConst[W] = 0;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 1;
break;
case GL_ALPHA:
multConst[X] = 0;
multConst[Y] = 0;
multConst[Z] = 0;
multConst[W] = 1;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 0;
break;
case GL_LUMINANCE:
multConst[X] = 1;
multConst[Y] = 0;
multConst[Z] = 0;
multConst[W] = 0;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 1;
break;
case GL_LUMINANCE_ALPHA:
multConst[X] = 1;
multConst[Y] = 0;
multConst[Z] = 0;
multConst[W] = 1;
addConst[X] = 0;
addConst[Y] = 0;
addConst[Z] = 0;
addConst[W] = 0;
break;
default:
UNREACHABLE();
}
mRenderer->getDevice()->SetPixelShaderConstantF(0, psConst, 2);
......@@ -652,7 +652,9 @@ void Blit9::setCommonBlitState()
device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
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_SCISSORTESTENABLE, FALSE);
......@@ -662,10 +664,11 @@ void Blit9::setCommonBlitState()
device->SetSamplerState(0, D3DSAMP_ADDRESSU, 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);
for(int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
device->SetStreamSourceFreq(i, 1);
}
......@@ -676,7 +679,7 @@ void Blit9::render()
IDirect3DDevice9 *device = mRenderer->getDevice();
HRESULT hr = device->SetStreamSource(0, mQuadVertexBuffer, 0, 2 * sizeof(float));
hr = device->SetVertexDeclaration(mQuadVertexDeclaration);
hr = device->SetVertexDeclaration(mQuadVertexDeclaration);
mRenderer->startScene();
hr = device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
......@@ -698,7 +701,7 @@ void Blit9::saveState()
setCommonBlitState();
static const float dummyConst[8] = { 0 };
static const float dummyConst[8] = {0};
device->SetVertexShader(nullptr);
device->SetVertexShaderConstantF(0, dummyConst, 2);
......@@ -706,12 +709,12 @@ void Blit9::saveState()
device->SetPixelShaderConstantF(0, dummyConst, 2);
D3DVIEWPORT9 dummyVp;
dummyVp.X = 0;
dummyVp.Y = 0;
dummyVp.Width = 1;
dummyVp.X = 0;
dummyVp.Y = 0;
dummyVp.Width = 1;
dummyVp.Height = 1;
dummyVp.MinZ = 0;
dummyVp.MaxZ = 1;
dummyVp.MinZ = 0;
dummyVp.MaxZ = 1;
device->SetViewport(&dummyVp);
......@@ -751,5 +754,4 @@ void Blit9::restoreState()
mSavedStateBlock->Apply();
}
}
}
......@@ -198,12 +198,12 @@ angle::Result Framebuffer9::readPixelsImpl(const gl::Context *context,
gl::FormatType formatType(format, type);
PackPixelsParams packParams;
packParams.area.x = rect.left;
packParams.area.y = rect.top;
packParams.area.width = rect.right - rect.left;
packParams.area.height = rect.bottom - rect.top;
packParams.destFormat = &GetFormatFromFormatType(format, type);
packParams.outputPitch = static_cast<GLuint>(outputPitch);
packParams.area.x = rect.left;
packParams.area.y = rect.top;
packParams.area.width = rect.right - rect.left;
packParams.area.height = rect.bottom - rect.top;
packParams.destFormat = &GetFormatFromFormatType(format, type);
packParams.outputPitch = static_cast<GLuint>(outputPitch);
packParams.reverseRowOrder = pack.reverseRowOrder;
PackPixels(packParams, d3dFormatInfo.info(), inputPitch, source, pixels);
......
......@@ -31,7 +31,7 @@ Image9::Image9(Renderer9 *renderer)
mSurface = nullptr;
mRenderer = nullptr;
mD3DPool = D3DPOOL_SYSTEMMEM;
mD3DPool = D3DPOOL_SYSTEMMEM;
mD3DFormat = D3DFMT_UNKNOWN;
mRenderer = renderer;
......@@ -113,7 +113,7 @@ angle::Result Image9::CopyLockableSurfaces(Context9 *context9,
IDirect3DSurface9 *source)
{
D3DLOCKED_RECT sourceLock = {0};
D3DLOCKED_RECT destLock = {0};
D3DLOCKED_RECT destLock = {0};
HRESULT result;
......@@ -133,15 +133,16 @@ angle::Result Image9::CopyLockableSurfaces(Context9 *context9,
source->GetDesc(&desc);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
unsigned int rows = desc.Height / d3dFormatInfo.blockHeight;
unsigned int rows = desc.Height / d3dFormatInfo.blockHeight;
unsigned int bytes = d3d9::ComputeBlockSize(desc.Format, desc.Width, d3dFormatInfo.blockHeight);
ASSERT(bytes <= static_cast<unsigned int>(sourceLock.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();
......@@ -227,22 +228,19 @@ bool Image9::redefine(gl::TextureType type,
// Only 2D and cube texture are supported by the D3D9 backend.
ASSERT(type == gl::TextureType::_2D || type == gl::TextureType::CubeMap);
if (mWidth != size.width ||
mHeight != size.height ||
mDepth != size.depth ||
mInternalFormat != internalformat ||
forceRelease)
if (mWidth != size.width || mHeight != size.height || mDepth != size.depth ||
mInternalFormat != internalformat || forceRelease)
{
mWidth = size.width;
mHeight = size.height;
mDepth = size.depth;
mWidth = size.width;
mHeight = size.height;
mDepth = size.depth;
mType = type;
mInternalFormat = internalformat;
// compute the d3d format that will be used
const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(internalformat);
mD3DFormat = d3d9FormatInfo.texFormat;
mRenderable = (d3d9FormatInfo.renderFormat != D3DFMT_UNKNOWN);
mD3DFormat = d3d9FormatInfo.texFormat;
mRenderable = (d3d9FormatInfo.renderFormat != D3DFMT_UNKNOWN);
SafeRelease(mSurface);
mDirty = (d3d9FormatInfo.dataInitializerFunction != nullptr);
......@@ -262,13 +260,13 @@ angle::Result Image9::createSurface(Context9 *context9)
IDirect3DTexture9 *newTexture = nullptr;
IDirect3DSurface9 *newSurface = nullptr;
const D3DPOOL poolToUse = D3DPOOL_SYSTEMMEM;
const D3DFORMAT d3dFormat = getD3DFormat();
const D3DPOOL poolToUse = D3DPOOL_SYSTEMMEM;
const D3DFORMAT d3dFormat = getD3DFormat();
if (mWidth != 0 && mHeight != 0)
{
int levelToFetch = 0;
GLsizei requestWidth = mWidth;
int levelToFetch = 0;
GLsizei requestWidth = mWidth;
GLsizei requestHeight = mHeight;
d3d9::MakeValidSize(true, d3dFormat, &requestWidth, &requestHeight, &levelToFetch);
......@@ -286,9 +284,9 @@ angle::Result Image9::createSurface(Context9 *context9)
if (d3dFormatInfo.dataInitializerFunction != nullptr)
{
RECT entireRect;
entireRect.left = 0;
entireRect.right = mWidth;
entireRect.top = 0;
entireRect.left = 0;
entireRect.right = mWidth;
entireRect.top = 0;
entireRect.bottom = mHeight;
D3DLOCKED_RECT lockedRect;
......@@ -306,7 +304,7 @@ angle::Result Image9::createSurface(Context9 *context9)
}
mSurface = newSurface;
mDirty = false;
mDirty = false;
mD3DPool = poolToUse;
return angle::Result::Continue();
......@@ -347,8 +345,8 @@ D3DFORMAT Image9::getD3DFormat() 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
// if initialization is required before use.
// Make sure to that this image is marked as dirty even if the staging texture hasn't been
// created yet if initialization is required before use.
return (mSurface ||
d3d9::GetTextureFormatInfo(mInternalFormat).dataInitializerFunction != nullptr) &&
mDirty;
......@@ -377,7 +375,7 @@ angle::Result Image9::setManagedSurfaceCube(const gl::Context *context,
int level)
{
IDirect3DSurface9 *surface = nullptr;
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
ANGLE_TRY(storage9->getSurfaceLevel(context, gl::CubeFaceIndexToTextureTarget(face), level,
false, &surface));
return setManagedSurface(GetImplAs<Context9>(context), surface);
......@@ -412,7 +410,7 @@ angle::Result Image9::copyToStorage(const gl::Context *context,
{
ANGLE_TRY(createSurface(GetImplAs<Context9>(context)));
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
IDirect3DSurface9 *destSurface = nullptr;
ANGLE_TRY(storage9->getSurfaceLevel(context, index.getTarget(), index.getLevelIndex(), true,
&destSurface));
......@@ -435,9 +433,9 @@ angle::Result Image9::copyToSurface(Context9 *context9,
ASSERT(sourceSurface && sourceSurface != destSurface);
RECT rect;
rect.left = area.x;
rect.top = area.y;
rect.right = area.x + area.width;
rect.left = area.x;
rect.top = area.y;
rect.right = area.x + area.width;
rect.bottom = area.y + area.height;
POINT point = {rect.left, rect.top};
......@@ -455,7 +453,7 @@ angle::Result Image9::copyToSurface(Context9 *context9,
ANGLE_TRY_HR(context9, result, "Internal CreateOffscreenPlainSurface call failed");
auto err = CopyLockableSurfaces(context9, surf, sourceSurface);
result = device->UpdateSurface(surf, &rect, destSurface, &point);
result = device->UpdateSurface(surf, &rect, destSurface, &point);
SafeRelease(surf);
ANGLE_TRY(err);
ASSERT(SUCCEEDED(result));
......@@ -472,8 +470,8 @@ angle::Result Image9::copyToSurface(Context9 *context9,
return angle::Result::Continue();
}
// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
// into the target pixel rectangle.
// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as
// format/type at input into the target pixel rectangle.
angle::Result Image9::loadData(const gl::Context *context,
const gl::Box &area,
const gl::PixelUnpackState &unpack,
......@@ -497,11 +495,7 @@ angle::Result Image9::loadData(const gl::Context *context,
const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
ASSERT(d3dFormatInfo.loadFunction != nullptr);
RECT lockRect =
{
area.x, area.y,
area.x + area.width, area.y + area.height
};
RECT lockRect = {area.x, area.y, area.x + area.width, area.y + area.height};
D3DLOCKED_RECT locked;
ANGLE_TRY(lock(GetImplAs<Context9>(context), &locked, lockRect));
......@@ -540,11 +534,7 @@ angle::Result Image9::loadCompressedData(const gl::Context *context,
ASSERT(d3d9FormatInfo.loadFunction != nullptr);
RECT lockRect =
{
area.x, area.y,
area.x + area.width, area.y + area.height
};
RECT lockRect = {area.x, area.y, area.x + area.width, area.y + area.height};
D3DLOCKED_RECT locked;
ANGLE_TRY(lock(GetImplAs<Context9>(context), &locked, lockRect));
......@@ -558,7 +548,8 @@ angle::Result Image9::loadCompressedData(const gl::Context *context,
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,
const gl::Offset &destOffset,
const gl::Rectangle &sourceArea,
......@@ -590,11 +581,11 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9,
ANGLE_TRY_HR(context9, hr, "GetRenderTargetData unexpectedly failed");
int width = sourceArea.width;
int width = sourceArea.width;
int height = sourceArea.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 sourceRect = {sourceArea.x, sourceArea.y, sourceArea.x + width, sourceArea.y + height};
RECT destRect = {destOffset.x, destOffset.y, destOffset.x + width, destOffset.y + height};
D3DLOCKED_RECT sourceLock = {0};
hr = renderTargetData->LockRect(&sourceLock, &sourceRect, 0);
......@@ -611,159 +602,159 @@ angle::Result Image9::copyFromRTInternal(Context9 *context9,
ASSERT(destLock.pBits && sourceLock.pBits);
unsigned char *sourcePixels = (unsigned char*)sourceLock.pBits;
unsigned char *destPixels = (unsigned char*)destLock.pBits;
unsigned char *sourcePixels = (unsigned char *)sourceLock.pBits;
unsigned char *destPixels = (unsigned char *)destLock.pBits;
switch (description.Format)
{
case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8:
switch (getD3DFormat())
{
case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8:
for (int y = 0; y < height; y++)
{
memcpy(destPixels, sourcePixels, 4 * width);
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_L8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
destPixels[x] = sourcePixels[x * 4 + 2];
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_A8L8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
destPixels[x * 2 + 0] = sourcePixels[x * 4 + 2];
destPixels[x * 2 + 1] = sourcePixels[x * 4 + 3];
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
default:
UNREACHABLE();
}
break;
case D3DFMT_R5G6B5:
switch (getD3DFormat())
{
case D3DFMT_X8R8G8B8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned short rgb = ((unsigned short*)sourcePixels)[x];
unsigned char red = static_cast<unsigned char>((rgb & 0xF800) >> 8);
unsigned char green = static_cast<unsigned char>((rgb & 0x07E0) >> 3);
unsigned char blue = static_cast<unsigned char>((rgb & 0x001F) << 3);
destPixels[x + 0] = blue | (blue >> 5);
destPixels[x + 1] = green | (green >> 6);
destPixels[x + 2] = red | (red >> 5);
destPixels[x + 3] = 0xFF;
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_L8:
for (int y = 0; y < height; y++)
case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8:
switch (getD3DFormat())
{
for (int x = 0; x < width; x++)
{
unsigned char red = sourcePixels[x * 2 + 1] & 0xF8;
destPixels[x] = red | (red >> 5);
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8:
for (int y = 0; y < height; y++)
{
memcpy(destPixels, sourcePixels, 4 * width);
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_L8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
destPixels[x] = sourcePixels[x * 4 + 2];
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_A8L8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
destPixels[x * 2 + 0] = sourcePixels[x * 4 + 2];
destPixels[x * 2 + 1] = sourcePixels[x * 4 + 3];
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
default:
UNREACHABLE();
}
break;
default:
UNREACHABLE();
}
break;
case D3DFMT_A1R5G5B5:
switch (getD3DFormat())
{
case D3DFMT_X8R8G8B8:
for (int y = 0; y < height; y++)
case D3DFMT_R5G6B5:
switch (getD3DFormat())
{
for (int x = 0; x < width; x++)
{
unsigned short argb = ((unsigned short*)sourcePixels)[x];
unsigned char red = static_cast<unsigned char>((argb & 0x7C00) >> 7);
unsigned char green = static_cast<unsigned char>((argb & 0x03E0) >> 2);
unsigned char blue = static_cast<unsigned char>((argb & 0x001F) << 3);
destPixels[x + 0] = blue | (blue >> 5);
destPixels[x + 1] = green | (green >> 5);
destPixels[x + 2] = red | (red >> 5);
destPixels[x + 3] = 0xFF;
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
case D3DFMT_X8R8G8B8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned short rgb = ((unsigned short *)sourcePixels)[x];
unsigned char red = static_cast<unsigned char>((rgb & 0xF800) >> 8);
unsigned char green = static_cast<unsigned char>((rgb & 0x07E0) >> 3);
unsigned char blue = static_cast<unsigned char>((rgb & 0x001F) << 3);
destPixels[x + 0] = blue | (blue >> 5);
destPixels[x + 1] = green | (green >> 6);
destPixels[x + 2] = red | (red >> 5);
destPixels[x + 3] = 0xFF;
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_L8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned char red = sourcePixels[x * 2 + 1] & 0xF8;
destPixels[x] = red | (red >> 5);
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
default:
UNREACHABLE();
}
break;
case D3DFMT_A8R8G8B8:
for (int y = 0; y < height; y++)
case D3DFMT_A1R5G5B5:
switch (getD3DFormat())
{
for (int x = 0; x < width; x++)
{
unsigned short argb = ((unsigned short*)sourcePixels)[x];
unsigned char red = static_cast<unsigned char>((argb & 0x7C00) >> 7);
unsigned char green = static_cast<unsigned char>((argb & 0x03E0) >> 2);
unsigned char blue = static_cast<unsigned char>((argb & 0x001F) << 3);
unsigned char alpha = (signed short)argb >> 15;
destPixels[x + 0] = blue | (blue >> 5);
destPixels[x + 1] = green | (green >> 5);
destPixels[x + 2] = red | (red >> 5);
destPixels[x + 3] = alpha;
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
case D3DFMT_X8R8G8B8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned short argb = ((unsigned short *)sourcePixels)[x];
unsigned char red = static_cast<unsigned char>((argb & 0x7C00) >> 7);
unsigned char green = static_cast<unsigned char>((argb & 0x03E0) >> 2);
unsigned char blue = static_cast<unsigned char>((argb & 0x001F) << 3);
destPixels[x + 0] = blue | (blue >> 5);
destPixels[x + 1] = green | (green >> 5);
destPixels[x + 2] = red | (red >> 5);
destPixels[x + 3] = 0xFF;
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_A8R8G8B8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned short argb = ((unsigned short *)sourcePixels)[x];
unsigned char red = static_cast<unsigned char>((argb & 0x7C00) >> 7);
unsigned char green = static_cast<unsigned char>((argb & 0x03E0) >> 2);
unsigned char blue = static_cast<unsigned char>((argb & 0x001F) << 3);
unsigned char alpha = (signed short)argb >> 15;
destPixels[x + 0] = blue | (blue >> 5);
destPixels[x + 1] = green | (green >> 5);
destPixels[x + 2] = red | (red >> 5);
destPixels[x + 3] = alpha;
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_L8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned char red = sourcePixels[x * 2 + 1] & 0x7C;
destPixels[x] = (red << 1) | (red >> 4);
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_A8L8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned char red = sourcePixels[x * 2 + 1] & 0x7C;
destPixels[x * 2 + 0] = (red << 1) | (red >> 4);
destPixels[x * 2 + 1] = (signed char)sourcePixels[x * 2 + 1] >> 7;
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
default:
UNREACHABLE();
}
break;
case D3DFMT_L8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned char red = sourcePixels[x * 2 + 1] & 0x7C;
destPixels[x] = (red << 1) | (red >> 4);
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
case D3DFMT_A8L8:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned char red = sourcePixels[x * 2 + 1] & 0x7C;
destPixels[x * 2 + 0] = (red << 1) | (red >> 4);
destPixels[x * 2 + 1] = (signed char)sourcePixels[x * 2 + 1] >> 7;
}
sourcePixels += sourceLock.Pitch;
destPixels += destLock.Pitch;
}
break;
default:
default:
UNREACHABLE();
}
break;
default:
UNREACHABLE();
}
unlock();
......
......@@ -80,8 +80,9 @@ angle::Result RenderbufferGL::setStorageMultisample(const gl::Context *context,
const gl::TextureCaps &formatCaps = mTextureCaps.get(internalformat);
if (samples > formatCaps.getMaxSamples())
{
// Before version 4.2, it is unknown if the specific internal format can support the requested number
// of samples. It is expected that GL_OUT_OF_MEMORY is returned if the renderbuffer cannot be created.
// Before version 4.2, it is unknown if the specific internal format can support the
// 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;
do
{
......
......@@ -9,9 +9,9 @@
#ifndef LIBANGLE_RENDERER_GL_TEXTUREGL_H_
#define LIBANGLE_RENDERER_GL_TEXTUREGL_H_
#include "libANGLE/Texture.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/TextureImpl.h"
#include "libANGLE/Texture.h"
namespace rx
{
......@@ -246,7 +246,6 @@ class TextureGL : public TextureImpl
GLuint mTextureID;
};
}
#endif // LIBANGLE_RENDERER_GL_TEXTUREGL_H_
#endif // LIBANGLE_RENDERER_GL_TEXTUREGL_H_
......@@ -86,7 +86,7 @@ VertexArrayGL::~VertexArrayGL()
void VertexArrayGL::destroy(const gl::Context *context)
{
mStateManager->deleteVertexArray(mVertexArrayID);
mVertexArrayID = 0;
mVertexArrayID = 0;
mAppliedNumViews = 1;
mStateManager->deleteBuffer(mStreamingElementArrayBuffer);
......@@ -276,7 +276,7 @@ void VertexArrayGL::computeStreamingAttributeSizes(const gl::AttributesMask &att
// If streaming is going to be required, compute the size of the required buffer
// and how much slack space at the beginning of the buffer will be required by determining
// the attribute with the largest data size.
size_t typeSize = ComputeVertexAttributeTypeSize(attrib);
size_t typeSize = ComputeVertexAttributeTypeSize(attrib);
GLuint adjustedDivisor = GetAdjustedDivisor(mAppliedNumViews, binding.getDivisor());
*outStreamingDataSize +=
typeSize * ComputeVertexBindingElementCount(adjustedDivisor, indexRange.vertexCount(),
......@@ -338,7 +338,7 @@ angle::Result VertexArrayGL::streamAttributes(const gl::Context *context,
for (auto idx : attribsToStream)
{
const auto &attrib = attribs[idx];
const auto &attrib = attribs[idx];
ASSERT(IsVertexAttribPointerSupported(idx, attrib));
const auto &binding = bindings[attrib.bindingIndex];
......@@ -729,7 +729,7 @@ void VertexArrayGL::applyNumViewsToDivisor(int numViews)
void VertexArrayGL::applyActiveAttribLocationsMask(const gl::AttributesMask &activeMask)
{
gl::AttributesMask updateMask = mProgramActiveAttribLocationsMask ^ activeMask;
gl::AttributesMask updateMask = mProgramActiveAttribLocationsMask ^ activeMask;
if (!updateMask.any())
{
return;
......
......@@ -25,7 +25,7 @@ QueryVk::~QueryVk() = default;
void QueryVk::onDestroy(const gl::Context *context)
{
ContextVk *contextVk = vk::GetImpl(context);
ContextVk *contextVk = vk::GetImpl(context);
vk::DynamicQueryPool *queryPool = contextVk->getQueryPool(getType());
queryPool->freeQuery(contextVk, &mQueryHelper);
queryPool->freeQuery(contextVk, &mQueryHelperTimeElapsedBegin);
......
......@@ -8,12 +8,12 @@
// vertex buffer.
//
#include "libANGLE/angletypes.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/Context11.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/IndexDataManager.h"
#include "test_utils/ANGLETest.h"
#include "test_utils/angle_test_instantiate.h"
......@@ -25,7 +25,6 @@ namespace
class D3D11EmulatedIndexedBufferTest : public ANGLETest
{
protected:
void SetUp() override
{
ANGLETest::SetUp();
......@@ -35,15 +34,15 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest
rx::Context11 *context11 = rx::GetImplAs<rx::Context11>(mContext);
mRenderer = context11->getRenderer();
mSourceBuffer = new rx::Buffer11(mBufferState, mRenderer);
GLfloat testData[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f };
mSourceBuffer = new rx::Buffer11(mBufferState, mRenderer);
GLfloat testData[] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
angle::Result error = mSourceBuffer->setData(nullptr, gl::BufferBinding::Array, testData,
sizeof(testData), gl::BufferUsage::StaticDraw);
ASSERT_EQ(angle::Result::Continue(), error);
mTranslatedAttribute.baseOffset = 0;
mTranslatedAttribute.usesFirstVertexOffset = false;
mTranslatedAttribute.stride = sizeof(GLfloat);
mTranslatedAttribute.stride = sizeof(GLfloat);
GLubyte indices[] = {0, 0, 3, 4, 2, 1, 1};
......@@ -62,30 +61,33 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest
ANGLETest::TearDown();
}
void createMappableCompareBufferFromEmulatedBuffer(ID3D11Buffer *sourceBuffer, GLuint size, ID3D11Buffer **mappableBuffer)
void createMappableCompareBufferFromEmulatedBuffer(ID3D11Buffer *sourceBuffer,
GLuint size,
ID3D11Buffer **mappableBuffer)
{
*mappableBuffer = nullptr;
D3D11_BUFFER_DESC bufferDesc;
bufferDesc.ByteWidth = size;
bufferDesc.MiscFlags = 0;
bufferDesc.ByteWidth = size;
bufferDesc.MiscFlags = 0;
bufferDesc.StructureByteStride = 0;
bufferDesc.Usage = D3D11_USAGE_STAGING;
bufferDesc.BindFlags = 0;
bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
bufferDesc.Usage = D3D11_USAGE_STAGING;
bufferDesc.BindFlags = 0;
bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
HRESULT hr = mRenderer->getDevice()->CreateBuffer(&bufferDesc, nullptr, mappableBuffer);
ASSERT_TRUE(SUCCEEDED(hr));
D3D11_BOX srcBox;
srcBox.left = 0;
srcBox.right = size;
srcBox.top = 0;
srcBox.left = 0;
srcBox.right = size;
srcBox.top = 0;
srcBox.bottom = 1;
srcBox.front = 0;
srcBox.back = 1;
srcBox.front = 0;
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)
......@@ -96,10 +98,11 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest
&compareBuffer);
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));
GLfloat* compareData = static_cast<GLfloat*>(mappedResource.pData);
GLfloat *compareData = static_cast<GLfloat *>(mappedResource.pData);
for (size_t i = 0; i < mExpectedExpandedData.size(); i++)
{
EXPECT_EQ(mExpectedExpandedData[i], compareData[i]);
......@@ -161,7 +164,8 @@ TEST_P(D3D11EmulatedIndexedBufferTest, TestNativeToExpandedUsingGLuintIndices)
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)
{
// Copy the original source buffer before any expand calls have been made
......@@ -178,7 +182,7 @@ TEST_P(D3D11EmulatedIndexedBufferTest, TestSourceBufferRemainsUntouchedAfterExpa
emulateAndCompare(&srcData);
const uint8_t *sourceBufferMem = nullptr;
const uint8_t *cleanBufferMem = nullptr;
const uint8_t *cleanBufferMem = nullptr;
angle::Result error = mSourceBuffer->getData(mContext, &sourceBufferMem);
ASSERT_EQ(angle::Result::Continue(), error);
......@@ -192,7 +196,6 @@ TEST_P(D3D11EmulatedIndexedBufferTest, TestSourceBufferRemainsUntouchedAfterExpa
SafeDelete(cleanSourceBuffer);
}
ANGLE_INSTANTIATE_TEST(D3D11EmulatedIndexedBufferTest,
ES2_D3D11());
ANGLE_INSTANTIATE_TEST(D3D11EmulatedIndexedBufferTest, 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