Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ std::vector<std::byte> DecodeDisplayBuffer(const DisplayBuffer& buffer, std::spa
timing.Mark("detile_convert");
return pixels;
}
const auto blocksPerRow = (buffer.width + 127u) / 128u;
const bool rgba = DisplayRedLow(buffer.pixelFormat);
const bool pq = DisplayPq(buffer.pixelFormat);
const float whiteNits = pq ? PqToSdrWhiteNits(AgcDriver::CurrentHostHdr()) : 0.0f;
Expand All @@ -194,9 +193,7 @@ std::vector<std::byte> DecodeDisplayBuffer(const DisplayBuffer& buffer, std::spa
timing.Mark("validate_allocate");
for (std::uint32_t y = 0; y < buffer.height; ++y) {
for (std::uint32_t x = 0; x < buffer.width; ++x) {
const auto pitch = buffer.pitchInPixel == 0 ? buffer.width : buffer.pitchInPixel;
const auto tiled = buffer.tilingMode == 1 ? (static_cast<std::size_t>(y) * pitch + x) * 4u
: (static_cast<std::size_t>(y / 128u) * blocksPerRow + x / 128u) * 65536u + tileOffset(x, y);
const auto tiled = texelOffset(buffer, x, y, 4u);
const auto linear = (static_cast<std::size_t>(y) * buffer.width + x) * 4;
decodeTexel(source.data() + tiled, pixels.data() + linear, rgba, tenBit, pq, whiteNits);
}
Expand Down
21 changes: 21 additions & 0 deletions core/libs/tests/LinearDisplayBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <cstdlib>
#include <stdexcept>
#include <tuple>
#include <vector>

static void Require(bool condition) { if (!condition) std::abort(); }
template<typename TAction> static void Reject(TAction action) {
Expand Down Expand Up @@ -170,6 +171,25 @@ static void PqDisplay() {
}
}

static void GcnDisplay() {
AgcDriver::DisplayBuffer buffer{65536, 0x8000000000000000ull, 1920, 1024, AgcDriver::DisplayTilingGcn, 1920};
Require(AgcDriver::DisplayBufferOffset(buffer, 4, 0) == 32 && AgcDriver::DisplayBufferOffset(buffer, 0, 1) == 16);
std::vector<std::byte> source(AgcDriver::DisplayBufferSize(buffer));
for (std::uint32_t y = 0; y < buffer.height; ++y) {
for (std::uint32_t x = 0; x < buffer.width; ++x) {
const std::uint32_t texel = x | y << 16u;
std::memcpy(source.data() + AgcDriver::DisplayBufferOffset(buffer, x, y), &texel, sizeof(texel));
}
}
const auto pixels = AgcDriver::DecodeDisplayBuffer(buffer, source);
for (std::uint32_t y = 0; y < buffer.height; ++y) {
for (std::uint32_t x = 0; x < buffer.width; ++x) {
const std::uint32_t texel = x | y << 16u;
Require(std::memcmp(pixels.data() + (static_cast<std::size_t>(y) * buffer.width + x) * 4u, &texel, sizeof(texel)) == 0);
}
}
}

int main() {
AgcDriver::DisplayBuffer buffer{65536, 0x8000000000000000ull, 2, 2, 1, 3};
const std::array<unsigned char, 24> input{1,2,3,4, 5,6,7,8, 99,99,99,99,
Expand All @@ -195,4 +215,5 @@ int main() {
HalfFloatCodes();
HalfFloatDisplay();
PqDisplay();
GcnDisplay();
}
Loading