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" |
| 10 | #include "libGLESv2/utilities.h" |
| 11 | #include "libGLESv2/renderer/Renderer11.h" |
| 12 | |
| 13 | #include "libEGL/Config.h" |
| 14 | #include "libEGL/Display.h" |
| 15 | |
| 16 | namespace rx |
| 17 | { |
| 18 | |
| 19 | Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc(hDc) |
| 20 | { |
| 21 | mD3d11Module = NULL; |
| 22 | mDxgiModule = NULL; |
| 23 | |
| 24 | mD3d11 = NULL; |
| 25 | mDeviceContext = NULL; |
| 26 | } |
| 27 | |
| 28 | Renderer11::~Renderer11() |
| 29 | { |
| 30 | releaseDeviceResources(); |
| 31 | |
| 32 | if (mDeviceContext) |
| 33 | { |
| 34 | mDeviceContext->Release(); |
| 35 | mDeviceContext = NULL; |
| 36 | } |
| 37 | |
| 38 | if (mD3d11) |
| 39 | { |
| 40 | mD3d11->Release(); |
| 41 | mD3d11 = NULL; |
| 42 | } |
| 43 | |
| 44 | if (mD3d11Module) |
| 45 | { |
| 46 | mD3d11Module = NULL; |
| 47 | } |
| 48 | |
| 49 | if (mDxgiModule) |
| 50 | { |
| 51 | mDxgiModule = NULL; |
| 52 | } |
| 53 | |
| 54 | } |
| 55 | |
| 56 | EGLint Renderer11::initialize() |
| 57 | { |
| 58 | |
| 59 | mDxgiModule = GetModuleHandle(TEXT("dxgi.dll")); |
| 60 | mD3d11Module = GetModuleHandle(TEXT("d3d11.dll")); |
| 61 | |
| 62 | if (mD3d11Module == NULL || mDxgiModule == NULL) |
| 63 | { |
| 64 | ERR("No D3D11 or DXGI module found - aborting!\n"); |
| 65 | return EGL_NOT_INITIALIZED; |
| 66 | } |
| 67 | |
| 68 | // TODO: device creation, any one-time setup. |
| 69 | UNIMPLEMENTED(); |
| 70 | |
| 71 | initializeDevice(); |
| 72 | |
| 73 | return EGL_SUCCESS; |
| 74 | } |
| 75 | |
| 76 | // do any one-time device initialization |
| 77 | // NOTE: this is also needed after a device lost/reset |
| 78 | // to reset the scene status and ensure the default states are reset. |
| 79 | void Renderer11::initializeDevice() |
| 80 | { |
| 81 | // Permanent non-default states |
| 82 | // TODO |
| 83 | UNIMPLEMENTED(); |
| 84 | } |
| 85 | |
| 86 | |
| 87 | int Renderer11::generateConfigs(ConfigDesc **configDescList) |
| 88 | { |
| 89 | // TODO |
| 90 | UNIMPLEMENTED(); |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | void Renderer11::deleteConfigs(ConfigDesc *configDescList) |
| 95 | { |
| 96 | delete [] (configDescList); |
| 97 | } |
| 98 | |
| 99 | void Renderer11::startScene() |
| 100 | { |
| 101 | // TODO: nop in d3d11? |
| 102 | } |
| 103 | |
| 104 | void Renderer11::endScene() |
| 105 | { |
| 106 | // TODO: nop in d3d11? |
| 107 | } |
| 108 | |
| 109 | void Renderer11::sync(bool block) |
| 110 | { |
| 111 | // TODO |
| 112 | UNIMPLEMENTED(); |
| 113 | } |
| 114 | |
| 115 | void Renderer11::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &samplerState) |
| 116 | { |
| 117 | // TODO |
| 118 | UNIMPLEMENTED(); |
| 119 | } |
| 120 | |
| 121 | void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture) |
| 122 | { |
| 123 | // TODO |
| 124 | UNIMPLEMENTED(); |
| 125 | } |
| 126 | |
| 127 | |
| 128 | void Renderer11::releaseDeviceResources() |
| 129 | { |
| 130 | // TODO |
| 131 | UNIMPLEMENTED(); |
| 132 | } |
| 133 | |
| 134 | void Renderer11::markDeviceLost() |
| 135 | { |
| 136 | mDeviceLost = true; |
| 137 | } |
| 138 | |
| 139 | bool Renderer11::isDeviceLost() |
| 140 | { |
| 141 | return mDeviceLost; |
| 142 | } |
| 143 | |
| 144 | // set notify to true to broadcast a message to all contexts of the device loss |
| 145 | bool Renderer11::testDeviceLost(bool notify) |
| 146 | { |
| 147 | bool isLost = false; |
| 148 | |
| 149 | // TODO |
| 150 | UNIMPLEMENTED(); |
| 151 | |
| 152 | if (isLost) |
| 153 | { |
| 154 | // ensure we note the device loss -- |
| 155 | // we'll probably get this done again by markDeviceLost |
| 156 | // but best to remember it! |
| 157 | // Note that we don't want to clear the device loss status here |
| 158 | // -- this needs to be done by resetDevice |
| 159 | mDeviceLost = true; |
| 160 | if (notify) |
| 161 | { |
| 162 | mDisplay->notifyDeviceLost(); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | return isLost; |
| 167 | } |
| 168 | |
| 169 | bool Renderer11::testDeviceResettable() |
| 170 | { |
| 171 | HRESULT status = D3D_OK; |
| 172 | |
| 173 | // TODO |
| 174 | UNIMPLEMENTED(); |
| 175 | |
| 176 | switch (status) |
| 177 | { |
| 178 | case D3DERR_DEVICENOTRESET: |
| 179 | case D3DERR_DEVICEHUNG: |
| 180 | return true; |
| 181 | default: |
| 182 | return false; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | bool Renderer11::resetDevice() |
| 187 | { |
| 188 | releaseDeviceResources(); |
| 189 | |
| 190 | // TODO |
| 191 | UNIMPLEMENTED(); |
| 192 | |
| 193 | // reset device defaults |
| 194 | initializeDevice(); |
| 195 | mDeviceLost = false; |
| 196 | |
| 197 | return true; |
| 198 | } |
| 199 | |
| 200 | DWORD Renderer11::getAdapterVendor() const |
| 201 | { |
| 202 | // TODO |
| 203 | UNIMPLEMENTED(); |
| 204 | return 0; |
| 205 | } |
| 206 | |
| 207 | const char *Renderer11::getAdapterDescription() const |
| 208 | { |
| 209 | // TODO |
| 210 | UNIMPLEMENTED(); |
| 211 | return "UNIMPLEMENTED"; |
| 212 | } |
| 213 | |
| 214 | GUID Renderer11::getAdapterIdentifier() const |
| 215 | { |
| 216 | // TODO |
| 217 | UNIMPLEMENTED(); |
| 218 | GUID foo = {}; |
| 219 | return foo; |
| 220 | } |
| 221 | |
| 222 | bool Renderer11::getDXT1TextureSupport() |
| 223 | { |
| 224 | // TODO |
| 225 | UNIMPLEMENTED(); |
| 226 | return false; |
| 227 | } |
| 228 | |
| 229 | bool Renderer11::getDXT3TextureSupport() |
| 230 | { |
| 231 | // TODO |
| 232 | UNIMPLEMENTED(); |
| 233 | return false; |
| 234 | } |
| 235 | |
| 236 | bool Renderer11::getDXT5TextureSupport() |
| 237 | { |
| 238 | // TODO |
| 239 | UNIMPLEMENTED(); |
| 240 | return false; |
| 241 | } |
| 242 | |
| 243 | bool Renderer11::getDepthTextureSupport() const |
| 244 | { |
| 245 | // TODO |
| 246 | UNIMPLEMENTED(); |
| 247 | return false; |
| 248 | } |
| 249 | |
| 250 | bool Renderer11::getFloat32TextureSupport(bool *filtering, bool *renderable) |
| 251 | { |
| 252 | // TODO |
| 253 | UNIMPLEMENTED(); |
| 254 | |
| 255 | *filtering = false; |
| 256 | *renderable = false; |
| 257 | return false; |
| 258 | } |
| 259 | |
| 260 | bool Renderer11::getFloat16TextureSupport(bool *filtering, bool *renderable) |
| 261 | { |
| 262 | // TODO |
| 263 | UNIMPLEMENTED(); |
| 264 | |
| 265 | *filtering = false; |
| 266 | *renderable = false; |
| 267 | return false; |
| 268 | } |
| 269 | |
| 270 | bool Renderer11::getLuminanceTextureSupport() |
| 271 | { |
| 272 | // TODO |
| 273 | UNIMPLEMENTED(); |
| 274 | return false; |
| 275 | } |
| 276 | |
| 277 | bool Renderer11::getLuminanceAlphaTextureSupport() |
| 278 | { |
| 279 | // TODO |
| 280 | UNIMPLEMENTED(); |
| 281 | return false; |
| 282 | } |
| 283 | |
| 284 | bool Renderer11::getTextureFilterAnisotropySupport() const |
| 285 | { |
| 286 | // TODO |
| 287 | UNIMPLEMENTED(); |
| 288 | return false; |
| 289 | } |
| 290 | |
| 291 | float Renderer11::getTextureMaxAnisotropy() const |
| 292 | { |
| 293 | // TODO |
| 294 | UNIMPLEMENTED(); |
| 295 | return 1.0f; |
| 296 | } |
| 297 | |
| 298 | bool Renderer11::getEventQuerySupport() |
| 299 | { |
| 300 | // TODO |
| 301 | UNIMPLEMENTED(); |
| 302 | return false; |
| 303 | } |
| 304 | |
| 305 | bool Renderer11::getVertexTextureSupport() const |
| 306 | { |
| 307 | // TODO |
| 308 | UNIMPLEMENTED(); |
| 309 | return false; |
| 310 | } |
| 311 | |
| 312 | bool Renderer11::getNonPower2TextureSupport() const |
| 313 | { |
| 314 | // TODO |
| 315 | UNIMPLEMENTED(); |
| 316 | return false; |
| 317 | } |
| 318 | |
| 319 | bool Renderer11::getOcclusionQuerySupport() const |
| 320 | { |
| 321 | // TODO |
| 322 | UNIMPLEMENTED(); |
| 323 | return false; |
| 324 | } |
| 325 | |
| 326 | bool Renderer11::getInstancingSupport() const |
| 327 | { |
| 328 | // TODO |
| 329 | UNIMPLEMENTED(); |
| 330 | return false; |
| 331 | } |
| 332 | |
| 333 | bool Renderer11::getShareHandleSupport() const |
| 334 | { |
| 335 | // TODO |
| 336 | UNIMPLEMENTED(); |
| 337 | |
| 338 | // PIX doesn't seem to support using share handles, so disable them. |
| 339 | return false && !gl::perfActive(); |
| 340 | } |
| 341 | |
| 342 | bool Renderer11::getShaderModel3Support() const |
| 343 | { |
| 344 | // TODO |
| 345 | UNIMPLEMENTED(); |
| 346 | return true; |
| 347 | } |
| 348 | |
| 349 | float Renderer11::getMaxPointSize() const |
| 350 | { |
| 351 | // TODO |
| 352 | UNIMPLEMENTED(); |
| 353 | return 1.0f; |
| 354 | } |
| 355 | |
| 356 | int Renderer11::getMaxTextureWidth() const |
| 357 | { |
| 358 | // TODO |
| 359 | UNIMPLEMENTED(); |
| 360 | return 1024; |
| 361 | } |
| 362 | |
| 363 | int Renderer11::getMaxTextureHeight() const |
| 364 | { |
| 365 | // TODO |
| 366 | UNIMPLEMENTED(); |
| 367 | return 1024; |
| 368 | } |
| 369 | |
| 370 | bool Renderer11::get32BitIndexSupport() const |
| 371 | { |
| 372 | // TODO |
| 373 | UNIMPLEMENTED(); |
| 374 | return true; |
| 375 | } |
| 376 | |
| 377 | int Renderer11::getMinSwapInterval() const |
| 378 | { |
| 379 | // TODO |
| 380 | UNIMPLEMENTED(); |
| 381 | return 1; |
| 382 | } |
| 383 | |
| 384 | int Renderer11::getMaxSwapInterval() const |
| 385 | { |
| 386 | // TODO |
| 387 | UNIMPLEMENTED(); |
| 388 | return 1; |
| 389 | } |
| 390 | |
| 391 | int Renderer11::getMaxSupportedSamples() const |
| 392 | { |
| 393 | // TODO |
| 394 | UNIMPLEMENTED(); |
| 395 | return 1; |
| 396 | } |
| 397 | |
| 398 | } |