void GSDeviceOGL::CreateTextureFX() { m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer)); m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer)); // warning 1 sampler by image unit. So you cannot reuse m_ps_ss... m_palette_ss = CreateSampler(false, false, false); glBindSampler(1, m_palette_ss); // Pre compile all Geometry & Vertex Shader // It might cost a seconds at startup but it would reduce benchmark pollution GL_PUSH("Compile GS"); for (uint32 key = 0; key < countof(m_gs); key++) { GSSelector sel(key); if (sel.point == sel.sprite) m_gs[key] = 0; else m_gs[key] = CompileGS(GSSelector(key)); } GL_POP(); GL_PUSH("Compile VS"); for (uint32 key = 0; key < countof(m_vs); key++) { // wildhack is only useful if both TME and FST are enabled. VSSelector sel(key); if (sel.wildhack && (!sel.tme || !sel.fst)) m_vs[key] = 0; else m_vs[key] = CompileVS(sel, !GLLoader::found_GL_ARB_clip_control); } GL_POP(); // Enable all bits for stencil operations. Technically 1 bit is // enough but buffer is polluted with noise. Clear will be limited // to the mask. glStencilMask(0xFF); for (uint32 key = 0; key < countof(m_om_dss); key++) { m_om_dss[key] = CreateDepthStencil(OMDepthStencilSelector(key)); } // Help to debug FS in apitrace m_apitrace = CompilePS(PSSelector()); }
bool GSDevice11::CreateTextureFX() { HRESULT hr; D3D11_BUFFER_DESC bd; memset(&bd, 0, sizeof(bd)); bd.ByteWidth = sizeof(VSConstantBuffer); bd.Usage = D3D11_USAGE_DEFAULT; bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; hr = m_dev->CreateBuffer(&bd, NULL, &m_vs_cb); if(FAILED(hr)) return false; memset(&bd, 0, sizeof(bd)); bd.ByteWidth = sizeof(GSConstantBuffer); bd.Usage = D3D11_USAGE_DEFAULT; bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; hr = m_dev->CreateBuffer(&bd, NULL, &m_gs_cb); if (FAILED(hr)) return false; memset(&bd, 0, sizeof(bd)); bd.ByteWidth = sizeof(PSConstantBuffer); bd.Usage = D3D11_USAGE_DEFAULT; bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; hr = m_dev->CreateBuffer(&bd, NULL, &m_ps_cb); if(FAILED(hr)) return false; D3D11_SAMPLER_DESC sd; memset(&sd, 0, sizeof(sd)); sd.Filter = theApp.GetConfigI("MaxAnisotropy") && !theApp.GetConfigB("paltex") ? D3D11_FILTER_ANISOTROPIC : D3D11_FILTER_MIN_MAG_MIP_POINT; sd.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; sd.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; sd.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; sd.MinLOD = -FLT_MAX; sd.MaxLOD = FLT_MAX; sd.MaxAnisotropy = theApp.GetConfigI("MaxAnisotropy"); sd.ComparisonFunc = D3D11_COMPARISON_NEVER; hr = m_dev->CreateSamplerState(&sd, &m_palette_ss); if(FAILED(hr)) return false; hr = m_dev->CreateSamplerState(&sd, &m_rt_ss); if(FAILED(hr)) return false; // create layout VSSelector sel; VSConstantBuffer cb; SetupVS(sel, &cb); GSConstantBuffer gcb; SetupGS(GSSelector(1), &gcb); // return true; }