Skip to content

Commit

Permalink
gpu2: tweak formats
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Oct 1, 2024
1 parent 8d1e4f5 commit 59946fe
Show file tree
Hide file tree
Showing 6 changed files with 664 additions and 316 deletions.
2 changes: 1 addition & 1 deletion hw/amdgpu/bridge/src/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

static int gShmFd = -1;
static constexpr std::size_t kShmSize = sizeof(amdgpu::bridge::BridgeHeader) +
(sizeof(std::uint64_t) * 256);
(sizeof(std::uint64_t) * 1024);
amdgpu::bridge::BridgeHeader *
amdgpu::bridge::createShmCommandBuffer(const char *name) {
if (gShmFd != -1) {
Expand Down
6 changes: 3 additions & 3 deletions rpcsx-gpu2/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,19 @@ bool Device::flip(std::int64_t pid, int bufferIndex, std::uint64_t arg,

case 0x80002200:
dfmt = gnm::kDataFormat8_8_8_8;
nfmt = gnm::kNumericFormatUNorm;
nfmt = gnm::kNumericFormatSrgb;
flipType = FlipType::Std;
break;

case 0x88740000:
case 0x88060000:
dfmt = gnm::kDataFormat2_10_10_10;
nfmt = gnm::kNumericFormatUNorm;
nfmt = gnm::kNumericFormatSNorm;
break;

case 0xc1060000:
dfmt = gnm::kDataFormat16_16_16_16;
nfmt = gnm::kNumericFormatSrgb;
nfmt = gnm::kNumericFormatFloat;
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion rpcsx-gpu2/Registers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ struct CbColorInfo {
std::uint32_t endian : 2;
gnm::DataFormat dfmt : 5;
std::uint32_t linearGeneral : 1;
gnm::NumericFormat nfmt : 3;
gnm::CbNumericFormat nfmt : 3;
CbCompSwap compSwap : 2;
std::uint32_t fastClear : 1;
std::uint32_t compression : 1;
Expand Down
2 changes: 1 addition & 1 deletion rpcsx-gpu2/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void amdgpu::draw(GraphicsPipe &pipe, int vmId, std::uint32_t firstVertex,
renderTargetInfo.extent.height = vkViewPortScissor.extent.height;
renderTargetInfo.extent.depth = 1;
renderTargetInfo.dfmt = cbColor.info.dfmt;
renderTargetInfo.nfmt = cbColor.info.nfmt;
renderTargetInfo.nfmt = gnm::toNumericFormat(cbColor.info.nfmt, cbColor.info.dfmt);
renderTargetInfo.mipCount = 1;
renderTargetInfo.arrayLayerCount = 1;

Expand Down
19 changes: 19 additions & 0 deletions rpcsx-gpu2/lib/gnm/include/gnm/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ enum NumericFormat : unsigned {
kNumericFormatUBScaled = 0x0000000D,
};

enum CbNumericFormat : unsigned {
kCbNumericFormatUNorm = 0,
kCbNumericFormatSNorm = 1,
kCbNumericFormatUInt = 4,
kCbNumericFormatSint = 5,
kCbNumericFormatSrgb = 6,
kCbNumericFormatFloat = 7,
};

enum ZFormat {
kZFormatInvalid = 0,
kZFormat16 = 1,
Expand Down Expand Up @@ -286,4 +295,14 @@ enum class AnisoRatio : std::uint8_t {
x16,
};

constexpr NumericFormat toNumericFormat(CbNumericFormat cbFmt,
DataFormat dfmt) {
if (cbFmt == kCbNumericFormatSrgb || dfmt == kDataFormat8_8_8_8 ||
dfmt == kDataFormat10_10_10_2) {
return kNumericFormatSrgb;
}

return static_cast<NumericFormat>(cbFmt);
}

} // namespace gnm
Loading

0 comments on commit 59946fe

Please sign in to comment.