Skip to content

Commit

Permalink
Use typeless textures and linear light chroma
Browse files Browse the repository at this point in the history
  • Loading branch information
ns6089 committed Sep 27, 2023
1 parent cf093be commit cbd3c26
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 111 deletions.
1 change: 1 addition & 0 deletions cmake/compile_definitions/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ set(PLATFORM_TARGET_FILES
src/platform/windows/display_base.cpp
src/platform/windows/display_vram.cpp
src/platform/windows/display_ram.cpp
src/platform/windows/dx_helpers.cpp
src/platform/windows/audio.cpp
third-party/ViGEmClient/src/ViGEmClient.cpp
third-party/ViGEmClient/include/ViGEm/Client.h
Expand Down
1 change: 0 additions & 1 deletion src/platform/windows/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ namespace platf::dxgi {
using buf_t = util::safe_ptr<ID3D11Buffer, Release<ID3D11Buffer>>;
using raster_state_t = util::safe_ptr<ID3D11RasterizerState, Release<ID3D11RasterizerState>>;
using sampler_state_t = util::safe_ptr<ID3D11SamplerState, Release<ID3D11SamplerState>>;
using blob_t = util::safe_ptr<ID3DBlob, Release<ID3DBlob>>;
using depth_stencil_state_t = util::safe_ptr<ID3D11DepthStencilState, Release<ID3D11DepthStencilState>>;
using depth_stencil_view_t = util::safe_ptr<ID3D11DepthStencilView, Release<ID3D11DepthStencilView>>;
using keyed_mutex_t = util::safe_ptr<IDXGIKeyedMutex, Release<IDXGIKeyedMutex>>;
Expand Down
254 changes: 150 additions & 104 deletions src/platform/windows/display_vram.cpp

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions src/platform/windows/dx_helpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include "dx_helpers.h"

namespace dx_helpers {

DXGI_FORMAT
unorm_from_typeless_texture_format(DXGI_FORMAT typeless_format) {
switch (typeless_format) {
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
return DXGI_FORMAT_B8G8R8A8_UNORM;

case DXGI_FORMAT_B8G8R8X8_TYPELESS:
return DXGI_FORMAT_B8G8R8X8_UNORM;

case DXGI_FORMAT_R8G8B8A8_TYPELESS:
return DXGI_FORMAT_R8G8B8A8_UNORM;

default:
return DXGI_FORMAT_UNKNOWN;
}
}

DXGI_FORMAT
srgb_from_typeless_texture_format(DXGI_FORMAT typeless_format) {
switch (typeless_format) {
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;

case DXGI_FORMAT_B8G8R8X8_TYPELESS:
return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB;

case DXGI_FORMAT_R8G8B8A8_TYPELESS:
return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;

default:
return DXGI_FORMAT_UNKNOWN;
}
}

DXGI_FORMAT
typeless_from_unorm_texture_format(DXGI_FORMAT unorm_format) {
switch (unorm_format) {
case DXGI_FORMAT_B8G8R8A8_UNORM:
return DXGI_FORMAT_B8G8R8A8_TYPELESS;

case DXGI_FORMAT_B8G8R8X8_UNORM:
return DXGI_FORMAT_B8G8R8X8_TYPELESS;

case DXGI_FORMAT_R8G8B8A8_UNORM:
return DXGI_FORMAT_R8G8B8A8_TYPELESS;

default:
return DXGI_FORMAT_UNKNOWN;
}
}

} // namespace dx_helpers
14 changes: 14 additions & 0 deletions src/platform/windows/dx_helpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <d3d11.h>

namespace dx_helpers {

DXGI_FORMAT
unorm_from_typeless_texture_format(DXGI_FORMAT typeless_format);
DXGI_FORMAT
srgb_from_typeless_texture_format(DXGI_FORMAT typeless_format);
DXGI_FORMAT
typeless_from_unorm_texture_format(DXGI_FORMAT unorm_format);

} // namespace dx_helpers

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "include/convert_base.hlsl"
#include "include/convert_srgb_base.hlsl"

#include "include/convert_yuv420_planar_y_ps_base.hlsl"

0 comments on commit cbd3c26

Please sign in to comment.