[D3D12] Swap red and blue in 8bpp gamma ramp

This commit is contained in:
Triang3l 2018-12-09 15:53:57 +03:00
parent 1ee3ed03fd
commit 7698944673
2 changed files with 12 additions and 4 deletions

View File

@ -68,9 +68,9 @@ struct GammaRamp {
struct NormalEntry { struct NormalEntry {
union { union {
struct { struct {
uint32_t r : 10;
uint32_t g : 10;
uint32_t b : 10; uint32_t b : 10;
uint32_t g : 10;
uint32_t r : 10;
uint32_t : 2; uint32_t : 2;
}; };
uint32_t value; uint32_t value;

View File

@ -945,8 +945,15 @@ void D3D12CommandProcessor::PerformSwap(uint32_t frontbuffer_ptr,
if (dirty_gamma_ramp_normal_) { if (dirty_gamma_ramp_normal_) {
const D3D12_PLACED_SUBRESOURCE_FOOTPRINT& gamma_ramp_footprint = const D3D12_PLACED_SUBRESOURCE_FOOTPRINT& gamma_ramp_footprint =
gamma_ramp_footprints_[current_queue_frame_ * 2]; gamma_ramp_footprints_[current_queue_frame_ * 2];
std::memcpy(gamma_ramp_upload_mapping_ + gamma_ramp_footprint.Offset, volatile uint32_t* mapping = reinterpret_cast<uint32_t*>(
gamma_ramp_.normal, 256 * sizeof(uint32_t)); gamma_ramp_upload_mapping_ + gamma_ramp_footprint.Offset);
for (uint32_t i = 0; i < 256; ++i) {
uint32_t value = gamma_ramp_.normal[i].value;
// Swap red and blue (Project Sylpheed has settings allowing separate
// configuration).
mapping[i] = ((value & 1023) << 20) | (value & (1023 << 10)) |
((value >> 20) & 1023);
}
PushTransitionBarrier(gamma_ramp_texture_, gamma_ramp_texture_state_, PushTransitionBarrier(gamma_ramp_texture_, gamma_ramp_texture_state_,
D3D12_RESOURCE_STATE_COPY_DEST); D3D12_RESOURCE_STATE_COPY_DEST);
gamma_ramp_texture_state_ = D3D12_RESOURCE_STATE_COPY_DEST; gamma_ramp_texture_state_ = D3D12_RESOURCE_STATE_COPY_DEST;
@ -968,6 +975,7 @@ void D3D12CommandProcessor::PerformSwap(uint32_t frontbuffer_ptr,
volatile uint32_t* mapping = reinterpret_cast<uint32_t*>( volatile uint32_t* mapping = reinterpret_cast<uint32_t*>(
gamma_ramp_upload_mapping_ + gamma_ramp_footprint.Offset); gamma_ramp_upload_mapping_ + gamma_ramp_footprint.Offset);
for (uint32_t i = 0; i < 128; ++i) { for (uint32_t i = 0; i < 128; ++i) {
// TODO(Triang3l): Find a game to test if red and blue need to be swapped.
mapping[i] = (gamma_ramp_.pwl[i].values[0].base >> 6) | mapping[i] = (gamma_ramp_.pwl[i].values[0].base >> 6) |
(uint32_t(gamma_ramp_.pwl[i].values[1].base >> 6) << 10) | (uint32_t(gamma_ramp_.pwl[i].values[1].base >> 6) << 10) |
(uint32_t(gamma_ramp_.pwl[i].values[2].base >> 6) << 20); (uint32_t(gamma_ramp_.pwl[i].values[2].base >> 6) << 20);