2017-11-29 21:46:09 +01:00
|
|
|
#pragma once
|
|
|
|
|
2018-01-13 03:53:33 +01:00
|
|
|
#include "../dxvk/dxvk_device.h"
|
|
|
|
#include "../dxvk/dxvk_surface.h"
|
|
|
|
#include "../dxvk/dxvk_swapchain.h"
|
2018-01-10 13:43:23 +01:00
|
|
|
|
2018-01-13 03:53:33 +01:00
|
|
|
#include "../dxvk/hud/dxvk_hud.h"
|
2017-12-04 22:21:02 +01:00
|
|
|
|
2017-11-29 21:46:09 +01:00
|
|
|
#include "../spirv/spirv_module.h"
|
|
|
|
|
2018-01-13 03:53:33 +01:00
|
|
|
#include "dxgi_include.h"
|
|
|
|
|
2017-11-29 21:46:09 +01:00
|
|
|
namespace dxvk {
|
|
|
|
|
2018-04-10 20:44:55 +02:00
|
|
|
/**
|
|
|
|
* \brief Gamma ramp
|
|
|
|
*
|
|
|
|
* Structure that can be used to set the gamma
|
|
|
|
* ramp of a swap chain. This is the same data
|
|
|
|
* structure that is used by the fragment shader.
|
|
|
|
*/
|
|
|
|
struct DxgiPresenterGammaRamp {
|
|
|
|
constexpr static uint32_t CpCount = 1025;
|
|
|
|
|
|
|
|
float in_factor[4];
|
|
|
|
float in_offset[4];
|
|
|
|
float cp_values[4 * CpCount];
|
|
|
|
|
|
|
|
static float cpLocation(uint32_t cp) {
|
|
|
|
return float(cp) / float(CpCount - 1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-11-29 21:46:09 +01:00
|
|
|
/**
|
|
|
|
* \brief DXGI presenter
|
|
|
|
*
|
|
|
|
* Renders the back buffer from the
|
|
|
|
* \ref DxgiSwapChain to the Vulkan
|
|
|
|
* swap chain.
|
|
|
|
*/
|
|
|
|
class DxgiPresenter : public RcObject {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DxgiPresenter(
|
2018-04-10 20:44:55 +02:00
|
|
|
const Rc<DxvkDevice>& device,
|
|
|
|
HWND window);
|
2017-11-29 21:46:09 +01:00
|
|
|
|
|
|
|
~DxgiPresenter();
|
2017-12-12 00:27:49 +01:00
|
|
|
|
2017-12-02 11:46:25 +01:00
|
|
|
/**
|
|
|
|
* \brief Initializes back buffer image
|
|
|
|
* \param [in] image Back buffer image
|
|
|
|
*/
|
|
|
|
void initBackBuffer(
|
|
|
|
const Rc<DxvkImage>& image);
|
|
|
|
|
2017-11-29 21:46:09 +01:00
|
|
|
/**
|
2017-12-12 00:27:49 +01:00
|
|
|
* \brief Renders back buffer to the screen
|
|
|
|
*/
|
|
|
|
void presentImage();
|
|
|
|
|
|
|
|
/**
|
2017-12-19 16:01:50 +01:00
|
|
|
* \brief Sets new back buffer
|
2017-12-12 00:27:49 +01:00
|
|
|
*
|
2017-12-19 16:01:50 +01:00
|
|
|
* Recreates internal structures when
|
|
|
|
* the back buffer image was replaced.
|
|
|
|
* \param [in] image Back buffer image
|
2017-11-29 21:46:09 +01:00
|
|
|
*/
|
2017-12-19 16:01:50 +01:00
|
|
|
void updateBackBuffer(
|
2017-12-31 00:23:34 +01:00
|
|
|
const Rc<DxvkImage>& image);
|
2017-11-29 21:46:09 +01:00
|
|
|
|
2017-12-04 22:21:02 +01:00
|
|
|
/**
|
2017-12-31 00:23:34 +01:00
|
|
|
* \brief Recreats Vulkan swap chain
|
|
|
|
*
|
|
|
|
* Only actually recreates the swap chain object
|
|
|
|
* if any of the properties have changed. If no
|
|
|
|
* properties have changed, this is a no-op.
|
|
|
|
* \param [in] options New swap chain options
|
2017-12-04 22:21:02 +01:00
|
|
|
*/
|
|
|
|
void recreateSwapchain(
|
2017-12-31 00:23:34 +01:00
|
|
|
const DxvkSwapchainProperties& options);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Picks a surface format based on a DXGI format
|
|
|
|
*
|
|
|
|
* This will return a supported format that, if possible,
|
|
|
|
* has properties similar to those of the DXGI format.
|
|
|
|
* \param [in] fmt The DXGI format
|
|
|
|
* \returns The Vulkan format
|
|
|
|
*/
|
|
|
|
VkSurfaceFormatKHR pickSurfaceFormat(DXGI_FORMAT fmt) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Picks a supported present mode
|
|
|
|
*
|
|
|
|
* \param [in] preferred Preferred present mode
|
|
|
|
* \returns An actually supported present mode
|
|
|
|
*/
|
|
|
|
VkPresentModeKHR pickPresentMode(VkPresentModeKHR preferred) const;
|
2017-12-04 22:21:02 +01:00
|
|
|
|
2018-04-10 20:44:55 +02:00
|
|
|
/**
|
|
|
|
* \brief Sets gamma ramp
|
|
|
|
* \param [in] data Gamma data
|
|
|
|
*/
|
|
|
|
void setGammaRamp(const DxgiPresenterGammaRamp& data);
|
|
|
|
|
2017-11-29 21:46:09 +01:00
|
|
|
private:
|
|
|
|
|
2017-12-03 20:23:26 +01:00
|
|
|
enum BindingIds : uint32_t {
|
2018-04-10 20:44:55 +02:00
|
|
|
Sampler = 0,
|
|
|
|
Texture = 1,
|
|
|
|
GammaUbo = 2,
|
2017-12-03 20:23:26 +01:00
|
|
|
};
|
|
|
|
|
2017-11-29 21:46:09 +01:00
|
|
|
Rc<DxvkDevice> m_device;
|
2017-12-01 10:08:49 +01:00
|
|
|
Rc<DxvkContext> m_context;
|
2017-11-29 21:46:09 +01:00
|
|
|
|
|
|
|
Rc<DxvkSurface> m_surface;
|
|
|
|
Rc<DxvkSwapchain> m_swapchain;
|
|
|
|
|
2018-04-10 20:44:55 +02:00
|
|
|
Rc<DxvkBuffer> m_gammaBuffer;
|
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
Rc<DxvkSampler> m_samplerFitting;
|
|
|
|
Rc<DxvkSampler> m_samplerScaling;
|
2017-12-03 20:23:26 +01:00
|
|
|
|
2017-12-12 00:27:49 +01:00
|
|
|
Rc<DxvkImage> m_backBuffer;
|
|
|
|
Rc<DxvkImage> m_backBufferResolve;
|
|
|
|
Rc<DxvkImageView> m_backBufferView;
|
|
|
|
|
2018-01-13 03:53:33 +01:00
|
|
|
Rc<hud::Hud> m_hud;
|
|
|
|
|
|
|
|
DxvkBlendMode m_blendMode;
|
2017-12-31 00:23:34 +01:00
|
|
|
DxvkSwapchainProperties m_options;
|
2017-12-04 22:21:02 +01:00
|
|
|
|
2017-11-29 21:46:09 +01:00
|
|
|
Rc<DxvkShader> createVertexShader();
|
|
|
|
Rc<DxvkShader> createFragmentShader();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|