summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp')
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp201
1 files changed, 82 insertions, 119 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp
index 9c269a8565..dff12e03f8 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp
@@ -7,21 +7,25 @@
// Framebuffer9.cpp: Implements the Framebuffer9 class.
#include "libANGLE/renderer/d3d/d3d9/Framebuffer9.h"
-#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
-#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h"
-#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
-#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
-#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
-#include "libANGLE/renderer/d3d/TextureD3D.h"
-#include "libANGLE/formatutils.h"
+
+#include "libANGLE/Context.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Texture.h"
+#include "libANGLE/formatutils.h"
+#include "libANGLE/renderer/ContextImpl.h"
+#include "libANGLE/renderer/d3d/TextureD3D.h"
+#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
+#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
+#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h"
+#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
+#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
+#include "libANGLE/renderer/renderer_utils.h"
namespace rx
{
-Framebuffer9::Framebuffer9(const gl::Framebuffer::Data &data, Renderer9 *renderer)
+Framebuffer9::Framebuffer9(const gl::FramebufferState &data, Renderer9 *renderer)
: FramebufferD3D(data, renderer), mRenderer(renderer)
{
ASSERT(mRenderer != nullptr);
@@ -31,66 +35,61 @@ Framebuffer9::~Framebuffer9()
{
}
-gl::Error Framebuffer9::discard(size_t, const GLenum *)
+gl::Error Framebuffer9::discard(const gl::Context *context, size_t, const GLenum *)
{
// Extension not implemented in D3D9 renderer
UNREACHABLE();
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
-gl::Error Framebuffer9::invalidate(size_t, const GLenum *)
+gl::Error Framebuffer9::invalidate(const gl::Context *context, size_t, const GLenum *)
{
// Shouldn't ever reach here in D3D9
UNREACHABLE();
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
-gl::Error Framebuffer9::invalidateSub(size_t, const GLenum *, const gl::Rectangle &)
+gl::Error Framebuffer9::invalidateSub(const gl::Context *context,
+ size_t,
+ const GLenum *,
+ const gl::Rectangle &)
{
// Shouldn't ever reach here in D3D9
UNREACHABLE();
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
-gl::Error Framebuffer9::clear(const gl::Data &data, const ClearParameters &clearParams)
+gl::Error Framebuffer9::clearImpl(const gl::Context *context, const ClearParameters &clearParams)
{
- const gl::FramebufferAttachment *colorAttachment = mData.getColorAttachment(0);
- const gl::FramebufferAttachment *depthStencilAttachment = mData.getDepthOrStencilAttachment();
+ const gl::FramebufferAttachment *colorAttachment = mState.getColorAttachment(0);
+ const gl::FramebufferAttachment *depthStencilAttachment = mState.getDepthOrStencilAttachment();
- gl::Error error = mRenderer->applyRenderTarget(colorAttachment, depthStencilAttachment);
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(mRenderer->applyRenderTarget(context, colorAttachment, depthStencilAttachment));
- float nearZ = data.state->getNearPlane();
- float farZ = data.state->getFarPlane();
- mRenderer->setViewport(data.caps, data.state->getViewport(), nearZ, farZ, GL_TRIANGLES,
- data.state->getRasterizerState().frontFace, true);
+ const gl::State &glState = context->getGLState();
+ float nearZ = glState.getNearPlane();
+ float farZ = glState.getFarPlane();
+ mRenderer->setViewport(glState.getViewport(), nearZ, farZ, GL_TRIANGLES,
+ glState.getRasterizerState().frontFace, true);
- mRenderer->setScissorRectangle(data.state->getScissor(), data.state->isScissorTestEnabled());
+ mRenderer->setScissorRectangle(glState.getScissor(), glState.isScissorTestEnabled());
- return mRenderer->clear(clearParams, colorAttachment, depthStencilAttachment);
+ return mRenderer->clear(context, clearParams, colorAttachment, depthStencilAttachment);
}
-gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area,
+gl::Error Framebuffer9::readPixelsImpl(const gl::Context *context,
+ const gl::Rectangle &area,
GLenum format,
GLenum type,
size_t outputPitch,
const gl::PixelPackState &pack,
- uint8_t *pixels) const
+ uint8_t *pixels)
{
- ASSERT(pack.pixelBuffer.get() == nullptr);
-
- const gl::FramebufferAttachment *colorbuffer = mData.getColorAttachment(0);
+ const gl::FramebufferAttachment *colorbuffer = mState.getColorAttachment(0);
ASSERT(colorbuffer);
RenderTarget9 *renderTarget = nullptr;
- gl::Error error = colorbuffer->getRenderTarget(&renderTarget);
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(colorbuffer->getRenderTarget(context, &renderTarget));
ASSERT(renderTarget);
IDirect3DSurface9 *surface = renderTarget->getSurface();
@@ -103,7 +102,8 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area,
{
UNIMPLEMENTED(); // FIXME: Requires resolve using StretchRect into non-multisampled render target
SafeRelease(surface);
- return gl::Error(GL_OUT_OF_MEMORY, "ReadPixels is unimplemented for multisampled framebuffer attachments.");
+ return gl::OutOfMemory()
+ << "ReadPixels is unimplemented for multisampled framebuffer attachments.";
}
IDirect3DDevice9 *device = mRenderer->getDevice();
@@ -135,7 +135,7 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area,
{
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
SafeRelease(surface);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal texture for ReadPixels.");
+ return gl::OutOfMemory() << "Failed to allocate internal texture for ReadPixels.";
}
}
@@ -157,13 +157,13 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area,
UNREACHABLE();
}
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to read internal render target data.");
+ return gl::OutOfMemory() << "Failed to read internal render target data.";
}
if (directToPixels)
{
SafeRelease(systemSurface);
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
RECT rect;
@@ -180,85 +180,42 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area,
UNREACHABLE();
SafeRelease(systemSurface);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal render target.");
+ return gl::OutOfMemory() << "Failed to lock internal render target.";
}
- uint8_t *source;
- int inputPitch;
- if (pack.reverseRowOrder)
- {
- source = reinterpret_cast<uint8_t*>(lock.pBits) + lock.Pitch * (rect.bottom - rect.top - 1);
- inputPitch = -lock.Pitch;
- }
- else
- {
- source = reinterpret_cast<uint8_t*>(lock.pBits);
- inputPitch = lock.Pitch;
- }
+ uint8_t *source = reinterpret_cast<uint8_t *>(lock.pBits);
+ int inputPitch = lock.Pitch;
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
- const gl::InternalFormat &sourceFormatInfo = gl::GetInternalFormatInfo(d3dFormatInfo.internalFormat);
- if (sourceFormatInfo.format == format && sourceFormatInfo.type == type)
- {
- // Direct copy possible
- for (int y = 0; y < rect.bottom - rect.top; y++)
- {
- memcpy(pixels + y * outputPitch, source + y * inputPitch, (rect.right - rect.left) * sourceFormatInfo.pixelBytes);
- }
- }
- else
- {
- const d3d9::D3DFormat &sourceD3DFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
- ColorCopyFunction fastCopyFunc = sourceD3DFormatInfo.getFastCopyFunction(format, type);
-
- GLenum sizedDestInternalFormat = gl::GetSizedInternalFormat(format, type);
- const gl::InternalFormat &destFormatInfo = gl::GetInternalFormatInfo(sizedDestInternalFormat);
-
- if (fastCopyFunc)
- {
- // Fast copy is possible through some special function
- for (int y = 0; y < rect.bottom - rect.top; y++)
- {
- for (int x = 0; x < rect.right - rect.left; x++)
- {
- uint8_t *dest = pixels + y * outputPitch + x * destFormatInfo.pixelBytes;
- const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
+ gl::FormatType formatType(format, type);
- fastCopyFunc(src, dest);
- }
- }
- }
- else
- {
- ColorReadFunction colorReadFunction = sourceD3DFormatInfo.colorReadFunction;
- ColorWriteFunction colorWriteFunction = GetColorWriteFunction(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.format = format;
+ packParams.type = type;
+ packParams.outputPitch = static_cast<GLuint>(outputPitch);
+ packParams.pack = pack;
- uint8_t temp[sizeof(gl::ColorF)];
- for (int y = 0; y < rect.bottom - rect.top; y++)
- {
- for (int x = 0; x < rect.right - rect.left; x++)
- {
- uint8_t *dest = pixels + y * outputPitch + x * destFormatInfo.pixelBytes;
- const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
-
- // readFunc and writeFunc will be using the same type of color, CopyTexImage
- // will not allow the copy otherwise.
- colorReadFunction(src, temp);
- colorWriteFunction(temp, dest);
- }
- }
- }
- }
+ PackPixels(packParams, d3dFormatInfo.info(), inputPitch, source, pixels);
systemSurface->UnlockRect();
SafeRelease(systemSurface);
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
-gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor,
- bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter,
- const gl::Framebuffer *sourceFramebuffer)
+gl::Error Framebuffer9::blitImpl(const gl::Context *context,
+ const gl::Rectangle &sourceArea,
+ const gl::Rectangle &destArea,
+ const gl::Rectangle *scissor,
+ bool blitRenderTarget,
+ bool blitDepth,
+ bool blitStencil,
+ GLenum filter,
+ const gl::Framebuffer *sourceFramebuffer)
{
ASSERT(filter == GL_NEAREST);
@@ -273,18 +230,18 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
ASSERT(readBuffer);
RenderTarget9 *readRenderTarget = nullptr;
- gl::Error error = readBuffer->getRenderTarget(&readRenderTarget);
+ gl::Error error = readBuffer->getRenderTarget(context, &readRenderTarget);
if (error.isError())
{
return error;
}
ASSERT(readRenderTarget);
- const gl::FramebufferAttachment *drawBuffer = mData.getColorAttachment(0);
+ const gl::FramebufferAttachment *drawBuffer = mState.getColorAttachment(0);
ASSERT(drawBuffer);
RenderTarget9 *drawRenderTarget = nullptr;
- error = drawBuffer->getRenderTarget(&drawRenderTarget);
+ error = drawBuffer->getRenderTarget(context, &drawRenderTarget);
if (error.isError())
{
return error;
@@ -389,7 +346,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Internal blit failed, StretchRect returned 0x%X.", result);
+ return gl::OutOfMemory() << "Internal blit failed, StretchRect " << gl::FmtHR(result);
}
}
@@ -399,18 +356,18 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
ASSERT(readBuffer);
RenderTarget9 *readDepthStencil = nullptr;
- gl::Error error = readBuffer->getRenderTarget(&readDepthStencil);
+ gl::Error error = readBuffer->getRenderTarget(context, &readDepthStencil);
if (error.isError())
{
return error;
}
ASSERT(readDepthStencil);
- const gl::FramebufferAttachment *drawBuffer = mData.getDepthOrStencilAttachment();
+ const gl::FramebufferAttachment *drawBuffer = mState.getDepthOrStencilAttachment();
ASSERT(drawBuffer);
RenderTarget9 *drawDepthStencil = nullptr;
- error = drawBuffer->getRenderTarget(&drawDepthStencil);
+ error = drawBuffer->getRenderTarget(context, &drawDepthStencil);
if (error.isError())
{
return error;
@@ -431,18 +388,24 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Internal blit failed, StretchRect returned 0x%X.", result);
+ return gl::OutOfMemory() << "Internal blit failed, StretchRect " << gl::FmtHR(result);
}
}
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
GLenum Framebuffer9::getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const
{
RenderTarget9 *renderTarget9 = GetAs<RenderTarget9>(renderTarget);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(renderTarget9->getD3DFormat());
- return d3dFormatInfo.internalFormat;
+ return d3dFormatInfo.info().glInternalFormat;
}
+gl::Error Framebuffer9::getSamplePosition(size_t index, GLfloat *xy) const
+{
+ UNREACHABLE();
+ return gl::InternalError() << "getSamplePosition is unsupported to d3d9.";
}
+
+} // namespace rx