mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-27 16:02:37 +00:00
shader: evaluate unsigned min in runtime descriptors
This commit is contained in:
1 parent
f453a752bb
commit
f3cdf217ea
2 files changed
+40
-1
No files matched your search
@@ -85,6 +85,7 @@ bool IsRuntimeIntegerOp(ValueOpcode op) {
|
||||
case ValueOpcode::ISub64:
|
||||
case ValueOpcode::IMul32:
|
||||
case ValueOpcode::IMul64:
|
||||
case ValueOpcode::UMin32:
|
||||
case ValueOpcode::ShiftLeftLogical32:
|
||||
case ValueOpcode::ShiftLeftLogical64:
|
||||
case ValueOpcode::ShiftRightLogical32:
|
||||
@@ -639,6 +640,12 @@ private:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case ValueOpcode::UMin32:
|
||||
if (binary()) {
|
||||
result = std::min(static_cast<uint32_t>(a), static_cast<uint32_t>(b));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case ValueOpcode::BitwiseAnd32:
|
||||
if (binary()) {
|
||||
result = static_cast<uint32_t>(a & b);
|
||||
|
||||
@@ -234,6 +234,35 @@ void TestScalarAndVectorBufferAlias() {
|
||||
"scalar/vector alias did not share a dense index");
|
||||
}
|
||||
|
||||
void TestRuntimeUnsignedMinDescriptor() {
|
||||
Fixture fixture;
|
||||
const auto word3 = fixture.Emit(
|
||||
ValueOpcode::UMin32, {fixture.UserData(0), Value(0x100u)});
|
||||
const auto descriptor =
|
||||
fixture.Buffer({Value(0u), Value(0u), Value(64u), word3}, 0x330);
|
||||
MemoryInfo memory;
|
||||
memory.kind = ResourceKind::Buffer;
|
||||
fixture.Emit(ValueOpcode::LoadBufferU32,
|
||||
{descriptor, Value(0u), Value(0u), Value(0u), Value(true)},
|
||||
fixture.AddMemory(memory, 0x330));
|
||||
fixture.PlanAndTrack();
|
||||
|
||||
std::array<uint32_t, 1> user_data{0xffffffffu};
|
||||
SrtRuntime runtime{.user_data = user_data};
|
||||
DescriptorValue value;
|
||||
std::string error;
|
||||
const auto source = fixture.program.info.buffers[0].source;
|
||||
Check(EvaluateDescriptorSource(fixture.program, source, 0x330, runtime, value,
|
||||
&error) &&
|
||||
value.dwords[3] == 0x100u,
|
||||
"runtime descriptor unsigned minimum did not clamp its first operand");
|
||||
user_data[0] = 0x80u;
|
||||
Check(EvaluateDescriptorSource(fixture.program, source, 0x330, runtime, value,
|
||||
&error) &&
|
||||
value.dwords[3] == 0x80u,
|
||||
"runtime descriptor unsigned minimum did not preserve its first operand");
|
||||
}
|
||||
|
||||
void TestImagesSamplersAndAliases() {
|
||||
Fixture fixture;
|
||||
std::array<Value, 8> image_words;
|
||||
@@ -426,9 +455,11 @@ void TestPhiValidation() {
|
||||
static_cast<uint64_t>(Type::U32));
|
||||
phi.AddPhiOperand(left, Value(1u));
|
||||
phi.AddPhiOperand(right, Value(2u));
|
||||
const auto word3 = fixture.Emit(
|
||||
ValueOpcode::UMin32, {Value(&phi), Value(0x100u)}, 0, merge);
|
||||
const auto handle =
|
||||
fixture.Emit(ValueOpcode::GetBufferResource,
|
||||
{Value(&phi), Value(0u), Value(0u), Value(0u)},
|
||||
{Value(0u), Value(0u), Value(0u), word3},
|
||||
MemoryFlags{0, 20}, merge);
|
||||
MemoryInfo memory;
|
||||
memory.kind = ResourceKind::Buffer;
|
||||
@@ -628,6 +659,7 @@ int main() {
|
||||
};
|
||||
Run("dense buffers", TestDenseBufferTracking);
|
||||
Run("scalar/vector alias", TestScalarAndVectorBufferAlias);
|
||||
Run("runtime unsigned min", TestRuntimeUnsignedMinDescriptor);
|
||||
Run("images and samplers", TestImagesSamplersAndAliases);
|
||||
Run("SRT runtime", TestSrtFlatteningAndRuntimeMemoization);
|
||||
Run("dynamic SRT", TestDynamicSrtReadRemainsExplicit);
|
||||
|
||||
Reference in new issue
Block a user