Skip to content
Merged
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 @@ -41,11 +41,12 @@ std::uint32_t standard64Extra(std::uint32_t x, std::uint32_t y, std::uint32_t el

ColorTileMode DecodeColorTileMode(std::uint32_t attrib3) {
const auto resourceType = (attrib3 >> 24u) & 3u;
require((attrib3 & 0x80002000u) == 0 && ((resourceType == 1 && (attrib3 & 0x1fffu) == 0) || resourceType == 2) && ((attrib3 >> 27u) & 7u) == 1, "AGC graphics: unsupported color depth, dimension, resource level or metadata mode");
require((attrib3 & 0x80002000u) == 0 && ((resourceType <= 1 && (attrib3 & 0x1fffu) == 0) || resourceType == 2) && ((attrib3 >> 27u) & 7u) == 1, "AGC graphics: unsupported color depth, dimension, resource level or metadata mode");
const auto mode = (attrib3 >> 14u) & 0x1fu;
const auto fmaskMode = (attrib3 >> 19u) & 0x1fu;
require(fmaskMode == 0 || fmaskMode == 0x18, "AGC graphics: unsupported color FMASK swizzle mode");
require(mode == 0 || mode == 5 || mode == 9 || mode == 0x1b, "AGC graphics: unsupported color tile mode");
require(resourceType != 0 || mode == 0 || mode == 0x1b, "AGC graphics: 1D color targets with a standard swizzle mode are invalid");
return static_cast<ColorTileMode>(mode);
}

Expand Down
1 change: 1 addition & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ ColorTarget DecodeColorBuffer(const Registers& cx, std::uint32_t slot) {
const auto attrib3 = read(cx, 0x3b8 + slot);
color.tileMode = DecodeColorTileMode(attrib3);
const bool volume = ((attrib3 >> 24u) & 3u) == 2u;
Require(((attrib3 >> 24u) & 3u) != 0u || (attrib2 & 0x3fffu) == 0u, "1D color targets taller than one row are unsupported");
if (volume) {
color.depth = (attrib3 & 0x1fffu) + 1u;
Require(maxMip == 0 && (info & 0x10000000u) == 0, "mipmapped or DCC 3D color targets are unsupported");
Expand Down
6 changes: 6 additions & 0 deletions core/libs/prx/libSceAgcDriver/tests/ColorTargetLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ void RunColorTargetLayoutTests() {
reject([] { DecodeColorTileMode(0x4dc6e000); });
reject([] { DecodeColorTileMode(0xcdc6c000); });
reject([] { DecodeColorTileMode(0x09004000); });
Require(DecodeColorTileMode(0x4cc6c000) == ColorTileMode::RenderTarget, "1D color descriptor was rejected");
reject([] { DecodeColorTileMode(0x4cc6c001); });
reject([] { DecodeColorTileMode(0x4fc6c000); });
Require(DecodeColorTileMode(0x08000000) == ColorTileMode::Linear, "linear 1D color descriptor was rejected");
reject([] { DecodeColorTileMode(0x08014000); });
reject([] { DecodeColorTileMode(0x08024000); });
reject([] { ColorTargetLayout(0, 1, ColorTileMode::RenderTarget); });
const ColorTargetLayout padded(63, 2, ColorTileMode::Linear);
Require(padded.Bytes() == 512 && padded.LinearBytes() == 504 && padded.Offset(0, 1) == 256, "linear rows are not padded to 256 bytes");
Expand Down
10 changes: 10 additions & 0 deletions core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,15 @@ void DepthStencilTests() {
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "DCC 3D color targets");
}

void OneDimensionalColorTests() {
auto queue = makeState();
queue.context[0x3b8] = 0x08000000;
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "taller than one row");
queue.context[0x3b0] = 63u << 14u;
const auto line = AgcDriver::Graphics::DecodeState(queue);
Require(line.color.extent.width == 64u && line.color.extent.height == 1u && line.color.address == reinterpret_cast<std::uintptr_t>(colorMemory.data()) && line.color.depth == 1u, "a 1D color target did not decode as one row");
}

void depthMaintenanceTests() {
for (const auto mode : {0x4u, 0x8u, 0x10u, 0x80u, 0x100u, 0x1000u, 0x4000u}) {
for (const auto clear : {0u, 1u, 2u, 3u}) {
Expand Down Expand Up @@ -2756,6 +2765,7 @@ int main() {
srgb8TargetTests();
DepthClipTests();
DepthStencilTests();
OneDimensionalColorTests();
ZExportTests();
DepthBoundsBiasTests();
conservativeZExportTests();
Expand Down
Loading