vpResult vprBlendStateDX11::init() { vprDeviceDX11* dx11Device = static_cast<vprDeviceDX11*>(m_device); ID3D11Device* nativeDevice = dx11Device->getNativeDevice(); D3D11_BLEND_DESC nativeDesc; ZeroMemory(&nativeDesc, sizeof(nativeDesc)); nativeDesc.AlphaToCoverageEnable = m_desc.m_alphaToCoverageEnable; nativeDesc.IndependentBlendEnable = m_desc.m_independentBlendEnable; // TODO add a numRenderTargetDescs ? for (int i = 0; i < 8; ++i) { vprRenderTargetBlendDesc& blendDesc = m_desc.m_renderTarget[i]; D3D11_RENDER_TARGET_BLEND_DESC& nativeBlendDesc = nativeDesc.RenderTarget[i]; nativeBlendDesc.SrcBlend = blendToDX11[blendDesc.m_srcBlend]; nativeBlendDesc.DestBlend = blendToDX11[blendDesc.m_destBlend]; nativeBlendDesc.BlendOp = blendOpToDX11[blendDesc.m_blendOp]; nativeBlendDesc.SrcBlendAlpha = blendToDX11[blendDesc.m_srcBlendAlpha]; nativeBlendDesc.DestBlendAlpha = blendToDX11[blendDesc.m_destBlendAlpha]; nativeBlendDesc.BlendOpAlpha = blendOpToDX11[blendDesc.m_blendOp]; nativeBlendDesc.RenderTargetWriteMask = blendDesc.m_renderTargetWriteMask; } if (FAILED(nativeDevice->CreateBlendState(&nativeDesc, &m_nativeState))) { return VP_FAILURE; } return VP_SUCCESS; }
ComPtr<ID3D11BlendState> MipmapMinValueRenderer::createBlendState( ID3D11Device& device ) { ComPtr<ID3D11BlendState> blendState; D3D11_BLEND_DESC blendDesc; ZeroMemory( &blendDesc, sizeof( blendDesc ) ); blendDesc.AlphaToCoverageEnable = false; blendDesc.IndependentBlendEnable = false; // Disable blending. blendDesc.RenderTarget[ 0 ].BlendEnable = false; blendDesc.RenderTarget[ 0 ].SrcBlend = D3D11_BLEND_ONE; blendDesc.RenderTarget[ 0 ].DestBlend = D3D11_BLEND_ZERO; blendDesc.RenderTarget[ 0 ].BlendOp = D3D11_BLEND_OP_ADD; blendDesc.RenderTarget[ 0 ].SrcBlendAlpha = D3D11_BLEND_ONE; blendDesc.RenderTarget[ 0 ].DestBlendAlpha = D3D11_BLEND_ZERO; blendDesc.RenderTarget[ 0 ].BlendOpAlpha = D3D11_BLEND_OP_ADD; blendDesc.RenderTarget[ 0 ].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_RED | D3D11_COLOR_WRITE_ENABLE_GREEN | D3D11_COLOR_WRITE_ENABLE_BLUE; // Don't write alpha. HRESULT result = device.CreateBlendState( &blendDesc, blendState.ReleaseAndGetAddressOf() ); if ( result < 0 ) throw std::exception( "MipmapMinValueRenderer::createBlendState - creation of blend state failed." ); return blendState; }
//----------------------------------------------------------------------------- void CPUTRenderStateBlockDX11::CreateNativeResources() { // Now, create the DX render state items ID3D11Device *pDevice = CPUT_DX11::GetDevice(); HRESULT hr; hr = pDevice->CreateBlendState( &mStateDesc.BlendDesc, &mpBlendState ); ASSERT( SUCCEEDED(hr), _L("Failed to create blend state.") ); hr = pDevice->CreateDepthStencilState( &mStateDesc.DepthStencilDesc, &mpDepthStencilState ); ASSERT( SUCCEEDED(hr), _L("Failed to create depth stencil state.") ); hr = pDevice->CreateRasterizerState( &mStateDesc.RasterizerDesc, &mpRasterizerState ); ASSERT( SUCCEEDED(hr), _L("Failed to create rasterizer state.") ); // TODO: how to map samplers to shaders? // Each type can have different samplers assigned (VS, PS, GS, etc.) // How does DX treat them? 16 unified? or 16 each? // For now, just read 16 samplers, and set to all stages for( UINT ii=0; ii<mNumSamplers; ii++ ) { hr = pDevice->CreateSamplerState( &mStateDesc.SamplerDesc[ii], &mpSamplerState[ii] ); ASSERT( SUCCEEDED(hr), _L("Failed to create sampler state.") ); } } // CPUTRenderStateBlockDX11::CreateDXResources()
ID3D11BlendState *Clear11::getBlendState(const gl::ClearParameters &clearParams, const std::vector<RenderTarget11*>& rts) { GLuint clientVersion = mRenderer->getCurrentClientVersion(); ClearBlendInfo blendKey = { 0 }; for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++) { if (i < rts.size()) { GLint internalFormat = rts[i]->getInternalFormat(); blendKey.maskChannels[i][0] = clearParams.clearColor ? (clearParams.colorMaskRed && gl::GetRedBits(internalFormat, clientVersion) > 0) : false; blendKey.maskChannels[i][1] = clearParams.clearColor ? (clearParams.colorMaskGreen && gl::GetGreenBits(internalFormat, clientVersion) > 0) : false; blendKey.maskChannels[i][2] = clearParams.clearColor ? (clearParams.colorMaskBlue && gl::GetBlueBits(internalFormat, clientVersion) > 0) : false; blendKey.maskChannels[i][3] = clearParams.clearColor ? (clearParams.colorMaskAlpha && gl::GetAlphaBits(internalFormat, clientVersion) > 0) : false; } else { blendKey.maskChannels[i][0] = false; blendKey.maskChannels[i][1] = false; blendKey.maskChannels[i][2] = false; blendKey.maskChannels[i][3] = false; } } ClearBlendStateMap::const_iterator i = mClearBlendStates.find(blendKey); if (i != mClearBlendStates.end()) { return i->second; } else { D3D11_BLEND_DESC blendDesc = { 0 }; blendDesc.AlphaToCoverageEnable = FALSE; blendDesc.IndependentBlendEnable = (rts.size() > 1) ? TRUE : FALSE; for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++) { blendDesc.RenderTarget[i].BlendEnable = FALSE; blendDesc.RenderTarget[i].RenderTargetWriteMask = gl_d3d11::ConvertColorMask(blendKey.maskChannels[i][0], blendKey.maskChannels[i][1], blendKey.maskChannels[i][2], blendKey.maskChannels[i][3]); } ID3D11Device *device = mRenderer->getDevice(); ID3D11BlendState* blendState = NULL; HRESULT result = device->CreateBlendState(&blendDesc, &blendState); if (FAILED(result) || !blendState) { ERR("Unable to create a ID3D11BlendState, HRESULT: 0x%X.", result); return NULL; } mClearBlendStates[blendKey] = blendState; return blendState; } }
ID3D11BlendState *Clear11::getBlendState(const std::vector<MaskedRenderTarget>& rts) { ClearBlendInfo blendKey = { 0 }; for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++) { if (i < rts.size()) { RenderTarget11 *rt = rts[i].renderTarget; const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(rt->getInternalFormat()); blendKey.maskChannels[i][0] = (rts[i].colorMask[0] && formatInfo.redBits > 0); blendKey.maskChannels[i][1] = (rts[i].colorMask[1] && formatInfo.greenBits > 0); blendKey.maskChannels[i][2] = (rts[i].colorMask[2] && formatInfo.blueBits > 0); blendKey.maskChannels[i][3] = (rts[i].colorMask[3] && formatInfo.alphaBits > 0); } else { blendKey.maskChannels[i][0] = false; blendKey.maskChannels[i][1] = false; blendKey.maskChannels[i][2] = false; blendKey.maskChannels[i][3] = false; } } ClearBlendStateMap::const_iterator i = mClearBlendStates.find(blendKey); if (i != mClearBlendStates.end()) { return i->second; } else { D3D11_BLEND_DESC blendDesc = { 0 }; blendDesc.AlphaToCoverageEnable = FALSE; blendDesc.IndependentBlendEnable = (rts.size() > 1) ? TRUE : FALSE; for (unsigned int j = 0; j < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; j++) { blendDesc.RenderTarget[j].BlendEnable = FALSE; blendDesc.RenderTarget[j].RenderTargetWriteMask = gl_d3d11::ConvertColorMask(blendKey.maskChannels[j][0], blendKey.maskChannels[j][1], blendKey.maskChannels[j][2], blendKey.maskChannels[j][3]); } ID3D11Device *device = mRenderer->getDevice(); ID3D11BlendState* blendState = NULL; HRESULT result = device->CreateBlendState(&blendDesc, &blendState); if (FAILED(result) || !blendState) { ERR("Unable to create a ID3D11BlendState, HRESULT: 0x%X.", result); return NULL; } mClearBlendStates[blendKey] = blendState; return blendState; } }
HRESULT DeferredPipeline::Lighting::_initialise_blend_state(ID3D11Device & device) { D3D11_BLEND_DESC blend_state; ZeroMemory(&blend_state, sizeof(blend_state)); blend_state.AlphaToCoverageEnable = FALSE; blend_state.IndependentBlendEnable = FALSE; blend_state.RenderTarget[0].BlendEnable = TRUE; blend_state.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; blend_state.RenderTarget[0].DestBlend = D3D11_BLEND_ONE; blend_state.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; blend_state.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; blend_state.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; blend_state.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blend_state.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; return device.CreateBlendState(&blend_state, &_om_additive_blend); }
bool init(ID3D11Device* dev, int argc, char** argv) { this->dev = dev; for(char** p = argv + 1; *p; ++p) { if(!strcmp(*p, "-w")) wireframe = 1; else if(!strcmp(*p, "-b")) blue_only = true; else if(!strcmp(*p, "-t")) triangles = atoi(*++p); else if(!strcmp(*p, "-m")) impressions = (float)atof(*++p); else if(!strcmp(*p, "-p")) period = (float)atof(*++p); else if(!strcmp(*p, "-s")) speed = (float)atof(*++p); else { fprintf(stderr, "Usage: d3d11gears [-v|-w] [-t TRIANGLES]\n"); fprintf(stderr, "d3d11gears is an enhanced port of glxgears to Direct3D 11\n"); fprintf(stderr, "\n"); //fprintf(stderr, "-v\t\tuse per-vertex diffuse-only lighting (classic glxgears look)\n"); fprintf(stderr, "-w\t\twireframe mode\n"); fprintf(stderr, "-t TRIANGLES\ttriangle budget (default is 3200)\n"); fprintf(stderr, "-m IMPRESSIONS\tmotion blur impressions (default is 1)\n"); fprintf(stderr, "-p PERIOD\tspeed reversal period (default is infinite)\n"); fprintf(stderr, "-s SPEED\tgear speed (default is 1.0)\n"); fprintf(stderr, "-b\tonly show blue gear (for faster motion blur)\n"); return false; } } ensure(dev->CreatePixelShader(g_ps, sizeof(g_ps), NULL, &ps)); ensure(dev->CreateVertexShader(g_vs, sizeof(g_vs), NULL, &vs)); gears[0].color = vec(0.8f, 0.1f, 0.0f, 1.0f); gears[1].color = vec(0.0f, 0.8f, 0.2f, 1.0f); gears[2].color = vec(0.2f, 0.2f, 1.0f, 1.0f); gears[0].mesh = build_gear(dev, triangles / 2, 1.0f, 4.0f, 1.0f, 20, 0.7f); gears[1].mesh = build_gear(dev, triangles / 4, 0.5f, 2.0f, 2.0f, 10, 0.7f); gears[2].mesh = build_gear(dev, triangles / 4, 1.3f, 2.0f, 0.5f, 10, 0.7f); gears[0].x = -3.0f; gears[0].y = -2.0f; gears[0].wmul = 1.0f; gears[0].t0 = 0.0 * M_PI / 180.0f; gears[1].x = 3.1f; gears[1].y = -2.0f; gears[1].wmul = -2.0f; gears[1].t0 = -9.0f * (float)M_PI / 180.0f; gears[2].x = -3.1f; gears[2].y = 4.2f; gears[2].wmul = -2.0f; gears[2].t0 = -25.0f * (float)M_PI / 180.0f; D3D11_BUFFER_DESC bufferd; memset(&bufferd, 0, sizeof(bufferd)); bufferd.ByteWidth = sizeof(cbuf_t); bufferd.Usage = D3D11_USAGE_DEFAULT; bufferd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; ensure(dev->CreateBuffer(&bufferd, 0, &cb)); if(impressions > 1) { D3D11_BLEND_DESC blendd; memset(&blendd, 0, sizeof(blendd)); blendd.RenderTarget[0].BlendEnable = TRUE; blendd.RenderTarget[0].BlendOp = blendd.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blendd.RenderTarget[0].SrcBlend = blendd.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_BLEND_FACTOR; blendd.RenderTarget[0].DestBlend = blendd.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; blendd.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; ensure(dev->CreateBlendState(&blendd, &blend)); D3D11_DEPTH_STENCIL_DESC zsad; memset(&zsad, 0, sizeof(zsad)); zsad.DepthEnable = TRUE; zsad.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; zsad.DepthFunc = D3D11_COMPARISON_EQUAL; ensure(dev->CreateDepthStencilState(&zsad, &zsa)); blitter = new d3d11_blitter(dev); } return true; }
bool D11State::init() { HRESULT hr; ID3D11Texture2D* pBackBuffer = NULL; hr = pSwapChain->GetBuffer(0, __uuidof(*pBackBuffer), (LPVOID*)&pBackBuffer); if (FAILED(hr)) { ods("D3D11: pSwapChain->GetBuffer failure!"); return false; } hr = pDevice->CreateDeferredContext(0, &pDeviceContext); // Depending on the device settings a deferred context may not be createable // for example if it is a SINGLETHREADED device. // (See http://msdn.microsoft.com/en-us/library/windows/desktop/ff476505%28v=vs.85%29.aspx) // We handle the expected failure and failure fallback in the same way - // by trying to use an immediate context. if (FAILED(hr) || !pDeviceContext) { ods("D3D11: Failed to create DeferredContext (0x%x). Getting ImmediateContext", hr); pDevice->GetImmediateContext(&pDeviceContext); D11CreateStateBlock(pDeviceContext, &pOrigStateBlock); D11CreateStateBlock(pDeviceContext, &pMyStateBlock); pOrigStateBlock->Capture(); bDeferredContext = false; } else { bDeferredContext = true; } D3D11_TEXTURE2D_DESC backBufferSurfaceDesc; pBackBuffer->GetDesc(&backBufferSurfaceDesc); ZeroMemory(&vp, sizeof(vp)); vp.Width = static_cast<float>(backBufferSurfaceDesc.Width); vp.Height = static_cast<float>(backBufferSurfaceDesc.Height); vp.MinDepth = 0; vp.MaxDepth = 1; vp.TopLeftX = 0; vp.TopLeftY = 0; pDeviceContext->RSSetViewports(1, &vp); hr = pDevice->CreateRenderTargetView(pBackBuffer, NULL, &pRTV); if (FAILED(hr)) { ods("D3D11: pDevice->CreateRenderTargetView failed!"); return false; } pDeviceContext->OMSetRenderTargets(1, &pRTV, NULL); // Settings for an "over" operation. // https://en.wikipedia.org/w/index.php?title=Alpha_compositing&oldid=580659153#Description D3D11_BLEND_DESC blend; ZeroMemory(&blend, sizeof(blend)); blend.RenderTarget[0].BlendEnable = TRUE; blend.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; blend.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; blend.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; blend.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; blend.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; blend.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blend.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; pDevice->CreateBlendState(&blend, &pBlendState); if (FAILED(hr)) { ods("D3D11: pDevice->CreateBlendState failed!"); return false; } pDeviceContext->OMSetBlendState(pBlendState, NULL, 0xffffffff); hr = pDevice->CreateVertexShader(g_vertex_shader, sizeof(g_vertex_shader), NULL, &pVertexShader); if (FAILED(hr)) { ods("D3D11: Failed to create vertex shader."); return false; } hr = pDevice->CreatePixelShader(g_pixel_shader, sizeof(g_pixel_shader), NULL, &pPixelShader); if (FAILED(hr)) { ods("D3D11: Failed to create pixel shader."); return false; } pTexture = NULL; pSRView = NULL; // Define the input layout D3D11_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; hr = pDevice->CreateInputLayout(layout, ARRAY_NUM_ELEMENTS(layout), g_vertex_shader, sizeof(g_vertex_shader), &pVertexLayout); if (FAILED(hr)) { ods("D3D11: pDevice->CreateInputLayout failure!"); return false; } pDeviceContext->IASetInputLayout(pVertexLayout); D3D11_BUFFER_DESC bd; ZeroMemory(&bd, sizeof(bd)); bd.Usage = D3D11_USAGE_DYNAMIC; bd.ByteWidth = VERTEXBUFFER_SIZE; bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; bd.MiscFlags = 0; hr = pDevice->CreateBuffer(&bd, NULL, &pVertexBuffer); if (FAILED(hr)) { ods("D3D11: pDevice->CreateBuffer failure!"); return false; } DWORD indices[] = { 0,1,3, 1,2,3, }; ZeroMemory(&bd, sizeof(bd)); bd.Usage = D3D11_USAGE_IMMUTABLE; bd.ByteWidth = sizeof(DWORD) * 6; bd.BindFlags = D3D11_BIND_INDEX_BUFFER; bd.CPUAccessFlags = 0; bd.MiscFlags = 0; D3D11_SUBRESOURCE_DATA InitData; ZeroMemory(&InitData, sizeof(InitData)); InitData.pSysMem = indices; hr = pDevice->CreateBuffer(&bd, &InitData, &pIndexBuffer); if (FAILED(hr)) { ods("D3D11: pDevice->CreateBuffer failure!"); return false; } // Set index buffer pDeviceContext->IASetIndexBuffer(pIndexBuffer, DXGI_FORMAT_R32_UINT, 0); // Set primitive topology pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); if (!bDeferredContext) { pMyStateBlock->Capture(); pOrigStateBlock->Apply(); } pBackBuffer->Release(); return true; }
void CFullscreenTriangleDrawer::CreateDX11Resources() { ID3D11Device* pDevice = static_cast<ID3D11Device*>( gD3DDevice ); HRESULT hr = S_OK; /* // fxc /O2 /T vs_4_0 /E VSMain struct VSScreenQuadOutput { float4 Position : SV_POSITION; float2 TexCoords0 : TEXCOORD0; }; VSScreenQuadOutput VSMain(uint VertexID: SV_VertexID) { VSScreenQuadOutput output = (VSScreenQuadOutput)0; output.TexCoords0 = float2( (VertexID << 1) & 2, VertexID & 2 ); output.Position = float4( output.TexCoords0 * float2( 2.0f, -2.0f ) + float2( -1.0f, 1.0f), 0.0f, 1.0f ); return output; } */ const char CompiledVS[] = { 0x44, 0x58, 0x42, 0x43, 0x0d, 0x62, 0xaf, 0x9b, 0xa7, 0xca, 0xdb, 0xb0, 0xc3, 0x92, 0xc3, 0xc1, 0x99, 0xd5, 0x59, 0xe6, 0x01, 0x00, 0x00, 0x00, 0xb4, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x38, 0x02, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xfe, 0xff, 0x00, 0xc1, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x44, 0x00, 0x4f, 0x53, 0x47, 0x4e, 0x50, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0xab, 0xab, 0x53, 0x48, 0x44, 0x52, 0x18, 0x01, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x46, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x04, 0x12, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x32, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x05, 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08, 0xc2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; hr = pDevice->CreateVertexShader( CompiledVS, sizeof( CompiledVS ), NULL, &m_pVertexShader11 ); CRY_ASSERT( SUCCEEDED( hr ) ); /* // fxc /O2 /T ps_4_0 /E PSMain Texture2D txDiffuse : register(t0); SamplerState texSampler : register(s0); struct VSScreenQuadOutput { float4 Position : SV_POSITION; float2 TexCoords0 : TEXCOORD0; }; float4 PSMain(VSScreenQuadOutput input) : SV_Target { // Switch the red and blue channels for DX11 since CryEngine does // not provide the exact texture format required by Coherent UI return txDiffuse.Sample(texSampler, input.TexCoords0).bgra; } */ const char CompiledPS[] = { 0x44, 0x58, 0x42, 0x43, 0x2a, 0xce, 0xec, 0x64, 0xe0, 0xa8, 0xf3, 0xcd, 0xc7, 0x9e, 0x5d, 0xcb, 0x86, 0xb6, 0x78, 0x94, 0x01, 0x00, 0x00, 0x00, 0x70, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x6c, 0x01, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0x00, 0xc1, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x74, 0x78, 0x44, 0x69, 0x66, 0x66, 0x75, 0x73, 0x65, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x36, 0x2e, 0x33, 0x2e, 0x39, 0x36, 0x30, 0x30, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x50, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x00, 0xab, 0xab, 0x53, 0x48, 0x44, 0x52, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x03, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, 0x04, 0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x0c, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; hr = pDevice->CreatePixelShader( CompiledPS, sizeof( CompiledPS ), NULL, &m_pPixelShader11 ); CRY_ASSERT( SUCCEEDED( hr ) ); // Create a One/InvSrcAlpha blend state D3D11_BLEND_DESC blendDesc = { 0 }; blendDesc.AlphaToCoverageEnable = false; blendDesc.IndependentBlendEnable = false; blendDesc.RenderTarget[0].BlendEnable = true; blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; hr = pDevice->CreateBlendState( &blendDesc, &m_pBlendState11 ); CRY_ASSERT( SUCCEEDED( hr ) ); }