1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[dxgi] Remove support gamma-related ScaleAndOffsetSupported

Some games, including Heroes of the Storm (#287), do not set
the values correctly so it's better to ignore them altogether.
This commit is contained in:
Philip Rebohle 2018-04-15 20:12:41 +02:00
parent 256645724b
commit af19bba048
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
5 changed files with 7 additions and 73 deletions

View File

@ -260,7 +260,7 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE DxgiOutput::GetGammaControlCapabilities(DXGI_GAMMA_CONTROL_CAPABILITIES* pGammaCaps) {
pGammaCaps->ScaleAndOffsetSupported = TRUE;
pGammaCaps->ScaleAndOffsetSupported = FALSE;
pGammaCaps->MaxConvertedValue = 1.0f;
pGammaCaps->MinConvertedValue = 0.0f;
pGammaCaps->NumGammaControlPoints = DXGI_VK_GAMMA_CP_COUNT;

View File

@ -34,7 +34,6 @@ namespace dxvk {
// Create objects required for the gamma ramp. This is implemented partially
// with an UBO, which stores global parameters, and a lookup texture, which
// stores the actual gamma ramp and can be sampled with a linear filter.
m_gammaUbo = CreateGammaUbo();
m_gammaSampler = CreateSampler(VK_FILTER_LINEAR, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE);
m_gammaTexture = CreateGammaTexture();
m_gammaTextureView = CreateGammaTextureView();
@ -204,7 +203,6 @@ namespace dxvk {
m_context->bindResourceSampler(BindingIds::GammaSmp, m_gammaSampler);
m_context->bindResourceView (BindingIds::GammaTex, m_gammaTextureView, nullptr);
m_context->bindResourceBuffer (BindingIds::GammaUbo, DxvkBufferSlice(m_gammaUbo));
if (m_hud != nullptr) {
m_blendMode.enableBlending = VK_TRUE;
@ -339,15 +337,10 @@ namespace dxvk {
void DxgiVkPresenter::SetGammaControl(
const DXGI_VK_GAMMA_INPUT_CONTROL* pGammaControl,
const DXGI_VK_GAMMA_CURVE* pGammaCurve) {
m_context->beginRecording(
m_device->createCommandList());
m_context->updateBuffer(m_gammaUbo,
0, sizeof(DXGI_VK_GAMMA_INPUT_CONTROL),
pGammaControl);
m_context->updateImage(m_gammaTexture,
VkImageSubresourceLayers { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 },
VkOffset3D { 0, 0, 0 },
@ -383,19 +376,6 @@ namespace dxvk {
}
Rc<DxvkBuffer> DxgiVkPresenter::CreateGammaUbo() {
DxvkBufferCreateInfo info;
info.size = sizeof(DXGI_VK_GAMMA_INPUT_CONTROL);
info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT
| VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
info.stages = VK_PIPELINE_STAGE_TRANSFER_BIT
| VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
info.access = VK_ACCESS_TRANSFER_WRITE_BIT
| VK_ACCESS_SHADER_READ_BIT;
return m_device->createBuffer(info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
}
Rc<DxvkImage> DxgiVkPresenter::CreateGammaTexture() {
DxvkImageCreateInfo info;
info.type = VK_IMAGE_TYPE_1D;
@ -444,12 +424,11 @@ namespace dxvk {
const SpirvCodeBuffer codeBuffer(dxgi_presenter_frag);
// Shader resource slots
const std::array<DxvkResourceSlot, 5> resourceSlots = {{
const std::array<DxvkResourceSlot, 4> resourceSlots = {{
{ BindingIds::Sampler, VK_DESCRIPTOR_TYPE_SAMPLER, VK_IMAGE_VIEW_TYPE_MAX_ENUM },
{ BindingIds::Texture, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_IMAGE_VIEW_TYPE_2D },
{ BindingIds::GammaSmp, VK_DESCRIPTOR_TYPE_SAMPLER, VK_IMAGE_VIEW_TYPE_MAX_ENUM },
{ BindingIds::GammaTex, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_IMAGE_VIEW_TYPE_1D },
{ BindingIds::GammaUbo, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_IMAGE_VIEW_TYPE_MAX_ENUM },
}};
// Create the actual shader module

View File

@ -35,26 +35,6 @@ namespace dxvk {
DXGI_VK_GAMMA_CP ControlPoints[DXGI_VK_GAMMA_CP_COUNT];
};
/**
* \brief Gamma input color
* A floating-point color vector.
*/
struct DXGI_VK_GAMMA_INPUT_COLOR {
float R, G, B, A;
};
/**
* \brief Gamma input control
*
* Stores a scaling factor and a bias that shall
* be applied to the input color before performing
* the gamma lookup in the fragment shader.
*/
struct DXGI_VK_GAMMA_INPUT_CONTROL {
DXGI_VK_GAMMA_INPUT_COLOR Factor;
DXGI_VK_GAMMA_INPUT_COLOR Offset;
};
/**
* \brief Maps color value to normalized integer
*
@ -151,7 +131,6 @@ namespace dxvk {
* \param [in] pGammaCurve Gamma curve
*/
void SetGammaControl(
const DXGI_VK_GAMMA_INPUT_CONTROL* pGammaControl,
const DXGI_VK_GAMMA_CURVE* pGammaCurve);
private:
@ -161,7 +140,6 @@ namespace dxvk {
Texture = 1,
GammaSmp = 2,
GammaTex = 3,
GammaUbo = 4,
};
Rc<DxvkDevice> m_device;
@ -177,7 +155,6 @@ namespace dxvk {
Rc<DxvkImage> m_backBufferResolve;
Rc<DxvkImageView> m_backBufferView;
Rc<DxvkBuffer> m_gammaUbo;
Rc<DxvkSampler> m_gammaSampler;
Rc<DxvkImage> m_gammaTexture;
Rc<DxvkImageView> m_gammaTextureView;
@ -191,7 +168,6 @@ namespace dxvk {
VkFilter Filter,
VkSamplerAddressMode AddressMode);
Rc<DxvkBuffer> CreateGammaUbo();
Rc<DxvkImage> CreateGammaTexture();
Rc<DxvkImageView> CreateGammaTextureView();

View File

@ -284,13 +284,6 @@ namespace dxvk {
HRESULT DxgiSwapChain::SetGammaControl(const DXGI_GAMMA_CONTROL* pGammaControl) {
std::lock_guard<std::recursive_mutex> lock(m_mutex);
const DXGI_RGB Factor = pGammaControl->Scale;
const DXGI_RGB Offset = pGammaControl->Offset;
DXGI_VK_GAMMA_INPUT_CONTROL control;
control.Factor = { Factor.Red, Factor.Green, Factor.Blue, 1.0f };
control.Offset = { Offset.Red, Offset.Green, Offset.Blue, 0.0f };
DXGI_VK_GAMMA_CURVE curve;
for (uint32_t i = 0; i < DXGI_VK_GAMMA_CP_COUNT; i++) {
@ -301,7 +294,7 @@ namespace dxvk {
curve.ControlPoints[i].A = 0;
}
m_presenter->SetGammaControl(&control, &curve);
m_presenter->SetGammaControl(&curve);
return S_OK;
}
@ -309,10 +302,6 @@ namespace dxvk {
HRESULT DxgiSwapChain::SetDefaultGammaControl() {
std::lock_guard<std::recursive_mutex> lock(m_mutex);
DXGI_VK_GAMMA_INPUT_CONTROL control;
control.Factor = { 1.0f, 1.0f, 1.0f, 1.0f };
control.Offset = { 0.0f, 0.0f, 0.0f, 0.0f };
DXGI_VK_GAMMA_CURVE curve;
for (uint32_t i = 0; i < DXGI_VK_GAMMA_CP_COUNT; i++) {
@ -321,7 +310,7 @@ namespace dxvk {
curve.ControlPoints[i] = { value, value, value, 0 };
}
m_presenter->SetGammaControl(&control, &curve);
m_presenter->SetGammaControl(&curve);
return S_OK;
}

View File

@ -6,25 +6,15 @@ layout(binding = 1) uniform texture2D t_texture;
layout(binding = 2) uniform sampler s_gamma;
layout(binding = 3) uniform texture1D t_gamma;
layout(binding = 4)
uniform u_gamma_info_t {
layout(offset = 0) vec4 in_factor;
layout(offset = 16) vec4 in_offset;
} u_gamma_info;
layout(location = 0) in vec2 i_texcoord;
layout(location = 0) out vec4 o_color;
void main() {
vec4 color = texture(sampler2D(t_texture, s_sampler), i_texcoord);
vec3 cp_lookup = color.rgb;
cp_lookup *= u_gamma_info.in_factor.rgb;
cp_lookup += u_gamma_info.in_offset.rgb;
o_color = vec4(
texture(sampler1D(t_gamma, s_gamma), cp_lookup.r).r,
texture(sampler1D(t_gamma, s_gamma), cp_lookup.g).g,
texture(sampler1D(t_gamma, s_gamma), cp_lookup.b).b,
texture(sampler1D(t_gamma, s_gamma), color.r).r,
texture(sampler1D(t_gamma, s_gamma), color.g).g,
texture(sampler1D(t_gamma, s_gamma), color.b).b,
color.a);
}