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