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 | b5d8f23 | 2014-12-04 15:43:01 -0500 | [diff] [blame] | 12 | #include "libANGLE/renderer/d3d/RenderbufferD3D.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 13 | #include "libANGLE/renderer/RenderTarget.h" |
Geoff Lang | b5d8f23 | 2014-12-04 15:43:01 -0500 | [diff] [blame] | 14 | #include "libANGLE/FramebufferAttachment.h" |
Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 15 | |
| 16 | namespace rx |
| 17 | { |
| 18 | |
| 19 | DefaultAttachmentD3D::DefaultAttachmentD3D(RenderTarget *renderTarget) |
| 20 | : mRenderTarget(renderTarget) |
| 21 | { |
| 22 | ASSERT(mRenderTarget); |
| 23 | } |
| 24 | |
| 25 | DefaultAttachmentD3D::~DefaultAttachmentD3D() |
| 26 | { |
| 27 | SafeDelete(mRenderTarget); |
| 28 | } |
| 29 | |
| 30 | DefaultAttachmentD3D *DefaultAttachmentD3D::makeDefaultAttachmentD3D(DefaultAttachmentImpl* impl) |
| 31 | { |
| 32 | ASSERT(HAS_DYNAMIC_TYPE(DefaultAttachmentD3D*, impl)); |
| 33 | return static_cast<DefaultAttachmentD3D*>(impl); |
| 34 | } |
| 35 | |
| 36 | GLsizei DefaultAttachmentD3D::getWidth() const |
| 37 | { |
| 38 | return mRenderTarget->getWidth(); |
| 39 | } |
| 40 | |
| 41 | GLsizei DefaultAttachmentD3D::getHeight() const |
| 42 | { |
| 43 | return mRenderTarget->getHeight(); |
| 44 | } |
| 45 | |
| 46 | GLenum DefaultAttachmentD3D::getInternalFormat() const |
| 47 | { |
| 48 | return mRenderTarget->getInternalFormat(); |
| 49 | } |
| 50 | |
| 51 | GLenum DefaultAttachmentD3D::getActualFormat() const |
| 52 | { |
| 53 | return mRenderTarget->getActualFormat(); |
| 54 | } |
| 55 | |
| 56 | GLsizei DefaultAttachmentD3D::getSamples() const |
| 57 | { |
| 58 | return mRenderTarget->getSamples(); |
| 59 | } |
| 60 | |
| 61 | RenderTarget *DefaultAttachmentD3D::getRenderTarget() const |
| 62 | { |
| 63 | return mRenderTarget; |
| 64 | } |
| 65 | |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 66 | |
| 67 | FramebufferD3D::FramebufferD3D(RendererD3D *renderer) |
| 68 | : mRenderer(renderer) |
| 69 | { |
| 70 | ASSERT(mRenderer != nullptr); |
| 71 | } |
| 72 | |
| 73 | FramebufferD3D::~FramebufferD3D() |
| 74 | { |
| 75 | } |
| 76 | |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame^] | 77 | void FramebufferD3D::setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) |
| 78 | { |
| 79 | } |
| 80 | |
| 81 | void FramebufferD3D::setDepthttachment(const gl::FramebufferAttachment *attachment) |
| 82 | { |
| 83 | } |
| 84 | |
| 85 | void FramebufferD3D::setStencilAttachment(const gl::FramebufferAttachment *attachment) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | void FramebufferD3D::setDepthStencilAttachment(const gl::FramebufferAttachment *attachment) |
| 90 | { |
| 91 | } |
| 92 | |
| 93 | void FramebufferD3D::setDrawBuffers(size_t count, const GLenum *buffers) |
| 94 | { |
| 95 | } |
| 96 | |
| 97 | void FramebufferD3D::setReadBuffer(GLenum buffer) |
| 98 | { |
| 99 | } |
| 100 | |
Geoff Lang | 9ad4bda | 2014-12-01 11:03:09 -0500 | [diff] [blame] | 101 | gl::Error FramebufferD3D::invalidate(size_t, const GLenum *) |
| 102 | { |
| 103 | // No-op in D3D |
| 104 | return gl::Error(GL_NO_ERROR); |
| 105 | } |
| 106 | |
| 107 | gl::Error FramebufferD3D::invalidateSub(size_t, const GLenum *, const gl::Rectangle &) |
| 108 | { |
| 109 | // No-op in D3D |
| 110 | return gl::Error(GL_NO_ERROR); |
| 111 | } |
| 112 | |
Geoff Lang | b5d8f23 | 2014-12-04 15:43:01 -0500 | [diff] [blame] | 113 | gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTarget **outRT) |
| 114 | { |
| 115 | if (attachment->type() == GL_TEXTURE) |
| 116 | { |
| 117 | gl::Texture *texture = attachment->getTexture(); |
| 118 | ASSERT(texture); |
| 119 | TextureD3D *textureD3D = TextureD3D::makeTextureD3D(texture->getImplementation()); |
| 120 | const gl::ImageIndex *index = attachment->getTextureImageIndex(); |
| 121 | ASSERT(index); |
| 122 | return textureD3D->getRenderTarget(*index, outRT); |
| 123 | } |
| 124 | else if (attachment->type() == GL_RENDERBUFFER) |
| 125 | { |
| 126 | gl::Renderbuffer *renderbuffer = attachment->getRenderbuffer(); |
| 127 | ASSERT(renderbuffer); |
| 128 | RenderbufferD3D *renderbufferD3D = RenderbufferD3D::makeRenderbufferD3D(renderbuffer->getImplementation()); |
| 129 | *outRT = renderbufferD3D->getRenderTarget(); |
| 130 | return gl::Error(GL_NO_ERROR); |
| 131 | } |
| 132 | else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT) |
| 133 | { |
| 134 | const gl::DefaultAttachment *defaultAttachment = static_cast<const gl::DefaultAttachment *>(attachment); |
| 135 | DefaultAttachmentD3D *defaultAttachmentD3D = DefaultAttachmentD3D::makeDefaultAttachmentD3D(defaultAttachment->getImplementation()); |
| 136 | ASSERT(defaultAttachmentD3D); |
| 137 | |
| 138 | *outRT = defaultAttachmentD3D->getRenderTarget(); |
| 139 | return gl::Error(GL_NO_ERROR); |
| 140 | } |
| 141 | else |
| 142 | { |
| 143 | UNREACHABLE(); |
| 144 | return gl::Error(GL_INVALID_OPERATION); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // Note: RenderTarget serials should ideally be in the RenderTargets themselves. |
| 149 | unsigned int GetAttachmentSerial(const gl::FramebufferAttachment *attachment) |
| 150 | { |
| 151 | if (attachment->type() == GL_TEXTURE) |
| 152 | { |
| 153 | gl::Texture *texture = attachment->getTexture(); |
| 154 | ASSERT(texture); |
| 155 | TextureD3D *textureD3D = TextureD3D::makeTextureD3D(texture->getImplementation()); |
| 156 | const gl::ImageIndex *index = attachment->getTextureImageIndex(); |
| 157 | ASSERT(index); |
| 158 | return textureD3D->getRenderTargetSerial(*index); |
| 159 | } |
| 160 | else if (attachment->type() == GL_RENDERBUFFER) |
| 161 | { |
| 162 | gl::Renderbuffer *renderbuffer = attachment->getRenderbuffer(); |
| 163 | ASSERT(renderbuffer); |
| 164 | RenderbufferD3D *renderbufferD3D = RenderbufferD3D::makeRenderbufferD3D(renderbuffer->getImplementation()); |
| 165 | return renderbufferD3D->getRenderTargetSerial(); |
| 166 | } |
| 167 | else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT) |
| 168 | { |
| 169 | const gl::DefaultAttachment *defaultAttachment = static_cast<const gl::DefaultAttachment *>(attachment); |
| 170 | DefaultAttachmentD3D *defaultAttachmentD3D = DefaultAttachmentD3D::makeDefaultAttachmentD3D(defaultAttachment->getImplementation()); |
| 171 | ASSERT(defaultAttachmentD3D); |
| 172 | return defaultAttachmentD3D->getRenderTarget()->getSerial(); |
| 173 | } |
| 174 | else |
| 175 | { |
| 176 | UNREACHABLE(); |
| 177 | return 0; |
| 178 | } |
| 179 | } |
| 180 | |
Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 181 | } |