daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +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 | // Renderer11.cpp: Implements a back-end specific class for the D3D11 renderer. |
| 8 | |
| 9 | #include "common/debug.h" |
daniel@transgaming.com | 5503fd0 | 2012-11-28 19:38:57 +0000 | [diff] [blame^] | 10 | #include "libGLESv2/main.h" |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 11 | #include "libGLESv2/utilities.h" |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 12 | #include "libGLESv2/mathutil.h" |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 13 | #include "libGLESv2/renderer/Renderer11.h" |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 14 | #include "libGLESv2/renderer/renderer11_utils.h" |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 15 | |
| 16 | #include "libEGL/Config.h" |
| 17 | #include "libEGL/Display.h" |
| 18 | |
| 19 | namespace rx |
| 20 | { |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 21 | static const DXGI_FORMAT RenderTargetFormats[] = |
| 22 | { |
| 23 | DXGI_FORMAT_R8G8B8A8_UNORM |
| 24 | }; |
| 25 | |
| 26 | static const DXGI_FORMAT DepthStencilFormats[] = |
| 27 | { |
| 28 | DXGI_FORMAT_D24_UNORM_S8_UINT |
| 29 | }; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 30 | |
| 31 | Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc(hDc) |
| 32 | { |
| 33 | mD3d11Module = NULL; |
| 34 | mDxgiModule = NULL; |
| 35 | |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 36 | mDeviceLost = false; |
| 37 | |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 38 | mDevice = NULL; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 39 | mDeviceContext = NULL; |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 40 | mDxgiAdapter = NULL; |
| 41 | mDxgiFactory = NULL; |
daniel@transgaming.com | f8ba109 | 2012-11-28 19:37:53 +0000 | [diff] [blame] | 42 | |
| 43 | mForceSetBlendState = true; |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 44 | mForceSetRasterState = true; |
daniel@transgaming.com | 5503fd0 | 2012-11-28 19:38:57 +0000 | [diff] [blame^] | 45 | mForceSetDepthStencilState = true; |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 46 | mForceSetScissor = true; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | Renderer11::~Renderer11() |
| 50 | { |
| 51 | releaseDeviceResources(); |
| 52 | |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 53 | if (mDxgiFactory) |
| 54 | { |
| 55 | mDxgiFactory->Release(); |
| 56 | mDxgiFactory = NULL; |
| 57 | } |
| 58 | |
| 59 | if (mDxgiAdapter) |
| 60 | { |
| 61 | mDxgiAdapter->Release(); |
| 62 | mDxgiAdapter = NULL; |
| 63 | } |
| 64 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 65 | if (mDeviceContext) |
| 66 | { |
| 67 | mDeviceContext->Release(); |
| 68 | mDeviceContext = NULL; |
| 69 | } |
| 70 | |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 71 | if (mDevice) |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 72 | { |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 73 | mDevice->Release(); |
| 74 | mDevice = NULL; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | if (mD3d11Module) |
| 78 | { |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 79 | FreeLibrary(mD3d11Module); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 80 | mD3d11Module = NULL; |
| 81 | } |
| 82 | |
| 83 | if (mDxgiModule) |
| 84 | { |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 85 | FreeLibrary(mDxgiModule); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 86 | mDxgiModule = NULL; |
| 87 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | EGLint Renderer11::initialize() |
| 91 | { |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 92 | mDxgiModule = LoadLibrary(TEXT("dxgi.dll")); |
| 93 | mD3d11Module = LoadLibrary(TEXT("d3d11.dll")); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 94 | |
| 95 | if (mD3d11Module == NULL || mDxgiModule == NULL) |
| 96 | { |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 97 | ERR("Could not load D3D11 or DXGI library - aborting!\n"); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 98 | return EGL_NOT_INITIALIZED; |
| 99 | } |
| 100 | |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 101 | PFN_D3D11_CREATE_DEVICE D3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(mD3d11Module, "D3D11CreateDevice"); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 102 | |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 103 | if (D3D11CreateDevice == NULL) |
| 104 | { |
| 105 | ERR("Could not retrieve D3D11CreateDevice address - aborting!\n"); |
| 106 | return EGL_NOT_INITIALIZED; |
| 107 | } |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 108 | |
| 109 | D3D_FEATURE_LEVEL featureLevel[] = |
| 110 | { |
| 111 | D3D_FEATURE_LEVEL_11_0, |
| 112 | D3D_FEATURE_LEVEL_10_1, |
| 113 | D3D_FEATURE_LEVEL_10_0, |
| 114 | }; |
| 115 | |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 116 | HRESULT result = D3D11CreateDevice(NULL, |
| 117 | D3D_DRIVER_TYPE_HARDWARE, |
| 118 | NULL, |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 119 | 0, // D3D11_CREATE_DEVICE_DEBUG |
| 120 | featureLevel, |
| 121 | sizeof(featureLevel)/sizeof(featureLevel[0]), |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 122 | D3D11_SDK_VERSION, |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 123 | &mDevice, |
| 124 | &mFeatureLevel, |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 125 | &mDeviceContext); |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 126 | |
| 127 | if (!mDevice || FAILED(result)) |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 128 | { |
| 129 | ERR("Could not create D3D11 device - aborting!\n"); |
| 130 | return EGL_NOT_INITIALIZED; // Cleanup done by destructor through glDestroyRenderer |
| 131 | } |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 132 | |
| 133 | IDXGIDevice *dxgiDevice = NULL; |
| 134 | result = mDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice); |
| 135 | |
| 136 | if (FAILED(result)) |
| 137 | { |
| 138 | ERR("Could not query DXGI device - aborting!\n"); |
| 139 | return EGL_NOT_INITIALIZED; |
| 140 | } |
| 141 | |
| 142 | result = dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&mDxgiAdapter); |
| 143 | |
| 144 | if (FAILED(result)) |
| 145 | { |
| 146 | ERR("Could not retrieve DXGI adapter - aborting!\n"); |
| 147 | return EGL_NOT_INITIALIZED; |
| 148 | } |
| 149 | |
| 150 | dxgiDevice->Release(); |
| 151 | |
| 152 | result = mDxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&mDxgiFactory); |
| 153 | |
| 154 | if (!mDxgiFactory || FAILED(result)) |
| 155 | { |
| 156 | ERR("Could not create DXGI factory - aborting!\n"); |
| 157 | return EGL_NOT_INITIALIZED; |
| 158 | } |
| 159 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 160 | initializeDevice(); |
| 161 | |
| 162 | return EGL_SUCCESS; |
| 163 | } |
| 164 | |
| 165 | // do any one-time device initialization |
| 166 | // NOTE: this is also needed after a device lost/reset |
| 167 | // to reset the scene status and ensure the default states are reset. |
| 168 | void Renderer11::initializeDevice() |
| 169 | { |
daniel@transgaming.com | f8ba109 | 2012-11-28 19:37:53 +0000 | [diff] [blame] | 170 | mStateCache.initialize(mDevice); |
| 171 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 172 | // Permanent non-default states |
| 173 | // TODO |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 174 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 175 | } |
| 176 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 177 | int Renderer11::generateConfigs(ConfigDesc **configDescList) |
| 178 | { |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 179 | int numRenderFormats = sizeof(RenderTargetFormats) / sizeof(RenderTargetFormats[0]); |
| 180 | int numDepthFormats = sizeof(DepthStencilFormats) / sizeof(DepthStencilFormats[0]); |
| 181 | (*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats]; |
| 182 | int numConfigs = 0; |
| 183 | |
| 184 | for (int formatIndex = 0; formatIndex < numRenderFormats; formatIndex++) |
| 185 | { |
| 186 | for (int depthStencilIndex = 0; depthStencilIndex < numDepthFormats; depthStencilIndex++) |
| 187 | { |
| 188 | DXGI_FORMAT renderTargetFormat = RenderTargetFormats[formatIndex]; |
| 189 | |
| 190 | UINT formatSupport = 0; |
| 191 | HRESULT result = mDevice->CheckFormatSupport(renderTargetFormat, &formatSupport); |
| 192 | |
| 193 | if (SUCCEEDED(result) && (formatSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET)) |
| 194 | { |
| 195 | DXGI_FORMAT depthStencilFormat = DepthStencilFormats[depthStencilIndex]; |
| 196 | |
| 197 | UINT formatSupport = 0; |
| 198 | HRESULT result = mDevice->CheckFormatSupport(depthStencilFormat, &formatSupport); |
| 199 | |
| 200 | if (SUCCEEDED(result) && (formatSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL)) |
| 201 | { |
| 202 | ConfigDesc newConfig; |
| 203 | newConfig.renderTargetFormat = d3d11_gl::ConvertBackBufferFormat(renderTargetFormat); |
| 204 | newConfig.depthStencilFormat = d3d11_gl::ConvertDepthStencilFormat(depthStencilFormat); |
| 205 | newConfig.multiSample = 0; // FIXME: enumerate multi-sampling |
| 206 | newConfig.fastConfig = true; // Assume all DX11 format conversions to be fast |
| 207 | |
| 208 | (*configDescList)[numConfigs++] = newConfig; |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | return numConfigs; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | void Renderer11::deleteConfigs(ConfigDesc *configDescList) |
| 218 | { |
| 219 | delete [] (configDescList); |
| 220 | } |
| 221 | |
| 222 | void Renderer11::startScene() |
| 223 | { |
| 224 | // TODO: nop in d3d11? |
| 225 | } |
| 226 | |
| 227 | void Renderer11::endScene() |
| 228 | { |
| 229 | // TODO: nop in d3d11? |
| 230 | } |
| 231 | |
| 232 | void Renderer11::sync(bool block) |
| 233 | { |
| 234 | // TODO |
| 235 | UNIMPLEMENTED(); |
| 236 | } |
| 237 | |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 238 | SwapChain *Renderer11::createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) |
| 239 | { |
| 240 | // TODO |
| 241 | UNIMPLEMENTED(); |
| 242 | |
| 243 | //return new rx::SwapChain(this, window, shareHandle, backBufferFormat, depthBufferFormat); |
| 244 | |
| 245 | return NULL; |
| 246 | } |
| 247 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 248 | void Renderer11::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &samplerState) |
| 249 | { |
| 250 | // TODO |
| 251 | UNIMPLEMENTED(); |
| 252 | } |
| 253 | |
| 254 | void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture) |
| 255 | { |
| 256 | // TODO |
| 257 | UNIMPLEMENTED(); |
| 258 | } |
| 259 | |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 260 | void Renderer11::setRasterizerState(const gl::RasterizerState &rasterState, unsigned int depthSize) |
| 261 | { |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 262 | if (mForceSetRasterState || |
| 263 | memcmp(&rasterState, &mCurRasterState, sizeof(gl::RasterizerState)) != 0 || |
| 264 | depthSize != mCurDepthSize) |
| 265 | { |
| 266 | ID3D11RasterizerState *dxRasterState = mStateCache.getRasterizerState(rasterState, depthSize); |
| 267 | if (!dxRasterState) |
| 268 | { |
| 269 | ERR("NULL blend state returned by RenderStateCache::getRasterizerState, setting the " |
| 270 | "rasterizer state."); |
| 271 | } |
| 272 | |
| 273 | mDeviceContext->RSSetState(dxRasterState); |
| 274 | |
| 275 | if (dxRasterState) |
| 276 | { |
| 277 | dxRasterState->Release(); |
| 278 | } |
| 279 | mCurRasterState = rasterState; |
| 280 | mCurDepthSize = depthSize; |
| 281 | } |
| 282 | |
| 283 | mForceSetRasterState = false; |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | void Renderer11::setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor, |
| 287 | unsigned int sampleMask) |
| 288 | { |
daniel@transgaming.com | f8ba109 | 2012-11-28 19:37:53 +0000 | [diff] [blame] | 289 | if (mForceSetBlendState || |
| 290 | memcmp(&blendState, &mCurBlendState, sizeof(gl::BlendState)) != 0 || |
| 291 | memcmp(&blendColor, &mCurBlendColor, sizeof(gl::Color)) != 0 || |
| 292 | sampleMask != mCurSampleMask) |
| 293 | { |
| 294 | ID3D11BlendState *dxBlendState = mStateCache.getBlendState(blendState); |
| 295 | if (!dxBlendState) |
| 296 | { |
| 297 | ERR("NULL blend state returned by RenderStateCache::getBlendState, setting the default " |
| 298 | "blend state."); |
| 299 | } |
| 300 | |
| 301 | const float blendColors[] = { blendColor.red, blendColor.green, blendColor.blue, blendColor.alpha }; |
| 302 | mDeviceContext->OMSetBlendState(dxBlendState, blendColors, sampleMask); |
| 303 | |
| 304 | if (dxBlendState) |
| 305 | { |
| 306 | dxBlendState->Release(); |
| 307 | } |
| 308 | mCurBlendState = blendState; |
| 309 | mCurBlendColor = blendColor; |
| 310 | mCurSampleMask = sampleMask; |
| 311 | } |
| 312 | |
| 313 | mForceSetBlendState = false; |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 314 | } |
| 315 | |
daniel@transgaming.com | 08c331d | 2012-11-28 19:38:39 +0000 | [diff] [blame] | 316 | void Renderer11::setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef, |
| 317 | int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize) |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 318 | { |
daniel@transgaming.com | 5503fd0 | 2012-11-28 19:38:57 +0000 | [diff] [blame^] | 319 | if (mForceSetDepthStencilState || |
| 320 | memcmp(&depthStencilState, &mCurDepthStencilState, sizeof(gl::DepthStencilState)) != 0 || |
| 321 | stencilRef != mCurStencilRef || stencilBackRef != mCurStencilBackRef) |
| 322 | { |
| 323 | if (depthStencilState.stencilWritemask != depthStencilState.stencilBackWritemask || |
| 324 | stencilRef != stencilBackRef || |
| 325 | depthStencilState.stencilMask != depthStencilState.stencilBackMask) |
| 326 | { |
| 327 | ERR("Separate front/back stencil writemasks, reference values, or stencil mask values are " |
| 328 | "invalid under WebGL."); |
| 329 | return error(GL_INVALID_OPERATION); |
| 330 | } |
| 331 | |
| 332 | ID3D11DepthStencilState *dxDepthStencilState = mStateCache.getDepthStencilState(depthStencilState); |
| 333 | if (!dxDepthStencilState) |
| 334 | { |
| 335 | ERR("NULL depth stencil state returned by RenderStateCache::getDepthStencilState, " |
| 336 | "setting the default depth stencil state."); |
| 337 | } |
| 338 | |
| 339 | mDeviceContext->OMSetDepthStencilState(dxDepthStencilState, static_cast<UINT>(stencilRef)); |
| 340 | |
| 341 | if (dxDepthStencilState) |
| 342 | { |
| 343 | dxDepthStencilState->Release(); |
| 344 | } |
| 345 | mCurDepthStencilState = depthStencilState; |
| 346 | mCurStencilRef = stencilRef; |
| 347 | mCurStencilBackRef = stencilBackRef; |
| 348 | } |
| 349 | |
| 350 | mForceSetDepthStencilState = false; |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | void Renderer11::setScissorRectangle(const gl::Rectangle& scissor, unsigned int renderTargetWidth, |
| 354 | unsigned int renderTargetHeight) |
| 355 | { |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 356 | if (mForceSetScissor || |
| 357 | renderTargetWidth != mCurRenderTargetWidth || |
| 358 | renderTargetHeight != mCurRenderTargetHeight || |
| 359 | memcmp(&scissor, &mCurScissor, sizeof(gl::Rectangle)) != 0) |
| 360 | { |
| 361 | D3D11_RECT rect; |
| 362 | rect.left = gl::clamp(scissor.x, 0, static_cast<int>(renderTargetWidth)); |
| 363 | rect.top = gl::clamp(scissor.y, 0, static_cast<int>(renderTargetWidth)); |
| 364 | rect.right = gl::clamp(scissor.x + scissor.width, 0, static_cast<int>(renderTargetWidth)); |
| 365 | rect.bottom = gl::clamp(scissor.y + scissor.height, 0, static_cast<int>(renderTargetWidth)); |
| 366 | |
| 367 | mDeviceContext->RSSetScissorRects(1, &rect); |
| 368 | |
| 369 | mCurScissor = scissor; |
| 370 | mCurRenderTargetWidth = renderTargetWidth; |
| 371 | mCurRenderTargetHeight = renderTargetHeight; |
| 372 | } |
| 373 | |
| 374 | mForceSetScissor = false; |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | void Renderer11::applyRenderTarget(gl::Framebuffer *frameBuffer) |
| 378 | { |
| 379 | // TODO |
| 380 | UNIMPLEMENTED(); |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 381 | |
| 382 | mForceSetScissor = true; |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 383 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 384 | |
daniel@transgaming.com | d084c62 | 2012-11-28 19:36:05 +0000 | [diff] [blame] | 385 | void Renderer11::clear(GLbitfield mask, const gl::Color &colorClear, float depthClear, int stencilClear, |
| 386 | gl::Framebuffer *frameBuffer) |
| 387 | { |
| 388 | // TODO |
| 389 | UNIMPLEMENTED(); |
| 390 | } |
| 391 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 392 | void Renderer11::releaseDeviceResources() |
| 393 | { |
| 394 | // TODO |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 395 | // UNIMPLEMENTED(); |
daniel@transgaming.com | f8ba109 | 2012-11-28 19:37:53 +0000 | [diff] [blame] | 396 | mStateCache.clear(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | void Renderer11::markDeviceLost() |
| 400 | { |
| 401 | mDeviceLost = true; |
| 402 | } |
| 403 | |
| 404 | bool Renderer11::isDeviceLost() |
| 405 | { |
| 406 | return mDeviceLost; |
| 407 | } |
| 408 | |
| 409 | // set notify to true to broadcast a message to all contexts of the device loss |
| 410 | bool Renderer11::testDeviceLost(bool notify) |
| 411 | { |
| 412 | bool isLost = false; |
| 413 | |
| 414 | // TODO |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 415 | //UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 416 | |
| 417 | if (isLost) |
| 418 | { |
| 419 | // ensure we note the device loss -- |
| 420 | // we'll probably get this done again by markDeviceLost |
| 421 | // but best to remember it! |
| 422 | // Note that we don't want to clear the device loss status here |
| 423 | // -- this needs to be done by resetDevice |
| 424 | mDeviceLost = true; |
| 425 | if (notify) |
| 426 | { |
| 427 | mDisplay->notifyDeviceLost(); |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | return isLost; |
| 432 | } |
| 433 | |
| 434 | bool Renderer11::testDeviceResettable() |
| 435 | { |
| 436 | HRESULT status = D3D_OK; |
| 437 | |
| 438 | // TODO |
| 439 | UNIMPLEMENTED(); |
| 440 | |
| 441 | switch (status) |
| 442 | { |
| 443 | case D3DERR_DEVICENOTRESET: |
| 444 | case D3DERR_DEVICEHUNG: |
| 445 | return true; |
| 446 | default: |
| 447 | return false; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | bool Renderer11::resetDevice() |
| 452 | { |
| 453 | releaseDeviceResources(); |
| 454 | |
| 455 | // TODO |
| 456 | UNIMPLEMENTED(); |
| 457 | |
| 458 | // reset device defaults |
| 459 | initializeDevice(); |
| 460 | mDeviceLost = false; |
| 461 | |
daniel@transgaming.com | f8ba109 | 2012-11-28 19:37:53 +0000 | [diff] [blame] | 462 | mForceSetBlendState = true; |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 463 | mForceSetRasterState = true; |
daniel@transgaming.com | 5503fd0 | 2012-11-28 19:38:57 +0000 | [diff] [blame^] | 464 | mForceSetDepthStencilState = true; |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 465 | mForceSetScissor = true; |
daniel@transgaming.com | f8ba109 | 2012-11-28 19:37:53 +0000 | [diff] [blame] | 466 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 467 | return true; |
| 468 | } |
| 469 | |
| 470 | DWORD Renderer11::getAdapterVendor() const |
| 471 | { |
| 472 | // TODO |
| 473 | UNIMPLEMENTED(); |
| 474 | return 0; |
| 475 | } |
| 476 | |
| 477 | const char *Renderer11::getAdapterDescription() const |
| 478 | { |
| 479 | // TODO |
| 480 | UNIMPLEMENTED(); |
| 481 | return "UNIMPLEMENTED"; |
| 482 | } |
| 483 | |
| 484 | GUID Renderer11::getAdapterIdentifier() const |
| 485 | { |
| 486 | // TODO |
| 487 | UNIMPLEMENTED(); |
| 488 | GUID foo = {}; |
| 489 | return foo; |
| 490 | } |
| 491 | |
| 492 | bool Renderer11::getDXT1TextureSupport() |
| 493 | { |
| 494 | // TODO |
| 495 | UNIMPLEMENTED(); |
| 496 | return false; |
| 497 | } |
| 498 | |
| 499 | bool Renderer11::getDXT3TextureSupport() |
| 500 | { |
| 501 | // TODO |
| 502 | UNIMPLEMENTED(); |
| 503 | return false; |
| 504 | } |
| 505 | |
| 506 | bool Renderer11::getDXT5TextureSupport() |
| 507 | { |
| 508 | // TODO |
| 509 | UNIMPLEMENTED(); |
| 510 | return false; |
| 511 | } |
| 512 | |
| 513 | bool Renderer11::getDepthTextureSupport() const |
| 514 | { |
| 515 | // TODO |
| 516 | UNIMPLEMENTED(); |
| 517 | return false; |
| 518 | } |
| 519 | |
| 520 | bool Renderer11::getFloat32TextureSupport(bool *filtering, bool *renderable) |
| 521 | { |
| 522 | // TODO |
| 523 | UNIMPLEMENTED(); |
| 524 | |
| 525 | *filtering = false; |
| 526 | *renderable = false; |
| 527 | return false; |
| 528 | } |
| 529 | |
| 530 | bool Renderer11::getFloat16TextureSupport(bool *filtering, bool *renderable) |
| 531 | { |
| 532 | // TODO |
| 533 | UNIMPLEMENTED(); |
| 534 | |
| 535 | *filtering = false; |
| 536 | *renderable = false; |
| 537 | return false; |
| 538 | } |
| 539 | |
| 540 | bool Renderer11::getLuminanceTextureSupport() |
| 541 | { |
| 542 | // TODO |
| 543 | UNIMPLEMENTED(); |
| 544 | return false; |
| 545 | } |
| 546 | |
| 547 | bool Renderer11::getLuminanceAlphaTextureSupport() |
| 548 | { |
| 549 | // TODO |
| 550 | UNIMPLEMENTED(); |
| 551 | return false; |
| 552 | } |
| 553 | |
| 554 | bool Renderer11::getTextureFilterAnisotropySupport() const |
| 555 | { |
| 556 | // TODO |
| 557 | UNIMPLEMENTED(); |
| 558 | return false; |
| 559 | } |
| 560 | |
| 561 | float Renderer11::getTextureMaxAnisotropy() const |
| 562 | { |
| 563 | // TODO |
| 564 | UNIMPLEMENTED(); |
| 565 | return 1.0f; |
| 566 | } |
| 567 | |
| 568 | bool Renderer11::getEventQuerySupport() |
| 569 | { |
| 570 | // TODO |
| 571 | UNIMPLEMENTED(); |
| 572 | return false; |
| 573 | } |
| 574 | |
| 575 | bool Renderer11::getVertexTextureSupport() const |
| 576 | { |
| 577 | // TODO |
| 578 | UNIMPLEMENTED(); |
| 579 | return false; |
| 580 | } |
| 581 | |
| 582 | bool Renderer11::getNonPower2TextureSupport() const |
| 583 | { |
| 584 | // TODO |
| 585 | UNIMPLEMENTED(); |
| 586 | return false; |
| 587 | } |
| 588 | |
| 589 | bool Renderer11::getOcclusionQuerySupport() const |
| 590 | { |
| 591 | // TODO |
| 592 | UNIMPLEMENTED(); |
| 593 | return false; |
| 594 | } |
| 595 | |
| 596 | bool Renderer11::getInstancingSupport() const |
| 597 | { |
| 598 | // TODO |
| 599 | UNIMPLEMENTED(); |
| 600 | return false; |
| 601 | } |
| 602 | |
| 603 | bool Renderer11::getShareHandleSupport() const |
| 604 | { |
| 605 | // TODO |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 606 | //UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 607 | |
| 608 | // PIX doesn't seem to support using share handles, so disable them. |
| 609 | return false && !gl::perfActive(); |
| 610 | } |
| 611 | |
| 612 | bool Renderer11::getShaderModel3Support() const |
| 613 | { |
| 614 | // TODO |
| 615 | UNIMPLEMENTED(); |
| 616 | return true; |
| 617 | } |
| 618 | |
| 619 | float Renderer11::getMaxPointSize() const |
| 620 | { |
| 621 | // TODO |
| 622 | UNIMPLEMENTED(); |
| 623 | return 1.0f; |
| 624 | } |
| 625 | |
| 626 | int Renderer11::getMaxTextureWidth() const |
| 627 | { |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 628 | switch (mFeatureLevel) |
| 629 | { |
| 630 | case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 16384 |
| 631 | case D3D_FEATURE_LEVEL_10_1: |
| 632 | case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 8192 |
| 633 | default: UNREACHABLE(); return 0; |
| 634 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | int Renderer11::getMaxTextureHeight() const |
| 638 | { |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 639 | switch (mFeatureLevel) |
| 640 | { |
| 641 | case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 16384 |
| 642 | case D3D_FEATURE_LEVEL_10_1: |
| 643 | case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 8192 |
| 644 | default: UNREACHABLE(); return 0; |
| 645 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 646 | } |
| 647 | |
| 648 | bool Renderer11::get32BitIndexSupport() const |
| 649 | { |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 650 | switch (mFeatureLevel) |
| 651 | { |
| 652 | case D3D_FEATURE_LEVEL_11_0: |
| 653 | case D3D_FEATURE_LEVEL_10_1: |
| 654 | case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP >= 32; // true |
| 655 | default: UNREACHABLE(); return false; |
| 656 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | int Renderer11::getMinSwapInterval() const |
| 660 | { |
daniel@transgaming.com | 8c7b1a9 | 2012-11-28 19:34:06 +0000 | [diff] [blame] | 661 | return 0; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | int Renderer11::getMaxSwapInterval() const |
| 665 | { |
daniel@transgaming.com | 8c7b1a9 | 2012-11-28 19:34:06 +0000 | [diff] [blame] | 666 | return 4; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | int Renderer11::getMaxSupportedSamples() const |
| 670 | { |
| 671 | // TODO |
| 672 | UNIMPLEMENTED(); |
| 673 | return 1; |
| 674 | } |
| 675 | |
daniel@transgaming.com | 31b13e1 | 2012-11-28 19:34:30 +0000 | [diff] [blame] | 676 | bool Renderer11::copyToRenderTarget(TextureStorage2D *dest, TextureStorage2D *source) |
daniel@transgaming.com | ad6aee7 | 2012-11-28 19:33:42 +0000 | [diff] [blame] | 677 | { |
| 678 | // TODO |
| 679 | UNIMPLEMENTED(); |
| 680 | return false; |
| 681 | } |
| 682 | |
daniel@transgaming.com | 31b13e1 | 2012-11-28 19:34:30 +0000 | [diff] [blame] | 683 | bool Renderer11::copyToRenderTarget(TextureStorageCubeMap *dest, TextureStorageCubeMap *source) |
daniel@transgaming.com | ad6aee7 | 2012-11-28 19:33:42 +0000 | [diff] [blame] | 684 | { |
| 685 | // TODO |
| 686 | UNIMPLEMENTED(); |
| 687 | return false; |
| 688 | } |
| 689 | |
daniel@transgaming.com | 3838088 | 2012-11-28 19:36:39 +0000 | [diff] [blame] | 690 | bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, |
| 691 | GLint xoffset, GLint yoffset, TextureStorage2D *storage, GLint level) |
| 692 | { |
| 693 | // TODO |
| 694 | UNIMPLEMENTED(); |
| 695 | return false; |
| 696 | } |
| 697 | |
| 698 | bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, |
| 699 | GLint xoffset, GLint yoffset, TextureStorageCubeMap *storage, GLenum target, GLint level) |
| 700 | { |
| 701 | // TODO |
| 702 | UNIMPLEMENTED(); |
| 703 | return false; |
| 704 | } |
| 705 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 706 | } |