daniel@transgaming.com | b6b27bc | 2012-11-28 20:54:30 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // RenderTarget11.cpp: Implements a DX11-specific wrapper for ID3D11View pointers |
| 8 | // retained by Renderbuffers. |
| 9 | |
| 10 | #include "libGLESv2/renderer/RenderTarget11.h" |
| 11 | #include "libGLESv2/renderer/Renderer11.h" |
| 12 | |
| 13 | #include "libGLESv2/renderer/renderer11_utils.h" |
| 14 | #include "libGLESv2/main.h" |
| 15 | |
| 16 | namespace rx |
| 17 | { |
| 18 | |
| 19 | RenderTarget11::RenderTarget11(Renderer *renderer, ID3D11RenderTargetView *view, GLsizei width, GLsizei height) |
| 20 | { |
| 21 | mRenderer = Renderer11::makeRenderer11(renderer); |
| 22 | mRenderTarget = view; |
| 23 | mDepthStencil = NULL; |
| 24 | |
| 25 | if (mRenderTarget) |
| 26 | { |
| 27 | D3D11_RENDER_TARGET_VIEW_DESC desc; |
| 28 | view->GetDesc(&desc); |
| 29 | |
| 30 | mWidth = width; |
| 31 | mHeight = height; |
| 32 | |
| 33 | mInternalFormat = d3d11_gl::ConvertRenderbufferFormat(desc.Format); |
| 34 | mActualFormat = d3d11_gl::ConvertRenderbufferFormat(desc.Format); |
| 35 | mSamples = 1; // TEMP? |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | RenderTarget11::RenderTarget11(Renderer *renderer, ID3D11DepthStencilView *view, GLsizei width, GLsizei height) |
| 40 | { |
| 41 | mRenderer = Renderer11::makeRenderer11(renderer); |
| 42 | mRenderTarget = NULL; |
| 43 | mDepthStencil = view; |
| 44 | |
| 45 | if (mDepthStencil) |
| 46 | { |
| 47 | D3D11_DEPTH_STENCIL_VIEW_DESC desc; |
| 48 | view->GetDesc(&desc); |
| 49 | |
| 50 | mWidth = width; |
| 51 | mHeight = height; |
| 52 | |
| 53 | mInternalFormat = d3d11_gl::ConvertRenderbufferFormat(desc.Format); |
| 54 | mActualFormat = d3d11_gl::ConvertRenderbufferFormat(desc.Format); |
| 55 | mSamples = 1; // TEMP? |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | RenderTarget11::~RenderTarget11() |
| 60 | { |
| 61 | if (mRenderTarget) |
| 62 | { |
| 63 | mRenderTarget->Release(); |
| 64 | } |
| 65 | |
| 66 | if (mDepthStencil) |
| 67 | { |
| 68 | mDepthStencil->Release(); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | RenderTarget11 *RenderTarget11::makeRenderTarget11(RenderTarget *target) |
| 73 | { |
| 74 | ASSERT(dynamic_cast<rx::RenderTarget11*>(target) != NULL); |
| 75 | return static_cast<rx::RenderTarget11*>(target); |
| 76 | } |
| 77 | |
daniel@transgaming.com | 816c7f3 | 2012-11-28 21:02:01 +0000 | [diff] [blame^] | 78 | // Adds reference, caller must call Release |
| 79 | ID3D11RenderTargetView *RenderTarget11::getRenderTargetView() const |
| 80 | { |
| 81 | if (mRenderTarget) |
| 82 | { |
| 83 | mRenderTarget->AddRef(); |
| 84 | } |
| 85 | |
| 86 | return mRenderTarget; |
| 87 | } |
| 88 | |
| 89 | // Adds reference, caller must call Release |
| 90 | ID3D11DepthStencilView *RenderTarget11::getDepthStencilView() const |
| 91 | { |
| 92 | if (mDepthStencil) |
| 93 | { |
| 94 | mDepthStencil->AddRef(); |
| 95 | } |
| 96 | |
| 97 | return mDepthStencil; |
| 98 | } |
| 99 | |
daniel@transgaming.com | b6b27bc | 2012-11-28 20:54:30 +0000 | [diff] [blame] | 100 | } |