Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2014 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 | |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 7 | // FramebufferD3D.cpp: Implements the DefaultAttachmentD3D and FramebufferD3D classes. |
Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 8 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 9 | #include "libANGLE/renderer/d3d/FramebufferD3D.h" |
Geoff Lang | b5d8f23 | 2014-12-04 15:43:01 -0500 | [diff] [blame] | 10 | #include "libANGLE/renderer/d3d/TextureD3D.h" |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 11 | #include "libANGLE/renderer/d3d/RendererD3D.h" |
Geoff Lang | c2e75af | 2015-01-05 14:26:24 -0500 | [diff] [blame] | 12 | #include "libANGLE/renderer/d3d/RenderTargetD3D.h" |
Geoff Lang | b5d8f23 | 2014-12-04 15:43:01 -0500 | [diff] [blame] | 13 | #include "libANGLE/renderer/d3d/RenderbufferD3D.h" |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 14 | #include "libANGLE/formatutils.h" |
Geoff Lang | 54bd5a4 | 2014-12-01 12:51:04 -0500 | [diff] [blame] | 15 | #include "libANGLE/Framebuffer.h" |
Geoff Lang | b5d8f23 | 2014-12-04 15:43:01 -0500 | [diff] [blame] | 16 | #include "libANGLE/FramebufferAttachment.h" |
Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 17 | |
| 18 | namespace rx |
| 19 | { |
| 20 | |
Geoff Lang | c2e75af | 2015-01-05 14:26:24 -0500 | [diff] [blame] | 21 | DefaultAttachmentD3D::DefaultAttachmentD3D(RenderTargetD3D *renderTarget) |
Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 22 | : mRenderTarget(renderTarget) |
| 23 | { |
| 24 | ASSERT(mRenderTarget); |
| 25 | } |
| 26 | |
| 27 | DefaultAttachmentD3D::~DefaultAttachmentD3D() |
| 28 | { |
| 29 | SafeDelete(mRenderTarget); |
| 30 | } |
| 31 | |
| 32 | DefaultAttachmentD3D *DefaultAttachmentD3D::makeDefaultAttachmentD3D(DefaultAttachmentImpl* impl) |
| 33 | { |
| 34 | ASSERT(HAS_DYNAMIC_TYPE(DefaultAttachmentD3D*, impl)); |
| 35 | return static_cast<DefaultAttachmentD3D*>(impl); |
| 36 | } |
| 37 | |
| 38 | GLsizei DefaultAttachmentD3D::getWidth() const |
| 39 | { |
| 40 | return mRenderTarget->getWidth(); |
| 41 | } |
| 42 | |
| 43 | GLsizei DefaultAttachmentD3D::getHeight() const |
| 44 | { |
| 45 | return mRenderTarget->getHeight(); |
| 46 | } |
| 47 | |
| 48 | GLenum DefaultAttachmentD3D::getInternalFormat() const |
| 49 | { |
| 50 | return mRenderTarget->getInternalFormat(); |
| 51 | } |
| 52 | |
Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 53 | GLsizei DefaultAttachmentD3D::getSamples() const |
| 54 | { |
| 55 | return mRenderTarget->getSamples(); |
| 56 | } |
| 57 | |
Geoff Lang | c2e75af | 2015-01-05 14:26:24 -0500 | [diff] [blame] | 58 | RenderTargetD3D *DefaultAttachmentD3D::getRenderTarget() const |
Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 59 | { |
| 60 | return mRenderTarget; |
| 61 | } |
| 62 | |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 63 | FramebufferD3D::FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer) |
| 64 | : FramebufferImpl(data), |
| 65 | mRenderer(renderer), |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 66 | mColorAttachmentsForRender(mData.mColorAttachments.size(), nullptr) |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 67 | { |
| 68 | ASSERT(mRenderer != nullptr); |
| 69 | } |
| 70 | |
| 71 | FramebufferD3D::~FramebufferD3D() |
| 72 | { |
| 73 | } |
| 74 | |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 75 | void FramebufferD3D::setColorAttachment(size_t, const gl::FramebufferAttachment *) |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame] | 76 | { |
| 77 | } |
| 78 | |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 79 | void FramebufferD3D::setDepthttachment(const gl::FramebufferAttachment *) |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame] | 80 | { |
| 81 | } |
| 82 | |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 83 | void FramebufferD3D::setStencilAttachment(const gl::FramebufferAttachment *) |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame] | 84 | { |
| 85 | } |
| 86 | |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 87 | void FramebufferD3D::setDepthStencilAttachment(const gl::FramebufferAttachment *) |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame] | 88 | { |
| 89 | } |
| 90 | |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 91 | void FramebufferD3D::setDrawBuffers(size_t, const GLenum *) |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame] | 92 | { |
| 93 | } |
| 94 | |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 95 | void FramebufferD3D::setReadBuffer(GLenum) |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame] | 96 | { |
| 97 | } |
| 98 | |
Geoff Lang | 9ad4bda | 2014-12-01 11:03:09 -0500 | [diff] [blame] | 99 | gl::Error FramebufferD3D::invalidate(size_t, const GLenum *) |
| 100 | { |
| 101 | // No-op in D3D |
| 102 | return gl::Error(GL_NO_ERROR); |
| 103 | } |
| 104 | |
| 105 | gl::Error FramebufferD3D::invalidateSub(size_t, const GLenum *, const gl::Rectangle &) |
| 106 | { |
| 107 | // No-op in D3D |
| 108 | return gl::Error(GL_NO_ERROR); |
| 109 | } |
| 110 | |
Geoff Lang | b04dc82 | 2014-12-01 12:02:02 -0500 | [diff] [blame] | 111 | gl::Error FramebufferD3D::clear(const gl::State &state, GLbitfield mask) |
| 112 | { |
| 113 | gl::ClearParameters clearParams = state.getClearParameters(mask); |
| 114 | return clear(state, clearParams); |
| 115 | } |
| 116 | |
| 117 | gl::Error FramebufferD3D::clearBufferfv(const gl::State &state, GLenum buffer, GLint drawbuffer, const GLfloat *values) |
| 118 | { |
| 119 | // glClearBufferfv can be called to clear the color buffer or depth buffer |
| 120 | gl::ClearParameters clearParams = state.getClearParameters(0); |
| 121 | |
| 122 | if (buffer == GL_COLOR) |
| 123 | { |
| 124 | for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++) |
| 125 | { |
| 126 | clearParams.clearColor[i] = (drawbuffer == static_cast<int>(i)); |
| 127 | } |
| 128 | clearParams.colorFClearValue = gl::ColorF(values[0], values[1], values[2], values[3]); |
| 129 | clearParams.colorClearType = GL_FLOAT; |
| 130 | } |
| 131 | |
| 132 | if (buffer == GL_DEPTH) |
| 133 | { |
| 134 | clearParams.clearDepth = true; |
| 135 | clearParams.depthClearValue = values[0]; |
| 136 | } |
| 137 | |
| 138 | return clear(state, clearParams); |
| 139 | } |
| 140 | |
| 141 | gl::Error FramebufferD3D::clearBufferuiv(const gl::State &state, GLenum buffer, GLint drawbuffer, const GLuint *values) |
| 142 | { |
| 143 | // glClearBufferuiv can only be called to clear a color buffer |
| 144 | gl::ClearParameters clearParams = state.getClearParameters(0); |
| 145 | for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++) |
| 146 | { |
| 147 | clearParams.clearColor[i] = (drawbuffer == static_cast<int>(i)); |
| 148 | } |
| 149 | clearParams.colorUIClearValue = gl::ColorUI(values[0], values[1], values[2], values[3]); |
| 150 | clearParams.colorClearType = GL_UNSIGNED_INT; |
| 151 | |
| 152 | return clear(state, clearParams); |
| 153 | } |
| 154 | |
| 155 | gl::Error FramebufferD3D::clearBufferiv(const gl::State &state, GLenum buffer, GLint drawbuffer, const GLint *values) |
| 156 | { |
| 157 | // glClearBufferiv can be called to clear the color buffer or stencil buffer |
| 158 | gl::ClearParameters clearParams = state.getClearParameters(0); |
| 159 | |
| 160 | if (buffer == GL_COLOR) |
| 161 | { |
| 162 | for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++) |
| 163 | { |
| 164 | clearParams.clearColor[i] = (drawbuffer == static_cast<int>(i)); |
| 165 | } |
| 166 | clearParams.colorIClearValue = gl::ColorI(values[0], values[1], values[2], values[3]); |
| 167 | clearParams.colorClearType = GL_INT; |
| 168 | } |
| 169 | |
| 170 | if (buffer == GL_STENCIL) |
| 171 | { |
| 172 | clearParams.clearStencil = true; |
| 173 | clearParams.stencilClearValue = values[1]; |
| 174 | } |
| 175 | |
| 176 | return clear(state, clearParams); |
| 177 | } |
| 178 | |
| 179 | gl::Error FramebufferD3D::clearBufferfi(const gl::State &state, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 180 | { |
| 181 | // glClearBufferfi can only be called to clear a depth stencil buffer |
| 182 | gl::ClearParameters clearParams = state.getClearParameters(0); |
| 183 | clearParams.clearDepth = true; |
| 184 | clearParams.depthClearValue = depth; |
| 185 | clearParams.clearStencil = true; |
| 186 | clearParams.stencilClearValue = stencil; |
| 187 | |
| 188 | return clear(state, clearParams); |
| 189 | } |
| 190 | |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 191 | GLenum FramebufferD3D::getImplementationColorReadFormat() const |
| 192 | { |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 193 | const gl::FramebufferAttachment *readAttachment = mData.getReadAttachment(); |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 194 | |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 195 | if (readAttachment == nullptr) |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 196 | { |
| 197 | return GL_NONE; |
| 198 | } |
| 199 | |
Geoff Lang | c2e75af | 2015-01-05 14:26:24 -0500 | [diff] [blame] | 200 | RenderTargetD3D *attachmentRenderTarget = NULL; |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 201 | gl::Error error = GetAttachmentRenderTarget(readAttachment, &attachmentRenderTarget); |
Geoff Lang | d8a2258 | 2014-12-17 15:28:23 -0500 | [diff] [blame] | 202 | if (error.isError()) |
| 203 | { |
| 204 | return GL_NONE; |
| 205 | } |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 206 | |
Geoff Lang | d8a2258 | 2014-12-17 15:28:23 -0500 | [diff] [blame] | 207 | GLenum implementationFormat = getRenderTargetImplementationFormat(attachmentRenderTarget); |
| 208 | const gl::InternalFormat &implementationFormatInfo = gl::GetInternalFormatInfo(implementationFormat); |
| 209 | |
| 210 | return implementationFormatInfo.format; |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | GLenum FramebufferD3D::getImplementationColorReadType() const |
| 214 | { |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 215 | const gl::FramebufferAttachment *readAttachment = mData.getReadAttachment(); |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 216 | |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 217 | if (readAttachment == nullptr) |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 218 | { |
| 219 | return GL_NONE; |
| 220 | } |
| 221 | |
Geoff Lang | c2e75af | 2015-01-05 14:26:24 -0500 | [diff] [blame] | 222 | RenderTargetD3D *attachmentRenderTarget = NULL; |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 223 | gl::Error error = GetAttachmentRenderTarget(readAttachment, &attachmentRenderTarget); |
Geoff Lang | d8a2258 | 2014-12-17 15:28:23 -0500 | [diff] [blame] | 224 | if (error.isError()) |
| 225 | { |
| 226 | return GL_NONE; |
| 227 | } |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 228 | |
Geoff Lang | d8a2258 | 2014-12-17 15:28:23 -0500 | [diff] [blame] | 229 | GLenum implementationFormat = getRenderTargetImplementationFormat(attachmentRenderTarget); |
| 230 | const gl::InternalFormat &implementationFormatInfo = gl::GetInternalFormatInfo(implementationFormat); |
| 231 | |
| 232 | return implementationFormatInfo.type; |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | gl::Error FramebufferD3D::readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const |
| 236 | { |
| 237 | GLenum sizedInternalFormat = gl::GetSizedInternalFormat(format, type); |
| 238 | const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(sizedInternalFormat); |
Minmin Gong | b8aee3b | 2015-01-27 14:42:36 -0800 | [diff] [blame] | 239 | GLuint outputPitch = sizedFormatInfo.computeRowPitch(type, area.width, state.getPackAlignment(), 0); |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 240 | |
| 241 | return readPixels(area, format, type, outputPitch, state.getPackState(), reinterpret_cast<uint8_t*>(pixels)); |
| 242 | } |
| 243 | |
Geoff Lang | 54bd5a4 | 2014-12-01 12:51:04 -0500 | [diff] [blame] | 244 | gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, |
| 245 | GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) |
| 246 | { |
| 247 | bool blitRenderTarget = false; |
| 248 | if ((mask & GL_COLOR_BUFFER_BIT) && |
| 249 | sourceFramebuffer->getReadColorbuffer() != nullptr && |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 250 | mData.getFirstColorAttachment() != nullptr) |
Geoff Lang | 54bd5a4 | 2014-12-01 12:51:04 -0500 | [diff] [blame] | 251 | { |
| 252 | blitRenderTarget = true; |
| 253 | } |
| 254 | |
| 255 | bool blitStencil = false; |
| 256 | if ((mask & GL_STENCIL_BUFFER_BIT) && |
| 257 | sourceFramebuffer->getStencilbuffer() != nullptr && |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 258 | mData.mStencilAttachment != nullptr) |
Geoff Lang | 54bd5a4 | 2014-12-01 12:51:04 -0500 | [diff] [blame] | 259 | { |
| 260 | blitStencil = true; |
| 261 | } |
| 262 | |
| 263 | bool blitDepth = false; |
| 264 | if ((mask & GL_DEPTH_BUFFER_BIT) && |
| 265 | sourceFramebuffer->getDepthbuffer() != nullptr && |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 266 | mData.mDepthAttachment != nullptr) |
Geoff Lang | 54bd5a4 | 2014-12-01 12:51:04 -0500 | [diff] [blame] | 267 | { |
| 268 | blitDepth = true; |
| 269 | } |
| 270 | |
| 271 | if (blitRenderTarget || blitDepth || blitStencil) |
| 272 | { |
| 273 | const gl::Rectangle *scissor = state.isScissorTestEnabled() ? &state.getScissor() : NULL; |
| 274 | gl::Error error = blit(sourceArea, destArea, scissor, blitRenderTarget, blitDepth, blitStencil, |
| 275 | filter, sourceFramebuffer); |
| 276 | if (error.isError()) |
| 277 | { |
| 278 | return error; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | return gl::Error(GL_NO_ERROR); |
| 283 | } |
| 284 | |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 285 | GLenum FramebufferD3D::checkStatus() const |
| 286 | { |
| 287 | // D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 288 | for (size_t colorAttachment = 0; colorAttachment < mData.mColorAttachments.size(); colorAttachment++) |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 289 | { |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 290 | const gl::FramebufferAttachment *attachment = mData.mColorAttachments[colorAttachment]; |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 291 | if (attachment != nullptr) |
| 292 | { |
| 293 | for (size_t prevColorAttachment = 0; prevColorAttachment < colorAttachment; prevColorAttachment++) |
| 294 | { |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 295 | const gl::FramebufferAttachment *prevAttachment = mData.mColorAttachments[prevColorAttachment]; |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 296 | if (prevAttachment != nullptr && |
| 297 | (attachment->id() == prevAttachment->id() && |
| 298 | attachment->type() == prevAttachment->type())) |
| 299 | { |
| 300 | return GL_FRAMEBUFFER_UNSUPPORTED; |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | return GL_FRAMEBUFFER_COMPLETE; |
| 307 | } |
| 308 | |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame^] | 309 | const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Workarounds &workarounds) const |
| 310 | { |
| 311 | // Does not actually free memory |
| 312 | mColorAttachmentsForRender.clear(); |
| 313 | |
| 314 | for (size_t attachmentIndex = 0; attachmentIndex < mData.mColorAttachments.size(); ++attachmentIndex) |
| 315 | { |
| 316 | GLenum drawBufferState = mData.mDrawBufferStates[attachmentIndex]; |
| 317 | gl::FramebufferAttachment *colorAttachment = mData.mColorAttachments[attachmentIndex]; |
| 318 | |
| 319 | if (colorAttachment != nullptr && drawBufferState != GL_NONE) |
| 320 | { |
| 321 | ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + attachmentIndex)); |
| 322 | mColorAttachmentsForRender.push_back(colorAttachment); |
| 323 | } |
| 324 | else if (!workarounds.mrtPerfWorkaround) |
| 325 | { |
| 326 | mColorAttachmentsForRender.push_back(nullptr); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | return mColorAttachmentsForRender; |
| 331 | } |
| 332 | |
Geoff Lang | c2e75af | 2015-01-05 14:26:24 -0500 | [diff] [blame] | 333 | gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTargetD3D **outRT) |
Geoff Lang | b5d8f23 | 2014-12-04 15:43:01 -0500 | [diff] [blame] | 334 | { |
| 335 | if (attachment->type() == GL_TEXTURE) |
| 336 | { |
| 337 | gl::Texture *texture = attachment->getTexture(); |
| 338 | ASSERT(texture); |
Jamie Madill | 9236b41 | 2015-02-02 16:51:52 -0500 | [diff] [blame] | 339 | TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture); |
Geoff Lang | b5d8f23 | 2014-12-04 15:43:01 -0500 | [diff] [blame] | 340 | const gl::ImageIndex *index = attachment->getTextureImageIndex(); |
| 341 | ASSERT(index); |
| 342 | return textureD3D->getRenderTarget(*index, outRT); |
| 343 | } |
| 344 | else if (attachment->type() == GL_RENDERBUFFER) |
| 345 | { |
| 346 | gl::Renderbuffer *renderbuffer = attachment->getRenderbuffer(); |
| 347 | ASSERT(renderbuffer); |
| 348 | RenderbufferD3D *renderbufferD3D = RenderbufferD3D::makeRenderbufferD3D(renderbuffer->getImplementation()); |
| 349 | *outRT = renderbufferD3D->getRenderTarget(); |
| 350 | return gl::Error(GL_NO_ERROR); |
| 351 | } |
| 352 | else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT) |
| 353 | { |
| 354 | const gl::DefaultAttachment *defaultAttachment = static_cast<const gl::DefaultAttachment *>(attachment); |
| 355 | DefaultAttachmentD3D *defaultAttachmentD3D = DefaultAttachmentD3D::makeDefaultAttachmentD3D(defaultAttachment->getImplementation()); |
| 356 | ASSERT(defaultAttachmentD3D); |
| 357 | |
| 358 | *outRT = defaultAttachmentD3D->getRenderTarget(); |
| 359 | return gl::Error(GL_NO_ERROR); |
| 360 | } |
| 361 | else |
| 362 | { |
| 363 | UNREACHABLE(); |
| 364 | return gl::Error(GL_INVALID_OPERATION); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | // Note: RenderTarget serials should ideally be in the RenderTargets themselves. |
| 369 | unsigned int GetAttachmentSerial(const gl::FramebufferAttachment *attachment) |
| 370 | { |
| 371 | if (attachment->type() == GL_TEXTURE) |
| 372 | { |
| 373 | gl::Texture *texture = attachment->getTexture(); |
| 374 | ASSERT(texture); |
Jamie Madill | 9236b41 | 2015-02-02 16:51:52 -0500 | [diff] [blame] | 375 | TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture); |
Geoff Lang | b5d8f23 | 2014-12-04 15:43:01 -0500 | [diff] [blame] | 376 | const gl::ImageIndex *index = attachment->getTextureImageIndex(); |
| 377 | ASSERT(index); |
| 378 | return textureD3D->getRenderTargetSerial(*index); |
| 379 | } |
| 380 | else if (attachment->type() == GL_RENDERBUFFER) |
| 381 | { |
| 382 | gl::Renderbuffer *renderbuffer = attachment->getRenderbuffer(); |
| 383 | ASSERT(renderbuffer); |
| 384 | RenderbufferD3D *renderbufferD3D = RenderbufferD3D::makeRenderbufferD3D(renderbuffer->getImplementation()); |
| 385 | return renderbufferD3D->getRenderTargetSerial(); |
| 386 | } |
| 387 | else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT) |
| 388 | { |
| 389 | const gl::DefaultAttachment *defaultAttachment = static_cast<const gl::DefaultAttachment *>(attachment); |
| 390 | DefaultAttachmentD3D *defaultAttachmentD3D = DefaultAttachmentD3D::makeDefaultAttachmentD3D(defaultAttachment->getImplementation()); |
| 391 | ASSERT(defaultAttachmentD3D); |
| 392 | return defaultAttachmentD3D->getRenderTarget()->getSerial(); |
| 393 | } |
| 394 | else |
| 395 | { |
| 396 | UNREACHABLE(); |
| 397 | return 0; |
| 398 | } |
| 399 | } |
| 400 | |
Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 401 | } |