1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-01 16:24:12 +01:00

[dxgi] Implemented back buffer creation

This commit is contained in:
Philip Rebohle 2017-11-29 08:29:12 +01:00
parent 5bd3fdc11a
commit 9fedd0187b
2 changed files with 53 additions and 11 deletions

View File

@ -378,14 +378,6 @@ namespace dxvk {
const Rc<DxvkImage>& image,
const DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
IUnknown** ppInterface) {
UINT bindFlags = 0;
if (pSwapChainDesc->BufferUsage & DXGI_USAGE_RENDER_TARGET_OUTPUT)
bindFlags |= D3D11_BIND_RENDER_TARGET;
if (pSwapChainDesc->BufferUsage & DXGI_USAGE_SHADER_INPUT)
bindFlags |= D3D11_BIND_SHADER_RESOURCE;
D3D11_TEXTURE2D_DESC desc;
desc.Width = pSwapChainDesc->BufferDesc.Width;
desc.Height = pSwapChainDesc->BufferDesc.Height;
@ -394,7 +386,8 @@ namespace dxvk {
desc.Format = pSwapChainDesc->BufferDesc.Format;
desc.SampleDesc = pSwapChainDesc->SampleDesc;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = bindFlags;
desc.BindFlags = D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0;
desc.MiscFlags = 0;

View File

@ -258,7 +258,7 @@ namespace dxvk {
m_desc.BufferCount = BufferCount;
try {
// TODO implement
this->createBackBuffer();
return S_OK;
} catch (const DxvkError& err) {
Logger::err(err.message());
@ -347,8 +347,57 @@ namespace dxvk {
void DxgiSwapChain::createBackBuffer() {
// TODO create DXVK image and image virw
// TODO select format based on DXGI format
// TODO support proper multi-sampling
const Rc<DxvkDevice> dxvkDevice = m_device->GetDXVKDevice();
// Create an image that can be rendered to
// and that can be used as a sampled texture.
DxvkImageCreateInfo imageInfo;
imageInfo.type = VK_IMAGE_TYPE_2D;
imageInfo.format = VK_FORMAT_R8G8B8A8_SNORM;
imageInfo.sampleCount = VK_SAMPLE_COUNT_1_BIT;
imageInfo.extent.width = m_desc.BufferDesc.Width;
imageInfo.extent.height = m_desc.BufferDesc.Height;
imageInfo.extent.depth = 1;
imageInfo.numLayers = 1;
imageInfo.mipLevels = 1;
imageInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
| VK_IMAGE_USAGE_SAMPLED_BIT
| VK_IMAGE_USAGE_TRANSFER_DST_BIT
| VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
imageInfo.stages = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
| VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
| VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
| VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
| VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
| VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
| VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
| VK_PIPELINE_STAGE_TRANSFER_BIT;
imageInfo.access = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
| VK_ACCESS_TRANSFER_WRITE_BIT
| VK_ACCESS_TRANSFER_READ_BIT
| VK_ACCESS_SHADER_READ_BIT;
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
m_backBuffer = dxvkDevice->createImage(imageInfo,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
// Create an image view that allows the
// image to be bound as a shader resource.
DxvkImageViewCreateInfo viewInfo;
viewInfo.type = VK_IMAGE_VIEW_TYPE_2D;
viewInfo.format = imageInfo.format;
viewInfo.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
viewInfo.minLevel = 0;
viewInfo.numLevels = 1;
viewInfo.minLayer = 0;
viewInfo.numLayers = 1;
m_backBufferView = dxvkDevice->createImageView(m_backBuffer, viewInfo);
// Wrap the back buffer image into an interface
// that the device can use to access the image.
if (FAILED(m_device->WrapSwapChainBackBuffer(m_backBuffer, &m_desc, &m_backBufferIface)))
throw DxvkError("DxgiSwapChain::createBackBuffer: Failed to create back buffer");
}