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 | 5367004 | 2012-11-28 20:55:51 +0000 | [diff] [blame] | 13 | #include "libGLESv2/Program.h" |
| 14 | #include "libGLESv2/ProgramBinary.h" |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 15 | #include "libGLESv2/renderer/Renderer11.h" |
daniel@transgaming.com | b6b27bc | 2012-11-28 20:54:30 +0000 | [diff] [blame] | 16 | #include "libGLESv2/renderer/RenderTarget11.h" |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 17 | #include "libGLESv2/renderer/renderer11_utils.h" |
daniel@transgaming.com | a60160b | 2012-11-28 19:41:15 +0000 | [diff] [blame] | 18 | #include "libGLESv2/renderer/SwapChain11.h" |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 19 | |
| 20 | #include "libEGL/Config.h" |
| 21 | #include "libEGL/Display.h" |
| 22 | |
| 23 | namespace rx |
| 24 | { |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 25 | static const DXGI_FORMAT RenderTargetFormats[] = |
| 26 | { |
| 27 | DXGI_FORMAT_R8G8B8A8_UNORM |
| 28 | }; |
| 29 | |
| 30 | static const DXGI_FORMAT DepthStencilFormats[] = |
| 31 | { |
| 32 | DXGI_FORMAT_D24_UNORM_S8_UINT |
| 33 | }; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 34 | |
| 35 | Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc(hDc) |
| 36 | { |
| 37 | mD3d11Module = NULL; |
| 38 | mDxgiModule = NULL; |
| 39 | |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 40 | mDeviceLost = false; |
| 41 | |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 42 | mDevice = NULL; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 43 | mDeviceContext = NULL; |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 44 | mDxgiAdapter = NULL; |
| 45 | mDxgiFactory = NULL; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | Renderer11::~Renderer11() |
| 49 | { |
| 50 | releaseDeviceResources(); |
| 51 | |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 52 | if (mDxgiFactory) |
| 53 | { |
| 54 | mDxgiFactory->Release(); |
| 55 | mDxgiFactory = NULL; |
| 56 | } |
| 57 | |
| 58 | if (mDxgiAdapter) |
| 59 | { |
| 60 | mDxgiAdapter->Release(); |
| 61 | mDxgiAdapter = NULL; |
| 62 | } |
| 63 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 64 | if (mDeviceContext) |
| 65 | { |
| 66 | mDeviceContext->Release(); |
| 67 | mDeviceContext = NULL; |
| 68 | } |
| 69 | |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 70 | if (mDevice) |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 71 | { |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 72 | mDevice->Release(); |
| 73 | mDevice = NULL; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | if (mD3d11Module) |
| 77 | { |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 78 | FreeLibrary(mD3d11Module); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 79 | mD3d11Module = NULL; |
| 80 | } |
| 81 | |
| 82 | if (mDxgiModule) |
| 83 | { |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 84 | FreeLibrary(mDxgiModule); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 85 | mDxgiModule = NULL; |
| 86 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 87 | } |
| 88 | |
daniel@transgaming.com | b64ed28 | 2012-11-28 20:54:02 +0000 | [diff] [blame] | 89 | Renderer11 *Renderer11::makeRenderer11(Renderer *renderer) |
| 90 | { |
| 91 | ASSERT(dynamic_cast<rx::Renderer11*>(renderer) != NULL); |
| 92 | return static_cast<rx::Renderer11*>(renderer); |
| 93 | } |
| 94 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 95 | EGLint Renderer11::initialize() |
| 96 | { |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 97 | mDxgiModule = LoadLibrary(TEXT("dxgi.dll")); |
| 98 | mD3d11Module = LoadLibrary(TEXT("d3d11.dll")); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 99 | |
| 100 | if (mD3d11Module == NULL || mDxgiModule == NULL) |
| 101 | { |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 102 | ERR("Could not load D3D11 or DXGI library - aborting!\n"); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 103 | return EGL_NOT_INITIALIZED; |
| 104 | } |
| 105 | |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 106 | 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] | 107 | |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 108 | if (D3D11CreateDevice == NULL) |
| 109 | { |
| 110 | ERR("Could not retrieve D3D11CreateDevice address - aborting!\n"); |
| 111 | return EGL_NOT_INITIALIZED; |
| 112 | } |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 113 | |
| 114 | D3D_FEATURE_LEVEL featureLevel[] = |
| 115 | { |
| 116 | D3D_FEATURE_LEVEL_11_0, |
| 117 | D3D_FEATURE_LEVEL_10_1, |
| 118 | D3D_FEATURE_LEVEL_10_0, |
| 119 | }; |
| 120 | |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 121 | HRESULT result = D3D11CreateDevice(NULL, |
| 122 | D3D_DRIVER_TYPE_HARDWARE, |
| 123 | NULL, |
daniel@transgaming.com | a60160b | 2012-11-28 19:41:15 +0000 | [diff] [blame] | 124 | #if defined(_DEBUG) |
| 125 | D3D11_CREATE_DEVICE_DEBUG, |
| 126 | #else |
| 127 | 0, |
| 128 | #endif |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 129 | featureLevel, |
| 130 | sizeof(featureLevel)/sizeof(featureLevel[0]), |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 131 | D3D11_SDK_VERSION, |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 132 | &mDevice, |
| 133 | &mFeatureLevel, |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 134 | &mDeviceContext); |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 135 | |
| 136 | if (!mDevice || FAILED(result)) |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 137 | { |
| 138 | ERR("Could not create D3D11 device - aborting!\n"); |
| 139 | return EGL_NOT_INITIALIZED; // Cleanup done by destructor through glDestroyRenderer |
| 140 | } |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 141 | |
| 142 | IDXGIDevice *dxgiDevice = NULL; |
| 143 | result = mDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice); |
| 144 | |
| 145 | if (FAILED(result)) |
| 146 | { |
| 147 | ERR("Could not query DXGI device - aborting!\n"); |
| 148 | return EGL_NOT_INITIALIZED; |
| 149 | } |
| 150 | |
| 151 | result = dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&mDxgiAdapter); |
| 152 | |
| 153 | if (FAILED(result)) |
| 154 | { |
| 155 | ERR("Could not retrieve DXGI adapter - aborting!\n"); |
| 156 | return EGL_NOT_INITIALIZED; |
| 157 | } |
| 158 | |
| 159 | dxgiDevice->Release(); |
| 160 | |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 161 | mDxgiAdapter->GetDesc(&mAdapterDescription); |
| 162 | memset(mDescription, 0, sizeof(mDescription)); |
| 163 | wcstombs(mDescription, mAdapterDescription.Description, sizeof(mDescription) - 1); |
| 164 | |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 165 | result = mDxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&mDxgiFactory); |
| 166 | |
| 167 | if (!mDxgiFactory || FAILED(result)) |
| 168 | { |
| 169 | ERR("Could not create DXGI factory - aborting!\n"); |
| 170 | return EGL_NOT_INITIALIZED; |
| 171 | } |
| 172 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 173 | initializeDevice(); |
| 174 | |
| 175 | return EGL_SUCCESS; |
| 176 | } |
| 177 | |
| 178 | // do any one-time device initialization |
| 179 | // NOTE: this is also needed after a device lost/reset |
| 180 | // to reset the scene status and ensure the default states are reset. |
| 181 | void Renderer11::initializeDevice() |
| 182 | { |
daniel@transgaming.com | f8ba109 | 2012-11-28 19:37:53 +0000 | [diff] [blame] | 183 | mStateCache.initialize(mDevice); |
| 184 | |
daniel@transgaming.com | c43a605 | 2012-11-28 19:41:51 +0000 | [diff] [blame] | 185 | markAllStateDirty(); |
| 186 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 187 | // Permanent non-default states |
| 188 | // TODO |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 189 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 190 | } |
| 191 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 192 | int Renderer11::generateConfigs(ConfigDesc **configDescList) |
| 193 | { |
daniel@transgaming.com | e3e826d | 2012-11-28 19:42:35 +0000 | [diff] [blame] | 194 | unsigned int numRenderFormats = sizeof(RenderTargetFormats) / sizeof(RenderTargetFormats[0]); |
| 195 | unsigned int numDepthFormats = sizeof(DepthStencilFormats) / sizeof(DepthStencilFormats[0]); |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 196 | (*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats]; |
| 197 | int numConfigs = 0; |
| 198 | |
daniel@transgaming.com | e3e826d | 2012-11-28 19:42:35 +0000 | [diff] [blame] | 199 | for (unsigned int formatIndex = 0; formatIndex < numRenderFormats; formatIndex++) |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 200 | { |
daniel@transgaming.com | e3e826d | 2012-11-28 19:42:35 +0000 | [diff] [blame] | 201 | for (unsigned int depthStencilIndex = 0; depthStencilIndex < numDepthFormats; depthStencilIndex++) |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 202 | { |
| 203 | DXGI_FORMAT renderTargetFormat = RenderTargetFormats[formatIndex]; |
| 204 | |
| 205 | UINT formatSupport = 0; |
| 206 | HRESULT result = mDevice->CheckFormatSupport(renderTargetFormat, &formatSupport); |
| 207 | |
| 208 | if (SUCCEEDED(result) && (formatSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET)) |
| 209 | { |
| 210 | DXGI_FORMAT depthStencilFormat = DepthStencilFormats[depthStencilIndex]; |
| 211 | |
| 212 | UINT formatSupport = 0; |
| 213 | HRESULT result = mDevice->CheckFormatSupport(depthStencilFormat, &formatSupport); |
| 214 | |
| 215 | if (SUCCEEDED(result) && (formatSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL)) |
| 216 | { |
| 217 | ConfigDesc newConfig; |
| 218 | newConfig.renderTargetFormat = d3d11_gl::ConvertBackBufferFormat(renderTargetFormat); |
| 219 | newConfig.depthStencilFormat = d3d11_gl::ConvertDepthStencilFormat(depthStencilFormat); |
| 220 | newConfig.multiSample = 0; // FIXME: enumerate multi-sampling |
| 221 | newConfig.fastConfig = true; // Assume all DX11 format conversions to be fast |
| 222 | |
| 223 | (*configDescList)[numConfigs++] = newConfig; |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | return numConfigs; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | void Renderer11::deleteConfigs(ConfigDesc *configDescList) |
| 233 | { |
| 234 | delete [] (configDescList); |
| 235 | } |
| 236 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 237 | void Renderer11::sync(bool block) |
| 238 | { |
| 239 | // TODO |
| 240 | UNIMPLEMENTED(); |
| 241 | } |
| 242 | |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 243 | SwapChain *Renderer11::createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) |
| 244 | { |
daniel@transgaming.com | a60160b | 2012-11-28 19:41:15 +0000 | [diff] [blame] | 245 | return new rx::SwapChain11(this, window, shareHandle, backBufferFormat, depthBufferFormat); |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 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 | 237bc7e | 2012-11-28 21:01:06 +0000 | [diff] [blame] | 260 | void Renderer11::setRasterizerState(const gl::RasterizerState &rasterState) |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 261 | { |
daniel@transgaming.com | 237bc7e | 2012-11-28 21:01:06 +0000 | [diff] [blame] | 262 | if (mForceSetRasterState || memcmp(&rasterState, &mCurRasterState, sizeof(gl::RasterizerState)) != 0) |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 263 | { |
daniel@transgaming.com | 237bc7e | 2012-11-28 21:01:06 +0000 | [diff] [blame] | 264 | ID3D11RasterizerState *dxRasterState = mStateCache.getRasterizerState(rasterState, mCurDepthSize); |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 265 | if (!dxRasterState) |
| 266 | { |
| 267 | ERR("NULL blend state returned by RenderStateCache::getRasterizerState, setting the " |
| 268 | "rasterizer state."); |
| 269 | } |
| 270 | |
| 271 | mDeviceContext->RSSetState(dxRasterState); |
| 272 | |
| 273 | if (dxRasterState) |
| 274 | { |
| 275 | dxRasterState->Release(); |
| 276 | } |
| 277 | mCurRasterState = rasterState; |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | mForceSetRasterState = false; |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | void Renderer11::setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor, |
| 284 | unsigned int sampleMask) |
| 285 | { |
daniel@transgaming.com | f8ba109 | 2012-11-28 19:37:53 +0000 | [diff] [blame] | 286 | if (mForceSetBlendState || |
| 287 | memcmp(&blendState, &mCurBlendState, sizeof(gl::BlendState)) != 0 || |
| 288 | memcmp(&blendColor, &mCurBlendColor, sizeof(gl::Color)) != 0 || |
| 289 | sampleMask != mCurSampleMask) |
| 290 | { |
| 291 | ID3D11BlendState *dxBlendState = mStateCache.getBlendState(blendState); |
| 292 | if (!dxBlendState) |
| 293 | { |
| 294 | ERR("NULL blend state returned by RenderStateCache::getBlendState, setting the default " |
| 295 | "blend state."); |
| 296 | } |
| 297 | |
| 298 | const float blendColors[] = { blendColor.red, blendColor.green, blendColor.blue, blendColor.alpha }; |
| 299 | mDeviceContext->OMSetBlendState(dxBlendState, blendColors, sampleMask); |
| 300 | |
| 301 | if (dxBlendState) |
| 302 | { |
| 303 | dxBlendState->Release(); |
| 304 | } |
| 305 | mCurBlendState = blendState; |
| 306 | mCurBlendColor = blendColor; |
| 307 | mCurSampleMask = sampleMask; |
| 308 | } |
| 309 | |
| 310 | mForceSetBlendState = false; |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 311 | } |
| 312 | |
daniel@transgaming.com | 08c331d | 2012-11-28 19:38:39 +0000 | [diff] [blame] | 313 | void Renderer11::setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef, |
daniel@transgaming.com | 3a0ef48 | 2012-11-28 21:01:20 +0000 | [diff] [blame] | 314 | int stencilBackRef, bool frontFaceCCW) |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 315 | { |
daniel@transgaming.com | 5503fd0 | 2012-11-28 19:38:57 +0000 | [diff] [blame] | 316 | if (mForceSetDepthStencilState || |
| 317 | memcmp(&depthStencilState, &mCurDepthStencilState, sizeof(gl::DepthStencilState)) != 0 || |
| 318 | stencilRef != mCurStencilRef || stencilBackRef != mCurStencilBackRef) |
| 319 | { |
| 320 | if (depthStencilState.stencilWritemask != depthStencilState.stencilBackWritemask || |
| 321 | stencilRef != stencilBackRef || |
| 322 | depthStencilState.stencilMask != depthStencilState.stencilBackMask) |
| 323 | { |
| 324 | ERR("Separate front/back stencil writemasks, reference values, or stencil mask values are " |
| 325 | "invalid under WebGL."); |
| 326 | return error(GL_INVALID_OPERATION); |
| 327 | } |
| 328 | |
| 329 | ID3D11DepthStencilState *dxDepthStencilState = mStateCache.getDepthStencilState(depthStencilState); |
| 330 | if (!dxDepthStencilState) |
| 331 | { |
| 332 | ERR("NULL depth stencil state returned by RenderStateCache::getDepthStencilState, " |
| 333 | "setting the default depth stencil state."); |
| 334 | } |
| 335 | |
| 336 | mDeviceContext->OMSetDepthStencilState(dxDepthStencilState, static_cast<UINT>(stencilRef)); |
| 337 | |
| 338 | if (dxDepthStencilState) |
| 339 | { |
| 340 | dxDepthStencilState->Release(); |
| 341 | } |
| 342 | mCurDepthStencilState = depthStencilState; |
| 343 | mCurStencilRef = stencilRef; |
| 344 | mCurStencilBackRef = stencilBackRef; |
| 345 | } |
| 346 | |
| 347 | mForceSetDepthStencilState = false; |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 348 | } |
| 349 | |
daniel@transgaming.com | 04f1b33 | 2012-11-28 21:00:40 +0000 | [diff] [blame] | 350 | void Renderer11::setScissorRectangle(const gl::Rectangle &scissor) |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 351 | { |
daniel@transgaming.com | 04f1b33 | 2012-11-28 21:00:40 +0000 | [diff] [blame] | 352 | if (mForceSetScissor || memcmp(&scissor, &mCurScissor, sizeof(gl::Rectangle)) != 0) |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 353 | { |
| 354 | D3D11_RECT rect; |
daniel@transgaming.com | 04f1b33 | 2012-11-28 21:00:40 +0000 | [diff] [blame] | 355 | rect.left = gl::clamp(scissor.x, 0, static_cast<int>(mRenderTargetDesc.width)); |
| 356 | rect.top = gl::clamp(scissor.y, 0, static_cast<int>(mRenderTargetDesc.height)); |
| 357 | rect.right = gl::clamp(scissor.x + scissor.width, 0, static_cast<int>(mRenderTargetDesc.width)); |
| 358 | rect.bottom = gl::clamp(scissor.y + scissor.height, 0, static_cast<int>(mRenderTargetDesc.height)); |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 359 | |
| 360 | mDeviceContext->RSSetScissorRects(1, &rect); |
| 361 | |
| 362 | mCurScissor = scissor; |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | mForceSetScissor = false; |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 366 | } |
| 367 | |
daniel@transgaming.com | 4c4ce23 | 2012-11-28 21:01:40 +0000 | [diff] [blame^] | 368 | bool Renderer11::setViewport(const gl::Rectangle &viewport, float zNear, float zFar, bool ignoreViewport, |
daniel@transgaming.com | 83e80ee | 2012-11-28 19:40:53 +0000 | [diff] [blame] | 369 | gl::ProgramBinary *currentProgram, bool forceSetUniforms) |
| 370 | { |
daniel@transgaming.com | 4c4ce23 | 2012-11-28 21:01:40 +0000 | [diff] [blame^] | 371 | gl::Rectangle actualViewport = viewport; |
| 372 | float actualZNear = gl::clamp01(zNear); |
| 373 | float actualZFar = gl::clamp01(zFar); |
| 374 | if (ignoreViewport) |
| 375 | { |
| 376 | actualViewport.x = 0; |
| 377 | actualViewport.y = 0; |
| 378 | actualViewport.width = mRenderTargetDesc.width; |
| 379 | actualViewport.height = mRenderTargetDesc.height; |
| 380 | actualZNear = 0.0f; |
| 381 | actualZFar = 1.0f; |
| 382 | } |
daniel@transgaming.com | 5367004 | 2012-11-28 20:55:51 +0000 | [diff] [blame] | 383 | |
| 384 | D3D11_VIEWPORT dxViewport; |
daniel@transgaming.com | 4c4ce23 | 2012-11-28 21:01:40 +0000 | [diff] [blame^] | 385 | dxViewport.TopLeftX = gl::clamp(actualViewport.x, 0, static_cast<int>(mRenderTargetDesc.width)); |
| 386 | dxViewport.TopLeftY = gl::clamp(actualViewport.y, 0, static_cast<int>(mRenderTargetDesc.height)); |
| 387 | dxViewport.Width = gl::clamp(actualViewport.width, 0, static_cast<int>(mRenderTargetDesc.width) - static_cast<int>(dxViewport.TopLeftX)); |
| 388 | dxViewport.Height = gl::clamp(actualViewport.height, 0, static_cast<int>(mRenderTargetDesc.height) - static_cast<int>(dxViewport.TopLeftY)); |
| 389 | dxViewport.MinDepth = actualZNear; |
| 390 | dxViewport.MaxDepth = actualZFar; |
daniel@transgaming.com | 5367004 | 2012-11-28 20:55:51 +0000 | [diff] [blame] | 391 | |
| 392 | if (dxViewport.Width <= 0 || dxViewport.Height <= 0) |
| 393 | { |
| 394 | return false; // Nothing to render |
| 395 | } |
| 396 | |
daniel@transgaming.com | 4c4ce23 | 2012-11-28 21:01:40 +0000 | [diff] [blame^] | 397 | bool viewportChanged = mForceSetViewport || memcmp(&actualViewport, &mCurViewport, sizeof(gl::Rectangle)) != 0 || |
| 398 | actualZNear != mCurNear || actualZFar != mCurFar; |
| 399 | |
daniel@transgaming.com | 5367004 | 2012-11-28 20:55:51 +0000 | [diff] [blame] | 400 | if (viewportChanged) |
| 401 | { |
| 402 | mDeviceContext->RSSetViewports(1, &dxViewport); |
| 403 | |
daniel@transgaming.com | 4c4ce23 | 2012-11-28 21:01:40 +0000 | [diff] [blame^] | 404 | mCurViewport = actualViewport; |
| 405 | mCurNear = actualZNear; |
| 406 | mCurFar = actualZFar; |
daniel@transgaming.com | 5367004 | 2012-11-28 20:55:51 +0000 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | if (currentProgram && (viewportChanged || forceSetUniforms)) |
| 410 | { |
| 411 | GLint halfPixelSize = currentProgram->getDxHalfPixelSizeLocation(); |
| 412 | GLfloat xy[2] = { 0.0f, 0.0f }; |
| 413 | currentProgram->setUniform2fv(halfPixelSize, 1, xy); |
| 414 | |
| 415 | // These values are used for computing gl_FragCoord in Program::linkVaryings(). |
| 416 | GLint coord = currentProgram->getDxCoordLocation(); |
daniel@transgaming.com | 4c4ce23 | 2012-11-28 21:01:40 +0000 | [diff] [blame^] | 417 | GLfloat whxy[4] = { actualViewport.width * 0.5f, |
| 418 | actualViewport.height * 0.5f, |
| 419 | actualViewport.x + (actualViewport.width * 0.5f), |
| 420 | actualViewport.y + (actualViewport.height * 0.5f) }; |
daniel@transgaming.com | 5367004 | 2012-11-28 20:55:51 +0000 | [diff] [blame] | 421 | currentProgram->setUniform4fv(coord, 1, whxy); |
| 422 | |
| 423 | GLint depth = currentProgram->getDxDepthLocation(); |
daniel@transgaming.com | 4c4ce23 | 2012-11-28 21:01:40 +0000 | [diff] [blame^] | 424 | GLfloat dz[2] = { (actualZFar - actualZNear) * 0.5f, (actualZNear + actualZFar) * 0.5f }; |
daniel@transgaming.com | 5367004 | 2012-11-28 20:55:51 +0000 | [diff] [blame] | 425 | currentProgram->setUniform2fv(depth, 1, dz); |
| 426 | |
| 427 | GLint depthRange = currentProgram->getDxDepthRangeLocation(); |
daniel@transgaming.com | 4c4ce23 | 2012-11-28 21:01:40 +0000 | [diff] [blame^] | 428 | GLfloat nearFarDiff[3] = { actualZNear, actualZFar, actualZFar - actualZNear }; |
daniel@transgaming.com | 5367004 | 2012-11-28 20:55:51 +0000 | [diff] [blame] | 429 | currentProgram->setUniform3fv(depthRange, 1, nearFarDiff); |
| 430 | } |
| 431 | |
| 432 | mForceSetViewport = false; |
daniel@transgaming.com | 83e80ee | 2012-11-28 19:40:53 +0000 | [diff] [blame] | 433 | return true; |
| 434 | } |
| 435 | |
daniel@transgaming.com | 91207b7 | 2012-11-28 20:56:43 +0000 | [diff] [blame] | 436 | bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count) |
| 437 | { |
| 438 | // TODO |
| 439 | UNIMPLEMENTED(); |
| 440 | |
| 441 | return false; |
| 442 | } |
| 443 | |
| 444 | bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 445 | { |
| 446 | // TODO |
| 447 | UNIMPLEMENTED(); |
daniel@transgaming.com | dcf1e67 | 2012-11-28 19:38:19 +0000 | [diff] [blame] | 448 | |
| 449 | mForceSetScissor = true; |
daniel@transgaming.com | 5367004 | 2012-11-28 20:55:51 +0000 | [diff] [blame] | 450 | mForceSetViewport = true; |
daniel@transgaming.com | ae39ee2 | 2012-11-28 19:42:02 +0000 | [diff] [blame] | 451 | |
| 452 | return true; |
daniel@transgaming.com | 493d4f8 | 2012-11-28 19:35:45 +0000 | [diff] [blame] | 453 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 454 | |
daniel@transgaming.com | 91207b7 | 2012-11-28 20:56:43 +0000 | [diff] [blame] | 455 | GLenum Renderer11::applyVertexBuffer(gl::ProgramBinary *programBinary, gl::VertexAttribute vertexAttributes[], GLint first, GLsizei count, GLsizei instances) |
daniel@transgaming.com | def9f0f | 2012-11-28 20:53:20 +0000 | [diff] [blame] | 456 | { |
| 457 | // TODO |
| 458 | UNIMPLEMENTED(); |
| 459 | |
| 460 | return GL_OUT_OF_MEMORY; |
| 461 | } |
| 462 | |
daniel@transgaming.com | 91207b7 | 2012-11-28 20:56:43 +0000 | [diff] [blame] | 463 | GLenum Renderer11::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, gl::TranslatedIndexData *indexInfo) |
| 464 | { |
| 465 | // TODO |
| 466 | UNIMPLEMENTED(); |
| 467 | |
| 468 | return GL_OUT_OF_MEMORY; |
| 469 | } |
| 470 | |
| 471 | void Renderer11::drawArrays(GLenum mode, GLsizei count, GLsizei instances) |
| 472 | { |
| 473 | // TODO |
| 474 | UNIMPLEMENTED(); |
| 475 | } |
| 476 | |
daniel@transgaming.com | 97400dd | 2012-11-28 20:57:00 +0000 | [diff] [blame] | 477 | void Renderer11::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const gl::TranslatedIndexData &indexInfo) |
daniel@transgaming.com | 91207b7 | 2012-11-28 20:56:43 +0000 | [diff] [blame] | 478 | { |
| 479 | // TODO |
| 480 | UNIMPLEMENTED(); |
| 481 | } |
| 482 | |
daniel@transgaming.com | 5fbf177 | 2012-11-28 20:54:43 +0000 | [diff] [blame] | 483 | void Renderer11::applyShaders(gl::ProgramBinary *programBinary) |
| 484 | { |
| 485 | // TODO |
| 486 | UNIMPLEMENTED(); |
| 487 | } |
| 488 | |
daniel@transgaming.com | 084a257 | 2012-11-28 20:55:17 +0000 | [diff] [blame] | 489 | void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer) |
daniel@transgaming.com | d084c62 | 2012-11-28 19:36:05 +0000 | [diff] [blame] | 490 | { |
| 491 | // TODO |
| 492 | UNIMPLEMENTED(); |
| 493 | } |
| 494 | |
daniel@transgaming.com | c43a605 | 2012-11-28 19:41:51 +0000 | [diff] [blame] | 495 | void Renderer11::markAllStateDirty() |
| 496 | { |
daniel@transgaming.com | 7b6b83e | 2012-11-28 21:00:30 +0000 | [diff] [blame] | 497 | mDepthStencilInitialized = false; |
| 498 | mRenderTargetDescInitialized = false; |
| 499 | |
daniel@transgaming.com | c43a605 | 2012-11-28 19:41:51 +0000 | [diff] [blame] | 500 | mForceSetBlendState = true; |
| 501 | mForceSetRasterState = true; |
| 502 | mForceSetDepthStencilState = true; |
| 503 | mForceSetScissor = true; |
daniel@transgaming.com | 5367004 | 2012-11-28 20:55:51 +0000 | [diff] [blame] | 504 | mForceSetViewport = true; |
daniel@transgaming.com | c43a605 | 2012-11-28 19:41:51 +0000 | [diff] [blame] | 505 | } |
| 506 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 507 | void Renderer11::releaseDeviceResources() |
| 508 | { |
| 509 | // TODO |
daniel@transgaming.com | c1e2634 | 2012-11-28 19:31:16 +0000 | [diff] [blame] | 510 | // UNIMPLEMENTED(); |
daniel@transgaming.com | f8ba109 | 2012-11-28 19:37:53 +0000 | [diff] [blame] | 511 | mStateCache.clear(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | void Renderer11::markDeviceLost() |
| 515 | { |
| 516 | mDeviceLost = true; |
| 517 | } |
| 518 | |
| 519 | bool Renderer11::isDeviceLost() |
| 520 | { |
| 521 | return mDeviceLost; |
| 522 | } |
| 523 | |
| 524 | // set notify to true to broadcast a message to all contexts of the device loss |
| 525 | bool Renderer11::testDeviceLost(bool notify) |
| 526 | { |
| 527 | bool isLost = false; |
| 528 | |
| 529 | // TODO |
daniel@transgaming.com | b9bb279 | 2012-11-28 19:36:49 +0000 | [diff] [blame] | 530 | //UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 531 | |
| 532 | if (isLost) |
| 533 | { |
| 534 | // ensure we note the device loss -- |
| 535 | // we'll probably get this done again by markDeviceLost |
| 536 | // but best to remember it! |
| 537 | // Note that we don't want to clear the device loss status here |
| 538 | // -- this needs to be done by resetDevice |
| 539 | mDeviceLost = true; |
| 540 | if (notify) |
| 541 | { |
| 542 | mDisplay->notifyDeviceLost(); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | return isLost; |
| 547 | } |
| 548 | |
| 549 | bool Renderer11::testDeviceResettable() |
| 550 | { |
| 551 | HRESULT status = D3D_OK; |
| 552 | |
| 553 | // TODO |
| 554 | UNIMPLEMENTED(); |
| 555 | |
| 556 | switch (status) |
| 557 | { |
| 558 | case D3DERR_DEVICENOTRESET: |
| 559 | case D3DERR_DEVICEHUNG: |
| 560 | return true; |
| 561 | default: |
| 562 | return false; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | bool Renderer11::resetDevice() |
| 567 | { |
| 568 | releaseDeviceResources(); |
| 569 | |
| 570 | // TODO |
| 571 | UNIMPLEMENTED(); |
| 572 | |
| 573 | // reset device defaults |
| 574 | initializeDevice(); |
| 575 | mDeviceLost = false; |
| 576 | |
| 577 | return true; |
| 578 | } |
| 579 | |
| 580 | DWORD Renderer11::getAdapterVendor() const |
| 581 | { |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 582 | return mAdapterDescription.VendorId; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | const char *Renderer11::getAdapterDescription() const |
| 586 | { |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 587 | return mDescription; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | GUID Renderer11::getAdapterIdentifier() const |
| 591 | { |
| 592 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 593 | // UNIMPLEMENTED(); |
| 594 | GUID foo = {0}; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 595 | return foo; |
| 596 | } |
| 597 | |
| 598 | bool Renderer11::getDXT1TextureSupport() |
| 599 | { |
| 600 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 601 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 602 | return false; |
| 603 | } |
| 604 | |
| 605 | bool Renderer11::getDXT3TextureSupport() |
| 606 | { |
| 607 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 608 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 609 | return false; |
| 610 | } |
| 611 | |
| 612 | bool Renderer11::getDXT5TextureSupport() |
| 613 | { |
| 614 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 615 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 616 | return false; |
| 617 | } |
| 618 | |
| 619 | bool Renderer11::getDepthTextureSupport() const |
| 620 | { |
| 621 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 622 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 623 | return false; |
| 624 | } |
| 625 | |
| 626 | bool Renderer11::getFloat32TextureSupport(bool *filtering, bool *renderable) |
| 627 | { |
| 628 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 629 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 630 | |
| 631 | *filtering = false; |
| 632 | *renderable = false; |
| 633 | return false; |
| 634 | } |
| 635 | |
| 636 | bool Renderer11::getFloat16TextureSupport(bool *filtering, bool *renderable) |
| 637 | { |
| 638 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 639 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 640 | |
| 641 | *filtering = false; |
| 642 | *renderable = false; |
| 643 | return false; |
| 644 | } |
| 645 | |
| 646 | bool Renderer11::getLuminanceTextureSupport() |
| 647 | { |
| 648 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 649 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 650 | return false; |
| 651 | } |
| 652 | |
| 653 | bool Renderer11::getLuminanceAlphaTextureSupport() |
| 654 | { |
| 655 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 656 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 657 | return false; |
| 658 | } |
| 659 | |
| 660 | bool Renderer11::getTextureFilterAnisotropySupport() const |
| 661 | { |
| 662 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 663 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 664 | return false; |
| 665 | } |
| 666 | |
| 667 | float Renderer11::getTextureMaxAnisotropy() const |
| 668 | { |
| 669 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 670 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 671 | return 1.0f; |
| 672 | } |
| 673 | |
| 674 | bool Renderer11::getEventQuerySupport() |
| 675 | { |
| 676 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 677 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 678 | return false; |
| 679 | } |
| 680 | |
| 681 | bool Renderer11::getVertexTextureSupport() const |
| 682 | { |
| 683 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 684 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 685 | return false; |
| 686 | } |
| 687 | |
| 688 | bool Renderer11::getNonPower2TextureSupport() const |
| 689 | { |
| 690 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 691 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 692 | return false; |
| 693 | } |
| 694 | |
| 695 | bool Renderer11::getOcclusionQuerySupport() const |
| 696 | { |
| 697 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 698 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 699 | return false; |
| 700 | } |
| 701 | |
| 702 | bool Renderer11::getInstancingSupport() const |
| 703 | { |
| 704 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 705 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 706 | return false; |
| 707 | } |
| 708 | |
| 709 | bool Renderer11::getShareHandleSupport() const |
| 710 | { |
| 711 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 712 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 713 | |
| 714 | // PIX doesn't seem to support using share handles, so disable them. |
| 715 | return false && !gl::perfActive(); |
| 716 | } |
| 717 | |
daniel@transgaming.com | 9549bea | 2012-11-28 20:57:23 +0000 | [diff] [blame] | 718 | int Renderer11::getMajorShaderModel() const |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 719 | { |
daniel@transgaming.com | 9549bea | 2012-11-28 20:57:23 +0000 | [diff] [blame] | 720 | switch (mFeatureLevel) |
| 721 | { |
| 722 | case D3D_FEATURE_LEVEL_11_0: return D3D11_SHADER_MAJOR_VERSION; // 5 |
| 723 | case D3D_FEATURE_LEVEL_10_1: |
| 724 | case D3D_FEATURE_LEVEL_10_0: return D3D10_SHADER_MAJOR_VERSION; // 4 |
| 725 | default: UNREACHABLE(); return 0; |
| 726 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | float Renderer11::getMaxPointSize() const |
| 730 | { |
| 731 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 732 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 733 | return 1.0f; |
| 734 | } |
| 735 | |
| 736 | int Renderer11::getMaxTextureWidth() const |
| 737 | { |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 738 | switch (mFeatureLevel) |
| 739 | { |
| 740 | case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 16384 |
| 741 | case D3D_FEATURE_LEVEL_10_1: |
| 742 | case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 8192 |
| 743 | default: UNREACHABLE(); return 0; |
| 744 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | int Renderer11::getMaxTextureHeight() const |
| 748 | { |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 749 | switch (mFeatureLevel) |
| 750 | { |
| 751 | case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 16384 |
| 752 | case D3D_FEATURE_LEVEL_10_1: |
| 753 | case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; // 8192 |
| 754 | default: UNREACHABLE(); return 0; |
| 755 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 756 | } |
| 757 | |
| 758 | bool Renderer11::get32BitIndexSupport() const |
| 759 | { |
daniel@transgaming.com | 25072f6 | 2012-11-28 19:31:32 +0000 | [diff] [blame] | 760 | switch (mFeatureLevel) |
| 761 | { |
| 762 | case D3D_FEATURE_LEVEL_11_0: |
| 763 | case D3D_FEATURE_LEVEL_10_1: |
| 764 | case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP >= 32; // true |
| 765 | default: UNREACHABLE(); return false; |
| 766 | } |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | int Renderer11::getMinSwapInterval() const |
| 770 | { |
daniel@transgaming.com | 8c7b1a9 | 2012-11-28 19:34:06 +0000 | [diff] [blame] | 771 | return 0; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | int Renderer11::getMaxSwapInterval() const |
| 775 | { |
daniel@transgaming.com | 8c7b1a9 | 2012-11-28 19:34:06 +0000 | [diff] [blame] | 776 | return 4; |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | int Renderer11::getMaxSupportedSamples() const |
| 780 | { |
| 781 | // TODO |
daniel@transgaming.com | 1f811f5 | 2012-11-28 20:57:39 +0000 | [diff] [blame] | 782 | // UNIMPLEMENTED(); |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 783 | return 1; |
| 784 | } |
| 785 | |
daniel@transgaming.com | 31b13e1 | 2012-11-28 19:34:30 +0000 | [diff] [blame] | 786 | bool Renderer11::copyToRenderTarget(TextureStorage2D *dest, TextureStorage2D *source) |
daniel@transgaming.com | ad6aee7 | 2012-11-28 19:33:42 +0000 | [diff] [blame] | 787 | { |
| 788 | // TODO |
| 789 | UNIMPLEMENTED(); |
| 790 | return false; |
| 791 | } |
| 792 | |
daniel@transgaming.com | 31b13e1 | 2012-11-28 19:34:30 +0000 | [diff] [blame] | 793 | bool Renderer11::copyToRenderTarget(TextureStorageCubeMap *dest, TextureStorageCubeMap *source) |
daniel@transgaming.com | ad6aee7 | 2012-11-28 19:33:42 +0000 | [diff] [blame] | 794 | { |
| 795 | // TODO |
| 796 | UNIMPLEMENTED(); |
| 797 | return false; |
| 798 | } |
| 799 | |
daniel@transgaming.com | 3838088 | 2012-11-28 19:36:39 +0000 | [diff] [blame] | 800 | bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, |
| 801 | GLint xoffset, GLint yoffset, TextureStorage2D *storage, GLint level) |
| 802 | { |
| 803 | // TODO |
| 804 | UNIMPLEMENTED(); |
| 805 | return false; |
| 806 | } |
| 807 | |
| 808 | bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, |
| 809 | GLint xoffset, GLint yoffset, TextureStorageCubeMap *storage, GLenum target, GLint level) |
| 810 | { |
| 811 | // TODO |
| 812 | UNIMPLEMENTED(); |
| 813 | return false; |
| 814 | } |
| 815 | |
daniel@transgaming.com | f242365 | 2012-11-28 20:53:50 +0000 | [diff] [blame] | 816 | RenderTarget *Renderer11::createRenderTarget(SwapChain *swapChain, bool depth) |
| 817 | { |
daniel@transgaming.com | b6b27bc | 2012-11-28 20:54:30 +0000 | [diff] [blame] | 818 | SwapChain11 *swapChain11 = SwapChain11::makeSwapChain11(swapChain); |
| 819 | RenderTarget11 *renderTarget = NULL; |
| 820 | if (depth) |
| 821 | { |
| 822 | renderTarget = new RenderTarget11(this, swapChain11->getDepthStencil(), swapChain11->getWidth(), swapChain11->getHeight()); |
| 823 | } |
| 824 | else |
| 825 | { |
| 826 | renderTarget = new RenderTarget11(this, swapChain11->getRenderTarget(), swapChain11->getWidth(), swapChain11->getHeight()); |
| 827 | } |
| 828 | return renderTarget; |
daniel@transgaming.com | f242365 | 2012-11-28 20:53:50 +0000 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | RenderTarget *Renderer11::createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth) |
| 832 | { |
| 833 | // TODO |
| 834 | UNIMPLEMENTED(); |
| 835 | return NULL; |
| 836 | } |
| 837 | |
daniel@transgaming.com | 5531890 | 2012-11-28 20:58:58 +0000 | [diff] [blame] | 838 | ShaderExecutable *Renderer11::loadExecutable(const DWORD *function, size_t length, GLenum type, void *data) |
| 839 | { |
| 840 | // TODO |
| 841 | UNIMPLEMENTED(); |
| 842 | return NULL; |
| 843 | } |
| 844 | |
daniel@transgaming.com | a9c7142 | 2012-11-28 20:58:45 +0000 | [diff] [blame] | 845 | ShaderExecutable *Renderer11::compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, GLenum type) |
| 846 | { |
| 847 | // TODO |
| 848 | UNIMPLEMENTED(); |
| 849 | return NULL; |
| 850 | } |
| 851 | |
daniel@transgaming.com | 6c87217 | 2012-11-28 19:39:33 +0000 | [diff] [blame] | 852 | bool Renderer11::blitRect(gl::Framebuffer *readTarget, gl::Rectangle *readRect, gl::Framebuffer *drawTarget, gl::Rectangle *drawRect, |
| 853 | bool blitRenderTarget, bool blitDepthStencil) |
| 854 | { |
| 855 | // TODO |
| 856 | UNIMPLEMENTED(); |
| 857 | return false; |
| 858 | } |
| 859 | |
| 860 | void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, |
| 861 | GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels) |
| 862 | { |
| 863 | // TODO |
| 864 | UNIMPLEMENTED(); |
| 865 | return; |
| 866 | } |
| 867 | |
daniel@transgaming.com | 1d6aff2 | 2012-11-28 19:30:42 +0000 | [diff] [blame] | 868 | } |