summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp')
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp165
1 files changed, 90 insertions, 75 deletions
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp
index 13321ac8cd..53d1f752fa 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp
@@ -10,115 +10,83 @@
#include "libGLESv2/renderer/d3d/d3d9/RenderTarget9.h"
#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
+#include "libGLESv2/renderer/d3d/d3d9/SwapChain9.h"
#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
#include "libGLESv2/main.h"
namespace rx
{
+RenderTarget9 *RenderTarget9::makeRenderTarget9(RenderTarget *target)
+{
+ ASSERT(HAS_DYNAMIC_TYPE(RenderTarget9*, target));
+ return static_cast<RenderTarget9*>(target);
+}
+
+void RenderTarget9::invalidate(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ // Currently a no-op
+}
+
// TODO: AddRef the incoming surface to take ownership instead of expecting that its ref is being given.
-RenderTarget9::RenderTarget9(Renderer *renderer, IDirect3DSurface9 *surface)
+TextureRenderTarget9::TextureRenderTarget9(IDirect3DSurface9 *surface, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth,
+ GLsizei samples)
+ : mWidth(width),
+ mHeight(height),
+ mDepth(depth),
+ mInternalFormat(internalFormat),
+ mActualFormat(internalFormat),
+ mSamples(samples),
+ mRenderTarget(surface)
{
- mRenderer = Renderer9::makeRenderer9(renderer);
- mRenderTarget = surface;
+ ASSERT(mDepth == 1);
if (mRenderTarget)
{
D3DSURFACE_DESC description;
mRenderTarget->GetDesc(&description);
- mWidth = description.Width;
- mHeight = description.Height;
- mDepth = 1;
-
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(description.Format);
- mInternalFormat = d3dFormatInfo.internalFormat;
mActualFormat = d3dFormatInfo.internalFormat;
- mSamples = d3d9_gl::GetSamplesCount(description.MultiSampleType);
}
}
-RenderTarget9::RenderTarget9(Renderer *renderer, GLsizei width, GLsizei height, GLenum internalFormat, GLsizei samples)
+TextureRenderTarget9::~TextureRenderTarget9()
{
- mRenderer = Renderer9::makeRenderer9(renderer);
- mRenderTarget = NULL;
-
- const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(internalFormat);
- const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(d3d9FormatInfo.renderFormat);
-
- const gl::TextureCaps &textureCaps = mRenderer->getRendererTextureCaps().get(internalFormat);
- GLuint supportedSamples = textureCaps.getNearestSamples(samples);
+ SafeRelease(mRenderTarget);
+}
- HRESULT result = D3DERR_INVALIDCALL;
+GLsizei TextureRenderTarget9::getWidth() const
+{
+ return mWidth;
+}
- if (width > 0 && height > 0)
- {
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- bool requiresInitialization = false;
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
- if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
- {
- result = device->CreateDepthStencilSurface(width, height, d3d9FormatInfo.renderFormat,
- gl_d3d9::GetMultisampleType(supportedSamples),
- 0, FALSE, &mRenderTarget, NULL);
- }
- else
- {
- requiresInitialization = (d3d9FormatInfo.dataInitializerFunction != NULL);
- result = device->CreateRenderTarget(width, height, d3d9FormatInfo.renderFormat,
- gl_d3d9::GetMultisampleType(supportedSamples),
- 0, FALSE, &mRenderTarget, NULL);
- }
-
- if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
- {
- gl::error(GL_OUT_OF_MEMORY);
-
- return;
- }
-
- ASSERT(SUCCEEDED(result));
-
- if (requiresInitialization)
- {
- // This format requires that the data be initialized before the render target can be used
- // Unfortunately this requires a Get call on the d3d device but it is far better than having
- // to mark the render target as lockable and copy data to the gpu.
- IDirect3DSurface9 *prevRenderTarget = NULL;
- device->GetRenderTarget(0, &prevRenderTarget);
- device->SetRenderTarget(0, mRenderTarget);
- device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 255), 0.0f, 0);
- device->SetRenderTarget(0, prevRenderTarget);
- }
- }
+GLsizei TextureRenderTarget9::getHeight() const
+{
+ return mHeight;
+}
- mWidth = width;
- mHeight = height;
- mDepth = 1;
- mInternalFormat = internalFormat;
- mSamples = supportedSamples;
- mActualFormat = d3dFormatInfo.internalFormat;
+GLsizei TextureRenderTarget9::getDepth() const
+{
+ return mDepth;
}
-RenderTarget9::~RenderTarget9()
+GLenum TextureRenderTarget9::getInternalFormat() const
{
- SafeRelease(mRenderTarget);
+ return mInternalFormat;
}
-RenderTarget9 *RenderTarget9::makeRenderTarget9(RenderTarget *target)
+GLenum TextureRenderTarget9::getActualFormat() const
{
- ASSERT(HAS_DYNAMIC_TYPE(rx::RenderTarget9*, target));
- return static_cast<rx::RenderTarget9*>(target);
+ return mActualFormat;
}
-void RenderTarget9::invalidate(GLint x, GLint y, GLsizei width, GLsizei height)
+GLsizei TextureRenderTarget9::getSamples() const
{
- // Currently a no-op
+ return mSamples;
}
-IDirect3DSurface9 *RenderTarget9::getSurface()
+IDirect3DSurface9 *TextureRenderTarget9::getSurface()
{
// Caller is responsible for releasing the returned surface reference.
// TODO: remove the AddRef to match RenderTarget11
@@ -130,4 +98,51 @@ IDirect3DSurface9 *RenderTarget9::getSurface()
return mRenderTarget;
}
+
+SurfaceRenderTarget9::SurfaceRenderTarget9(SwapChain9 *swapChain, bool depth)
+ : mSwapChain(swapChain),
+ mDepth(depth)
+{
+}
+
+SurfaceRenderTarget9::~SurfaceRenderTarget9()
+{
+}
+
+GLsizei SurfaceRenderTarget9::getWidth() const
+{
+ return mSwapChain->getWidth();
+}
+
+GLsizei SurfaceRenderTarget9::getHeight() const
+{
+ return mSwapChain->getHeight();
+}
+
+GLsizei SurfaceRenderTarget9::getDepth() const
+{
+ return 1;
+}
+
+GLenum SurfaceRenderTarget9::getInternalFormat() const
+{
+ return (mDepth ? mSwapChain->GetDepthBufferInternalFormat() : mSwapChain->GetBackBufferInternalFormat());
+}
+
+GLenum SurfaceRenderTarget9::getActualFormat() const
+{
+ return d3d9::GetD3DFormatInfo(d3d9::GetTextureFormatInfo(getInternalFormat()).texFormat).internalFormat;
+}
+
+GLsizei SurfaceRenderTarget9::getSamples() const
+{
+ // Our EGL surfaces do not support multisampling.
+ return 0;
+}
+
+IDirect3DSurface9 *SurfaceRenderTarget9::getSurface()
+{
+ return (mDepth ? mSwapChain->getDepthStencil() : mSwapChain->getRenderTarget());
+}
+
}