1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 11:52:12 +01:00

[dxvk] Set non-zero framebuffer size when there are no attachments

This is required for UAV-only rendering and will be required for
stream output in the future as well.
This commit is contained in:
Philip Rebohle 2018-04-29 11:19:18 +02:00
parent 7cb7e4a944
commit 9aa73d1148
6 changed files with 70 additions and 25 deletions

View File

@ -12,6 +12,7 @@ namespace dxvk {
m_vkd (vkd), m_vkd (vkd),
m_extensions (extensions), m_extensions (extensions),
m_features (features), m_features (features),
m_properties (adapter->deviceProperties()),
m_memory (new DxvkMemoryAllocator (adapter, vkd)), m_memory (new DxvkMemoryAllocator (adapter, vkd)),
m_renderPassPool (new DxvkRenderPassPool (vkd)), m_renderPassPool (new DxvkRenderPassPool (vkd)),
m_pipelineCache (new DxvkPipelineCache (vkd)), m_pipelineCache (new DxvkPipelineCache (vkd)),
@ -111,9 +112,16 @@ namespace dxvk {
Rc<DxvkFramebuffer> DxvkDevice::createFramebuffer( Rc<DxvkFramebuffer> DxvkDevice::createFramebuffer(
const DxvkRenderTargets& renderTargets) { const DxvkRenderTargets& renderTargets) {
const DxvkFramebufferSize defaultSize = {
m_properties.limits.maxFramebufferWidth,
m_properties.limits.maxFramebufferHeight,
m_properties.limits.maxFramebufferLayers };
auto format = renderTargets.renderPassFormat(); auto format = renderTargets.renderPassFormat();
auto renderPass = m_renderPassPool->getRenderPass(format); auto renderPass = m_renderPassPool->getRenderPass(format);
return new DxvkFramebuffer(m_vkd, renderPass, renderTargets);
return new DxvkFramebuffer(m_vkd,
renderPass, renderTargets, defaultSize);
} }

View File

@ -346,24 +346,25 @@ namespace dxvk {
private: private:
Rc<DxvkAdapter> m_adapter; Rc<DxvkAdapter> m_adapter;
Rc<vk::DeviceFn> m_vkd; Rc<vk::DeviceFn> m_vkd;
Rc<DxvkDeviceExtensions> m_extensions; Rc<DxvkDeviceExtensions> m_extensions;
VkPhysicalDeviceFeatures m_features; VkPhysicalDeviceFeatures m_features;
VkPhysicalDeviceProperties m_properties;
Rc<DxvkMemoryAllocator> m_memory; Rc<DxvkMemoryAllocator> m_memory;
Rc<DxvkRenderPassPool> m_renderPassPool; Rc<DxvkRenderPassPool> m_renderPassPool;
Rc<DxvkPipelineCache> m_pipelineCache; Rc<DxvkPipelineCache> m_pipelineCache;
Rc<DxvkMetaClearObjects> m_metaClearObjects; Rc<DxvkMetaClearObjects> m_metaClearObjects;
DxvkUnboundResources m_unboundResources; DxvkUnboundResources m_unboundResources;
sync::Spinlock m_statLock; sync::Spinlock m_statLock;
DxvkStatCounters m_statCounters; DxvkStatCounters m_statCounters;
std::mutex m_submissionLock; std::mutex m_submissionLock;
DxvkDeviceQueue m_graphicsQueue; DxvkDeviceQueue m_graphicsQueue;
DxvkDeviceQueue m_presentQueue; DxvkDeviceQueue m_presentQueue;
DxvkRecycler<DxvkCommandList, 16> m_recycledCommandLists; DxvkRecycler<DxvkCommandList, 16> m_recycledCommandLists;
DxvkRecycler<DxvkStagingBuffer, 4> m_recycledStagingBuffers; DxvkRecycler<DxvkStagingBuffer, 4> m_recycledStagingBuffers;

View File

@ -48,7 +48,8 @@ namespace dxvk {
} }
DxvkFramebufferSize DxvkRenderTargets::getImageSize() const { DxvkFramebufferSize DxvkRenderTargets::getImageSize(
const DxvkFramebufferSize& defaultSize) const {
if (m_depthTarget.view != nullptr) if (m_depthTarget.view != nullptr)
return this->renderTargetSize(m_depthTarget.view); return this->renderTargetSize(m_depthTarget.view);
@ -57,7 +58,7 @@ namespace dxvk {
return this->renderTargetSize(m_colorTargets.at(i).view); return this->renderTargetSize(m_colorTargets.at(i).view);
} }
return DxvkFramebufferSize { 0, 0, 0 }; return defaultSize;
} }
@ -95,11 +96,12 @@ namespace dxvk {
DxvkFramebuffer::DxvkFramebuffer( DxvkFramebuffer::DxvkFramebuffer(
const Rc<vk::DeviceFn>& vkd, const Rc<vk::DeviceFn>& vkd,
const Rc<DxvkRenderPass>& renderPass, const Rc<DxvkRenderPass>& renderPass,
const DxvkRenderTargets& renderTargets) const DxvkRenderTargets& renderTargets,
const DxvkFramebufferSize& defaultSize)
: m_vkd (vkd), : m_vkd (vkd),
m_renderPass (renderPass), m_renderPass (renderPass),
m_renderTargets (renderTargets), m_renderTargets (renderTargets),
m_framebufferSize (renderTargets.getImageSize()) { m_framebufferSize (renderTargets.getImageSize(defaultSize)) {
std::array<VkImageView, MaxNumRenderTargets + 1> views; std::array<VkImageView, MaxNumRenderTargets + 1> views;
uint32_t viewCount = renderTargets.getAttachments(views.data()); uint32_t viewCount = renderTargets.getAttachments(views.data());

View File

@ -104,11 +104,14 @@ namespace dxvk {
/** /**
* \brief Framebuffer size * \brief Framebuffer size
* *
* The width, height and layers * The width, height and layer count of the
* of the attached render targets. * attached render targets.
* \param [in] defaultSize Size to use when
* there are no framebuffer attachments.
* \returns Framebuffer size * \returns Framebuffer size
*/ */
DxvkFramebufferSize getImageSize() const; DxvkFramebufferSize getImageSize(
const DxvkFramebufferSize& defaultSize) const;
/** /**
* \brief Checks whether any attachments are defined * \brief Checks whether any attachments are defined
@ -152,7 +155,8 @@ namespace dxvk {
DxvkFramebuffer( DxvkFramebuffer(
const Rc<vk::DeviceFn>& vkd, const Rc<vk::DeviceFn>& vkd,
const Rc<DxvkRenderPass>& renderPass, const Rc<DxvkRenderPass>& renderPass,
const DxvkRenderTargets& renderTargets); const DxvkRenderTargets& renderTargets,
const DxvkFramebufferSize& defaultSize);
~DxvkFramebuffer(); ~DxvkFramebuffer();
/** /**

View File

@ -189,7 +189,8 @@ namespace dxvk {
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
m_framebuffers.at(i) = new DxvkFramebuffer( m_framebuffers.at(i) = new DxvkFramebuffer(
m_vkd, m_renderPass, renderTargets); m_vkd, m_renderPass, renderTargets,
DxvkFramebufferSize());
m_semaphoreSet.at(i).acquireSync = m_device->createSemaphore(); m_semaphoreSet.at(i).acquireSync = m_device->createSemaphore();
m_semaphoreSet.at(i).presentSync = m_device->createSemaphore(); m_semaphoreSet.at(i).presentSync = m_device->createSemaphore();

View File

@ -22,6 +22,8 @@ struct Color {
uint8_t r, g, b, a; uint8_t r, g, b, a;
}; };
bool m_report = false;
const std::string g_vertexShaderCode = const std::string g_vertexShaderCode =
"Buffer<float4> buf : register(t0);\n" "Buffer<float4> buf : register(t0);\n"
"struct vs_out {\n" "struct vs_out {\n"
@ -311,7 +313,7 @@ public:
m_context->OMSetRenderTargets(0, nullptr, nullptr); m_context->OMSetRenderTargets(0, nullptr, nullptr);
m_swapChain->Present(0, 0); m_swapChain->Present(1, 0);
// Test query results // Test query results
while (true) { while (true) {
@ -332,6 +334,24 @@ public:
break; break;
} }
} }
// Swap chain stuff
uint32_t frameId = m_frameId++;
if (frameId == 300) {
m_report = true;
std::cout << "fullscreen begin" << std::endl;
m_swapChain->SetFullscreenState(TRUE, nullptr);
std::cout << "fullscreen end" << std::endl;
m_report = false;
} else if (frameId == 600) {
m_report = true;
std::cout << "restore begin" << std::endl;
m_swapChain->SetFullscreenState(FALSE, nullptr);
std::cout << "restore end" << std::endl;
m_report = false;
}
} }
@ -388,6 +408,8 @@ private:
D3D_FEATURE_LEVEL m_featureLevel; D3D_FEATURE_LEVEL m_featureLevel;
uint32_t m_frameId = 0;
}; };
LRESULT CALLBACK WindowProc(HWND hWnd, LRESULT CALLBACK WindowProc(HWND hWnd,
@ -446,6 +468,13 @@ int WINAPI WinMain(HINSTANCE hInstance,
} }
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
if (m_report) {
std::cout << "hwnd: " << hWnd << std::endl;
std::cout << "msg: " << message << std::endl;
std::cout << "wp: " << wParam << std::endl;
std::cout << "lp: " << lParam << std::endl;
}
switch (message) { switch (message) {
case WM_CLOSE: case WM_CLOSE:
PostQuitMessage(0); PostQuitMessage(0);