mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
Run clang-format
This commit is contained in:
parent
d999edfd2c
commit
1f05a8a6a6
125 changed files with 10664 additions and 7154 deletions
|
|
@ -37,8 +37,8 @@ amdgpu::bridge::createShmCommandBuffer(const char *name) {
|
|||
|
||||
gShmFd = fd;
|
||||
auto result = new (memory) amdgpu::bridge::BridgeHeader();
|
||||
result->size = (kShmSize - sizeof(amdgpu::bridge::BridgeHeader)) /
|
||||
sizeof(std::uint64_t);
|
||||
result->size =
|
||||
(kShmSize - sizeof(amdgpu::bridge::BridgeHeader)) / sizeof(std::uint64_t);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,5 +98,4 @@ enum PM4Opcodes {
|
|||
};
|
||||
|
||||
const char *pm4OpcodeToString(int opcode);
|
||||
} // namespace amdgpu::device
|
||||
|
||||
} // namespace amdgpu
|
||||
|
|
|
|||
|
|
@ -313,7 +313,8 @@ struct Tiler1d {
|
|||
m_bitsPerElement = 128;// getBitsPerElement(texture->dfmt);
|
||||
m_microTileMode = Gnm::MicroTileMode::kMicroTileModeThin;
|
||||
m_tileThickness = (m_arrayMode == Gnm::kArrayMode1dTiledThick) ? 4 : 1;
|
||||
m_tileBytes = (kMicroTileWidth * kMicroTileHeight * m_tileThickness * m_bitsPerElement + 7) / 8;
|
||||
m_tileBytes = (kMicroTileWidth * kMicroTileHeight * m_tileThickness *
|
||||
m_bitsPerElement + 7) / 8;
|
||||
|
||||
auto width = texture->width + 1;
|
||||
auto height = texture->height + 1;
|
||||
|
|
@ -326,8 +327,8 @@ struct Tiler1d {
|
|||
m_arrayMode = (Gnm::ArrayMode)2;
|
||||
m_bitsPerElement = 128;
|
||||
m_microTileMode = (Gnm::MicroTileMode)1;
|
||||
m_tileThickness= 1;
|
||||
m_tileBytes= 1024;
|
||||
m_tileThickness = 1;
|
||||
m_tileBytes = 1024;
|
||||
m_tilesPerRow = 16;
|
||||
m_tilesPerSlice = 256;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ struct RemoteMemory {
|
|||
char *shmPointer;
|
||||
|
||||
template <typename T = void> T *getPointer(std::uint64_t address) const {
|
||||
return address ? reinterpret_cast<T *>(shmPointer + address - 0x40000) : nullptr;
|
||||
return address ? reinterpret_cast<T *>(shmPointer + address - 0x40000)
|
||||
: nullptr;
|
||||
}
|
||||
};
|
||||
} // namespace amdgpu
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ class Verify {
|
|||
util::SourceLocation mLocation;
|
||||
|
||||
public:
|
||||
util::SourceLocation location() const {
|
||||
return mLocation;
|
||||
}
|
||||
util::SourceLocation location() const { return mLocation; }
|
||||
|
||||
Verify(util::SourceLocation location = util::SourceLocation())
|
||||
: mLocation(location) {}
|
||||
|
|
|
|||
|
|
@ -12,4 +12,3 @@ inline Verify operator<<(Verify lhs, VkResult result) {
|
|||
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include "SourceLocation.hpp"
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
|
||||
namespace util {
|
||||
[[noreturn]] inline void unreachable_impl() { std::fflush(stdout); __builtin_trap(); }
|
||||
[[noreturn]] inline void unreachable_impl() {
|
||||
std::fflush(stdout);
|
||||
__builtin_trap();
|
||||
}
|
||||
|
||||
[[noreturn]] inline void unreachable(SourceLocation location = {}) {
|
||||
std::printf("\n");
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ struct ImageValue : Value {};
|
|||
struct SampledImageValue : Value {};
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Value, T>)
|
||||
struct ConstantValue : T {};
|
||||
requires(std::is_base_of_v<Value, T>) struct ConstantValue : T {
|
||||
};
|
||||
|
||||
struct AnyConstantValue : Value {
|
||||
AnyConstantValue() = default;
|
||||
|
|
@ -95,28 +95,28 @@ struct AnyConstantValue : Value {
|
|||
};
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
struct VectorOfType : VectorType {};
|
||||
requires(std::is_base_of_v<Type, T>) struct VectorOfType : VectorType {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
struct ArrayOfType : ArrayType {};
|
||||
requires(std::is_base_of_v<Type, T>) struct ArrayOfType : ArrayType {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
struct VectorOfValue : VectorValue {};
|
||||
requires(std::is_base_of_v<Type, T>) struct VectorOfValue : VectorValue {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
struct ArrayOfValue : ArrayValue {};
|
||||
requires(std::is_base_of_v<Type, T>) struct ArrayOfValue : ArrayValue {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
struct PointerToType : PointerType {};
|
||||
requires(std::is_base_of_v<Type, T>) struct PointerToType : PointerType {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
struct PointerToValue : PointerValue {};
|
||||
requires(std::is_base_of_v<Type, T>) struct PointerToValue : PointerValue {
|
||||
};
|
||||
|
||||
struct StructPointerValue : Value {};
|
||||
|
||||
|
|
@ -125,45 +125,21 @@ struct VariableValue : PointerValue {};
|
|||
namespace detail {
|
||||
template <typename T> struct TypeToValueImpl;
|
||||
|
||||
template <> struct TypeToValueImpl<Type> {
|
||||
using type = Value;
|
||||
};
|
||||
template <> struct TypeToValueImpl<BoolType> {
|
||||
using type = BoolValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<IntType> {
|
||||
using type = IntValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<SIntType> {
|
||||
using type = SIntValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<UIntType> {
|
||||
using type = UIntValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<FloatType> {
|
||||
using type = FloatValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<StructType> {
|
||||
using type = StructValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<PointerType> {
|
||||
using type = PointerValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<Type> { using type = Value; };
|
||||
template <> struct TypeToValueImpl<BoolType> { using type = BoolValue; };
|
||||
template <> struct TypeToValueImpl<IntType> { using type = IntValue; };
|
||||
template <> struct TypeToValueImpl<SIntType> { using type = SIntValue; };
|
||||
template <> struct TypeToValueImpl<UIntType> { using type = UIntValue; };
|
||||
template <> struct TypeToValueImpl<FloatType> { using type = FloatValue; };
|
||||
template <> struct TypeToValueImpl<StructType> { using type = StructValue; };
|
||||
template <> struct TypeToValueImpl<PointerType> { using type = PointerValue; };
|
||||
template <> struct TypeToValueImpl<VariableValue> {
|
||||
using type = PointerValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<VectorType> {
|
||||
using type = VectorValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<ArrayType> {
|
||||
using type = ArrayValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<SamplerType> {
|
||||
using type = SamplerValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<ImageType> {
|
||||
using type = ImageValue;
|
||||
};
|
||||
template <> struct TypeToValueImpl<VectorType> { using type = VectorValue; };
|
||||
template <> struct TypeToValueImpl<ArrayType> { using type = ArrayValue; };
|
||||
template <> struct TypeToValueImpl<SamplerType> { using type = SamplerValue; };
|
||||
template <> struct TypeToValueImpl<ImageType> { using type = ImageValue; };
|
||||
template <> struct TypeToValueImpl<SampledImageType> {
|
||||
using type = SampledImageValue;
|
||||
};
|
||||
|
|
@ -184,8 +160,7 @@ template <typename T>
|
|||
using TypeToValue = typename detail::TypeToValueImpl<T>::type;
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
struct ScalarOrVectorOfValue : Value {
|
||||
requires(std::is_base_of_v<Type, T>) struct ScalarOrVectorOfValue : Value {
|
||||
ScalarOrVectorOfValue() = default;
|
||||
|
||||
ScalarOrVectorOfValue(TypeToValue<T> scalar) { id = scalar.id; }
|
||||
|
|
@ -199,8 +174,8 @@ using ConstantInt = ConstantValue<IntValue>;
|
|||
using ConstantFloat = ConstantValue<FloatValue>;
|
||||
|
||||
template <typename ToT, typename FromT>
|
||||
requires(std::is_base_of_v<FromT, ToT> && std::is_base_of_v<Id, FromT>)
|
||||
ToT cast(FromT from) {
|
||||
requires(std::is_base_of_v<FromT, ToT> &&std::is_base_of_v<Id, FromT>) ToT
|
||||
cast(FromT from) {
|
||||
ToT result;
|
||||
result.id = from.id;
|
||||
return result;
|
||||
|
|
@ -277,8 +252,7 @@ struct IdGenerator {
|
|||
std::uint32_t bounds = 1;
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Id, T>)
|
||||
T newId() {
|
||||
requires(std::is_base_of_v<Id, T>) T newId() {
|
||||
T result;
|
||||
result.id = bounds++;
|
||||
return result;
|
||||
|
|
@ -544,9 +518,8 @@ public:
|
|||
|
||||
// arithmetic
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<ScalarType, T>)
|
||||
TypeToValue<T> createInst(spv::Op op, T resultType,
|
||||
std::span<const TypeToValue<T>> operands) {
|
||||
requires(std::is_base_of_v<ScalarType, T>) TypeToValue<T> createInst(
|
||||
spv::Op op, T resultType, std::span<const TypeToValue<T>> operands) {
|
||||
auto region = bodyRegion.pushOp(op, 3 + operands.size());
|
||||
auto id = newId<TypeToValue<T>>();
|
||||
region.pushIdUse(resultType);
|
||||
|
|
@ -583,142 +556,142 @@ public:
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<SIntType, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T>)
|
||||
TypeToValue<T> createSNegate(T resultType, TypeToValue<T> operand) {
|
||||
requires(std::is_same_v<SIntType, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T>)
|
||||
TypeToValue<T> createSNegate(T resultType, TypeToValue<T> operand) {
|
||||
return createInst(spv::Op::OpSNegate, resultType, std::array{operand});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFNegate(T resultType, TypeToValue<T> operand) {
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFNegate(T resultType, TypeToValue<T> operand) {
|
||||
return createInst(spv::Op::OpFNegate, resultType, std::array{operand});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
|
||||
std::is_same_v<VectorOfType<IntType>, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T> ||
|
||||
std::is_same_v<VectorOfType<UIntType>, T>)
|
||||
TypeToValue<T> createIAdd(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
|
||||
std::is_same_v<VectorOfType<IntType>, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T> ||
|
||||
std::is_same_v<VectorOfType<UIntType>, T>)
|
||||
TypeToValue<T> createIAdd(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpIAdd, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFAdd(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFAdd(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpFAdd, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
|
||||
std::is_same_v<VectorOfType<IntType>, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T> ||
|
||||
std::is_same_v<VectorOfType<UIntType>, T>)
|
||||
TypeToValue<T> createISub(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
|
||||
std::is_same_v<VectorOfType<IntType>, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T> ||
|
||||
std::is_same_v<VectorOfType<UIntType>, T>)
|
||||
TypeToValue<T> createISub(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpISub, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFSub(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFSub(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpFSub, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
|
||||
std::is_same_v<VectorOfType<IntType>, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T> ||
|
||||
std::is_same_v<VectorOfType<UIntType>, T>)
|
||||
TypeToValue<T> createIMul(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<IntType, T> || std::is_base_of_v<IntType, T> ||
|
||||
std::is_same_v<VectorOfType<IntType>, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T> ||
|
||||
std::is_same_v<VectorOfType<UIntType>, T>)
|
||||
TypeToValue<T> createIMul(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpIMul, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFMul(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFMul(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpFMul, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<UIntType, T> ||
|
||||
std::is_same_v<VectorOfType<UIntType>, T>)
|
||||
TypeToValue<T> createUDiv(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<UIntType, T> ||
|
||||
std::is_same_v<VectorOfType<UIntType>, T>)
|
||||
TypeToValue<T> createUDiv(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpUDiv, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
template <typename T>
|
||||
requires(std::is_same_v<SIntType, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T>)
|
||||
TypeToValue<T> createSDiv(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<SIntType, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T>)
|
||||
TypeToValue<T> createSDiv(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpSDiv, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFDiv(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFDiv(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpFDiv, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
template <typename T>
|
||||
requires(std::is_same_v<UIntType, T> ||
|
||||
std::is_same_v<VectorOfType<UIntType>, T>)
|
||||
TypeToValue<T> createUMod(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<UIntType, T> ||
|
||||
std::is_same_v<VectorOfType<UIntType>, T>)
|
||||
TypeToValue<T> createUMod(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpUMod, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
template <typename T>
|
||||
requires(std::is_same_v<SIntType, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T>)
|
||||
TypeToValue<T> createSRem(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<SIntType, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T>)
|
||||
TypeToValue<T> createSRem(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpSRem, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_same_v<SIntType, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T>)
|
||||
TypeToValue<T> createSMod(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<SIntType, T> ||
|
||||
std::is_same_v<VectorOfType<SIntType>, T>)
|
||||
TypeToValue<T> createSMod(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpSMod, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
template <typename T>
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFRem(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFRem(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpFRem, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
template <typename T>
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFMod(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
requires(std::is_same_v<FloatType, T> ||
|
||||
std::is_same_v<VectorOfType<FloatType>, T>)
|
||||
TypeToValue<T> createFMod(T resultType, TypeToValue<T> operand1,
|
||||
TypeToValue<T> operand2) {
|
||||
return createInst(spv::Op::OpFMod, resultType,
|
||||
std::array{operand1, operand2});
|
||||
}
|
||||
|
|
@ -795,9 +768,8 @@ public:
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
TypeToValue<T> createPhi(T resultType,
|
||||
std::span<const std::pair<Value, Block>> values) {
|
||||
requires(std::is_base_of_v<Type, T>) TypeToValue<T> createPhi(
|
||||
T resultType, std::span<const std::pair<Value, Block>> values) {
|
||||
return cast<TypeToValue<T>>(
|
||||
createPhi(static_cast<Type>(resultType), values));
|
||||
}
|
||||
|
|
@ -883,8 +855,8 @@ public:
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
TypeToValue<T> createLoad(T resultType, PointerValue pointer) {
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
TypeToValue<T> createLoad(T resultType, PointerValue pointer) {
|
||||
auto region = bodyRegion.pushOp(spv::Op::OpLoad, 4);
|
||||
auto id = newId<TypeToValue<T>>();
|
||||
region.pushIdUse(resultType);
|
||||
|
|
@ -1521,8 +1493,7 @@ public:
|
|||
return id;
|
||||
}
|
||||
|
||||
IntValue createImageQueryLevels(IntType resultType,
|
||||
ImageValue sampledImage) {
|
||||
IntValue createImageQueryLevels(IntType resultType, ImageValue sampledImage) {
|
||||
auto region = bodyRegion.pushOp(spv::Op::OpImageQueryLevels, 4);
|
||||
auto id = newId<IntValue>();
|
||||
region.pushIdUse(resultType);
|
||||
|
|
@ -1617,8 +1588,8 @@ public:
|
|||
: mIdGenerator(&idGenerator), capabilityRegion{1}, extensionRegion{1},
|
||||
extInstRegion{4}, memoryModelRegion{3}, entryPointRegion{1},
|
||||
executionModeRegion{1}, debugRegion{0}, annotationRegion{1},
|
||||
globalRegion{1}, functionDeclRegion{1},
|
||||
functionRegion{expInstructionsCount} {}
|
||||
globalRegion{1}, functionDeclRegion{1}, functionRegion{
|
||||
expInstructionsCount} {}
|
||||
|
||||
SpirvBuilder clone() const { return *this; }
|
||||
|
||||
|
|
@ -1698,8 +1669,8 @@ public:
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
TypeToValue<T> createUndef(T resultType) {
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
TypeToValue<T> createUndef(T resultType) {
|
||||
return cast<TypeToValue<T>>(createUndef(resultType));
|
||||
}
|
||||
|
||||
|
|
@ -1985,8 +1956,8 @@ public:
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
PointerToType<T> createTypePointer(spv::StorageClass storageClass, T type) {
|
||||
requires(std::is_base_of_v<Type, T>) PointerToType<T> createTypePointer(
|
||||
spv::StorageClass storageClass, T type) {
|
||||
return cast<PointerToType<T>>(
|
||||
createTypePointer(storageClass, static_cast<Type>(type)));
|
||||
}
|
||||
|
|
@ -2024,9 +1995,9 @@ public:
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
ConstantValue<TypeToValue<T>>
|
||||
createConstant(T type, std::span<const std::uint32_t> values) {
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
ConstantValue<TypeToValue<T>> createConstant(
|
||||
T type, std::span<const std::uint32_t> values) {
|
||||
auto region = globalRegion.pushOp(spv::Op::OpConstant, 3 + values.size());
|
||||
auto id = newId<ConstantValue<TypeToValue<T>>>();
|
||||
region.pushIdUse(type);
|
||||
|
|
@ -2038,14 +2009,16 @@ public:
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
ConstantValue<TypeToValue<T>> createConstant32(T type, std::uint32_t value) {
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
ConstantValue<TypeToValue<T>> createConstant32(T type,
|
||||
std::uint32_t value) {
|
||||
return createConstant(type, std::array{value});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
ConstantValue<TypeToValue<T>> createConstant64(T type, std::uint64_t value) {
|
||||
requires(std::is_base_of_v<Type, T>)
|
||||
ConstantValue<TypeToValue<T>> createConstant64(T type,
|
||||
std::uint64_t value) {
|
||||
return createConstant(type,
|
||||
std::array{static_cast<std::uint32_t>(value),
|
||||
static_cast<std::uint32_t>(value >> 32)});
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Stage.hpp"
|
||||
#include "AccessOp.hpp"
|
||||
#include "Stage.hpp"
|
||||
|
||||
#include <amdgpu/RemoteMemory.hpp>
|
||||
|
||||
|
|
@ -11,11 +11,7 @@
|
|||
|
||||
namespace amdgpu::shader {
|
||||
struct Shader {
|
||||
enum class UniformKind {
|
||||
Buffer,
|
||||
Sampler,
|
||||
Image
|
||||
};
|
||||
enum class UniformKind { Buffer, Sampler, Image };
|
||||
|
||||
struct UniformInfo {
|
||||
std::uint32_t binding;
|
||||
|
|
|
|||
|
|
@ -9,18 +9,18 @@
|
|||
#include "Value.hpp"
|
||||
#include "scf.hpp"
|
||||
|
||||
#include <forward_list>
|
||||
#include <amdgpu/RemoteMemory.hpp>
|
||||
#include <forward_list>
|
||||
#include <spirv/spirv-builder.hpp>
|
||||
#include <unordered_map>
|
||||
#include <util/unreachable.hpp>
|
||||
|
||||
#include <bit>
|
||||
#include <span>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
namespace amdgpu::shader {
|
||||
/*
|
||||
|
|
@ -99,13 +99,12 @@ class ConverterContext {
|
|||
spirv::Function mDiscardFn;
|
||||
|
||||
public:
|
||||
ConverterContext(RemoteMemory memory, Stage stage) : mMemory(memory), mStage(stage) {
|
||||
ConverterContext(RemoteMemory memory, Stage stage)
|
||||
: mMemory(memory), mStage(stage) {
|
||||
mGlslStd450 = mBuilder.createExtInstImport("GLSL.std.450");
|
||||
}
|
||||
|
||||
const decltype(mInterfaces) &getInterfaces() const {
|
||||
return mInterfaces;
|
||||
}
|
||||
const decltype(mInterfaces) &getInterfaces() const { return mInterfaces; }
|
||||
|
||||
spirv::SpirvBuilder &getBuilder() { return mBuilder; }
|
||||
RemoteMemory getMemory() const { return mMemory; }
|
||||
|
|
@ -155,11 +154,13 @@ public:
|
|||
}
|
||||
|
||||
spirv::ArrayOfType<spirv::UIntType> getArrayUint32x8Type() {
|
||||
return spirv::cast<spirv::ArrayOfType<spirv::UIntType>>(getType(TypeId::ArrayUInt32x8));
|
||||
return spirv::cast<spirv::ArrayOfType<spirv::UIntType>>(
|
||||
getType(TypeId::ArrayUInt32x8));
|
||||
}
|
||||
|
||||
spirv::ArrayOfType<spirv::UIntType> getArrayUint32x16Type() {
|
||||
return spirv::cast<spirv::ArrayOfType<spirv::UIntType>>(getType(TypeId::ArrayUInt32x16));
|
||||
return spirv::cast<spirv::ArrayOfType<spirv::UIntType>>(
|
||||
getType(TypeId::ArrayUInt32x16));
|
||||
}
|
||||
|
||||
spirv::SIntType getSint32Type() {
|
||||
|
|
@ -225,12 +226,14 @@ public:
|
|||
return spirv::cast<spirv::ImageType>(getType(TypeId::Image2D));
|
||||
}
|
||||
spirv::SampledImageType getSampledImage2DType() {
|
||||
return spirv::cast<spirv::SampledImageType>(getType(TypeId::SampledImage2D));
|
||||
return spirv::cast<spirv::SampledImageType>(
|
||||
getType(TypeId::SampledImage2D));
|
||||
}
|
||||
|
||||
UniformInfo *createStorageBuffer(TypeId type);
|
||||
UniformInfo *getOrCreateStorageBuffer(std::uint32_t *vbuffer, TypeId type);
|
||||
UniformInfo *getOrCreateUniformConstant(std::uint32_t *buffer, std::size_t size, TypeId type);
|
||||
UniformInfo *getOrCreateUniformConstant(std::uint32_t *buffer,
|
||||
std::size_t size, TypeId type);
|
||||
spirv::VariableValue getThreadId();
|
||||
spirv::VariableValue getWorkgroupId();
|
||||
spirv::VariableValue getLocalInvocationId();
|
||||
|
|
@ -250,8 +253,6 @@ public:
|
|||
Function *createFunction(std::size_t expectedSize);
|
||||
Fragment *createFragment(std::size_t expectedSize);
|
||||
|
||||
std::vector<UniformInfo> &getUniforms() {
|
||||
return mUniforms;
|
||||
}
|
||||
std::vector<UniformInfo> &getUniforms() { return mUniforms; }
|
||||
};
|
||||
} // namespace amdgpu::shader
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@
|
|||
#include <spirv/spirv-builder.hpp>
|
||||
|
||||
namespace amdgpu::shader {
|
||||
enum class OperandGetFlags {
|
||||
None,
|
||||
PreserveType = 1 << 0
|
||||
};
|
||||
enum class OperandGetFlags { None, PreserveType = 1 << 0 };
|
||||
|
||||
struct Function;
|
||||
class ConverterContext;
|
||||
|
|
@ -36,9 +33,7 @@ struct Fragment {
|
|||
std::uint64_t jumpAddress = 0;
|
||||
spirv::BoolValue branchCondition;
|
||||
|
||||
void appendBranch(Fragment &other) {
|
||||
other.predecessors.push_back(this);
|
||||
}
|
||||
void appendBranch(Fragment &other) { other.predecessors.push_back(this); }
|
||||
|
||||
void injectValuesFromPreds();
|
||||
|
||||
|
|
@ -47,34 +42,31 @@ struct Fragment {
|
|||
spirv::SamplerValue createSampler(RegisterId base);
|
||||
spirv::ImageValue createImage(RegisterId base, bool r128); // TODO: params
|
||||
Value createCompositeExtract(Value composite, std::uint32_t member);
|
||||
Value getOperand(RegisterId id, TypeId type, OperandGetFlags flags = OperandGetFlags::None);
|
||||
Value getOperand(RegisterId id, TypeId type,
|
||||
OperandGetFlags flags = OperandGetFlags::None);
|
||||
void setOperand(RegisterId id, Value value);
|
||||
void setVcc(Value value);
|
||||
void setScc(Value value);
|
||||
spirv::BoolValue getScc();
|
||||
spirv::Value createBitcast(spirv::Type to, spirv::Type from, spirv::Value value);
|
||||
spirv::Value createBitcast(spirv::Type to, spirv::Type from,
|
||||
spirv::Value value);
|
||||
|
||||
Value getScalarOperand(int id, TypeId type, OperandGetFlags flags = OperandGetFlags::None) {
|
||||
Value getScalarOperand(int id, TypeId type,
|
||||
OperandGetFlags flags = OperandGetFlags::None) {
|
||||
return getOperand(RegisterId::Scalar(id), type, flags);
|
||||
}
|
||||
Value getVectorOperand(int id, TypeId type, OperandGetFlags flags = OperandGetFlags::None) {
|
||||
Value getVectorOperand(int id, TypeId type,
|
||||
OperandGetFlags flags = OperandGetFlags::None) {
|
||||
return getOperand(RegisterId::Vector(id), type, flags);
|
||||
}
|
||||
Value getAttrOperand(int id, TypeId type, OperandGetFlags flags = OperandGetFlags::None) {
|
||||
Value getAttrOperand(int id, TypeId type,
|
||||
OperandGetFlags flags = OperandGetFlags::None) {
|
||||
return getOperand(RegisterId::Attr(id), type, flags);
|
||||
}
|
||||
Value getVccLo() {
|
||||
return getOperand(RegisterId::VccLo, TypeId::UInt32);
|
||||
}
|
||||
Value getVccHi() {
|
||||
return getOperand(RegisterId::VccHi, TypeId::UInt32);
|
||||
}
|
||||
Value getExecLo() {
|
||||
return getOperand(RegisterId::ExecLo, TypeId::UInt32);
|
||||
}
|
||||
Value getExecHi() {
|
||||
return getOperand(RegisterId::ExecHi, TypeId::UInt32);
|
||||
}
|
||||
Value getVccLo() { return getOperand(RegisterId::VccLo, TypeId::UInt32); }
|
||||
Value getVccHi() { return getOperand(RegisterId::VccHi, TypeId::UInt32); }
|
||||
Value getExecLo() { return getOperand(RegisterId::ExecLo, TypeId::UInt32); }
|
||||
Value getExecHi() { return getOperand(RegisterId::ExecHi, TypeId::UInt32); }
|
||||
void setScalarOperand(int id, Value value) {
|
||||
setOperand(RegisterId::Scalar(id), value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1419,7 +1419,8 @@ struct Mtbuf {
|
|||
bool idxen = fetchMaskedValue(inst[0], idxenMask);
|
||||
bool glc = fetchMaskedValue(inst[0], glcMask);
|
||||
SurfaceFormat dfmt = (SurfaceFormat)fetchMaskedValue(inst[0], dfmtMask);
|
||||
TextureChannelType nfmt = (TextureChannelType)fetchMaskedValue(inst[0], nfmtMask);
|
||||
TextureChannelType nfmt =
|
||||
(TextureChannelType)fetchMaskedValue(inst[0], nfmtMask);
|
||||
|
||||
std::uint8_t vaddr = fetchMaskedValue(inst[1], vaddrMask);
|
||||
std::uint8_t vdata = fetchMaskedValue(inst[1], vdataMask);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
template <std::invocable<BasicBlock *> T> void walkPredecessors(T &&cb) const {
|
||||
template <std::invocable<BasicBlock *> T>
|
||||
void walkPredecessors(T &&cb) const {
|
||||
for (auto pred : predecessors) {
|
||||
cb(pred);
|
||||
}
|
||||
|
|
@ -92,7 +93,9 @@ public:
|
|||
return successors[1] != nullptr ? 2 : 1;
|
||||
}
|
||||
|
||||
BasicBlock *getSuccessor(std::size_t index) const { return successors[index]; }
|
||||
BasicBlock *getSuccessor(std::size_t index) const {
|
||||
return successors[index];
|
||||
}
|
||||
|
||||
void split(BasicBlock *target);
|
||||
};
|
||||
|
|
@ -108,7 +111,7 @@ public:
|
|||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
BasicBlock *getBasicBlock(std::uint64_t address) {
|
||||
if (auto it = basicBlocks.lower_bound(address); it != basicBlocks.end()) {
|
||||
auto bb = &it->second;
|
||||
|
|
|
|||
|
|
@ -31,51 +31,40 @@ class Node {
|
|||
public:
|
||||
virtual ~Node() = default;
|
||||
virtual void print(const PrintOptions &options, unsigned depth) = 0;
|
||||
virtual bool isEqual(const Node &other) const {
|
||||
return this == &other;
|
||||
}
|
||||
virtual bool isEqual(const Node &other) const { return this == &other; }
|
||||
|
||||
void dump() {
|
||||
print({}, 0);
|
||||
}
|
||||
void dump() { print({}, 0); }
|
||||
|
||||
void setParent(Node *parent) {
|
||||
mParent = parent;
|
||||
}
|
||||
void setParent(Node *parent) { mParent = parent; }
|
||||
|
||||
Node *getParent() const {
|
||||
return mParent;
|
||||
}
|
||||
Node *getParent() const { return mParent; }
|
||||
|
||||
template<typename T> requires(std::is_base_of_v<Node, T>)
|
||||
auto getParent() const -> decltype(dynCast<T>(mParent)) {
|
||||
template <typename T>
|
||||
requires(std::is_base_of_v<Node, T>) auto getParent() const
|
||||
-> decltype(dynCast<T>(mParent)) {
|
||||
return dynCast<T>(mParent);
|
||||
}
|
||||
|
||||
Node *getNext() const {
|
||||
return mNext;
|
||||
}
|
||||
Node *getNext() const { return mNext; }
|
||||
|
||||
Node *getPrev() const {
|
||||
return mPrev;
|
||||
}
|
||||
Node *getPrev() const { return mPrev; }
|
||||
|
||||
friend class Block;
|
||||
};
|
||||
|
||||
template <typename T, typename ST>
|
||||
requires(std::is_base_of_v<Node, T> && std::is_base_of_v<Node, ST>) &&
|
||||
requires(ST *s) { dynamic_cast<T *>(s); }
|
||||
T *dynCast(ST *s) {
|
||||
return dynamic_cast<T *>(s);
|
||||
requires(std::is_base_of_v<Node, T> &&std::is_base_of_v<Node, ST>) &&
|
||||
requires(ST *s) {
|
||||
dynamic_cast<T *>(s);
|
||||
}
|
||||
T *dynCast(ST *s) { return dynamic_cast<T *>(s); }
|
||||
|
||||
template <typename T, typename ST>
|
||||
requires(std::is_base_of_v<Node, T> && std::is_base_of_v<Node, ST>) &&
|
||||
requires(const ST *s) { dynamic_cast<const T *>(s); }
|
||||
const T *dynCast(const ST *s) {
|
||||
return dynamic_cast<const T *>(s);
|
||||
requires(std::is_base_of_v<Node, T> &&std::is_base_of_v<Node, ST>) &&
|
||||
requires(const ST *s) {
|
||||
dynamic_cast<const T *>(s);
|
||||
}
|
||||
const T *dynCast(const ST *s) { return dynamic_cast<const T *>(s); }
|
||||
|
||||
inline bool isNodeEqual(const Node *lhs, const Node *rhs) {
|
||||
if (lhs == rhs) {
|
||||
|
|
@ -105,7 +94,6 @@ struct Return final : Node {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class Context;
|
||||
|
||||
class Block final : public Node {
|
||||
|
|
@ -124,25 +112,14 @@ public:
|
|||
std::printf("%s}\n", options.makeIdent(depth).c_str());
|
||||
}
|
||||
|
||||
bool isEmpty() const {
|
||||
return mBegin == nullptr;
|
||||
}
|
||||
bool isEmpty() const { return mBegin == nullptr; }
|
||||
|
||||
Node *getRootNode() const {
|
||||
return mBegin;
|
||||
}
|
||||
Node *getLastNode() const {
|
||||
return mEnd;
|
||||
}
|
||||
Node *getRootNode() const { return mBegin; }
|
||||
Node *getLastNode() const { return mEnd; }
|
||||
|
||||
void setUserData(void *data) {
|
||||
mUserData = data;
|
||||
}
|
||||
void* getUserData() const {
|
||||
return mUserData;
|
||||
}
|
||||
template<typename T>
|
||||
T* getUserData() const {
|
||||
void setUserData(void *data) { mUserData = data; }
|
||||
void *getUserData() const { return mUserData; }
|
||||
template <typename T> T *getUserData() const {
|
||||
return static_cast<T *>(mUserData);
|
||||
}
|
||||
|
||||
|
|
@ -239,9 +216,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
Block *getBlock() const {
|
||||
return dynCast<Block>(getParent());
|
||||
}
|
||||
Block *getBlock() const { return dynCast<Block>(getParent()); }
|
||||
|
||||
bool isEqual(const Node &other) const override {
|
||||
if (this == &other) {
|
||||
|
|
@ -320,9 +295,7 @@ struct Jump final : Node {
|
|||
struct Loop final : Node {
|
||||
Block *body;
|
||||
|
||||
Loop(Block *body) : body(body) {
|
||||
body->setParent(this);
|
||||
}
|
||||
Loop(Block *body) : body(body) { body->setParent(this); }
|
||||
|
||||
bool isEqual(const Node &other) const override {
|
||||
if (this == &other) {
|
||||
|
|
@ -358,8 +331,7 @@ class Context {
|
|||
|
||||
public:
|
||||
template <typename T, typename... ArgsT>
|
||||
requires(std::is_constructible_v<T, ArgsT...>)
|
||||
T *create(ArgsT &&...args) {
|
||||
requires(std::is_constructible_v<T, ArgsT...>) T *create(ArgsT &&...args) {
|
||||
auto result = new T(std::forward<ArgsT>(args)...);
|
||||
mNodes.push_front(std::unique_ptr<Node>{result});
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "CfBuilder.hpp"
|
||||
#include "Instruction.hpp"
|
||||
#include <cassert>
|
||||
#include <amdgpu/RemoteMemory.hpp>
|
||||
#include <cassert>
|
||||
#include <unordered_set>
|
||||
|
||||
using namespace amdgpu;
|
||||
|
|
@ -176,9 +176,8 @@ struct CfgBuilder {
|
|||
}
|
||||
};
|
||||
|
||||
cf::BasicBlock *amdgpu::shader::buildCf(cf::Context &ctxt,
|
||||
RemoteMemory memory,
|
||||
std::uint64_t entryPoint) {
|
||||
cf::BasicBlock *amdgpu::shader::buildCf(cf::Context &ctxt, RemoteMemory memory,
|
||||
std::uint64_t entryPoint) {
|
||||
CfgBuilder builder;
|
||||
builder.context = &ctxt;
|
||||
builder.memory = memory;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include "Instruction.hpp"
|
||||
#include "RegisterId.hpp"
|
||||
#include "RegisterState.hpp"
|
||||
#include "cf.hpp"
|
||||
#include "amdgpu/RemoteMemory.hpp"
|
||||
#include "cf.hpp"
|
||||
#include "scf.hpp"
|
||||
#include "util/unreachable.hpp"
|
||||
#include <compare>
|
||||
|
|
@ -108,8 +108,9 @@ private:
|
|||
instClass == InstructionClass::Vintrp ||
|
||||
instClass == InstructionClass::Exp ||
|
||||
instClass == InstructionClass::Vop1 ||
|
||||
instClass == InstructionClass::Vopc/* ||
|
||||
instClass == InstructionClass::Smrd*/;
|
||||
instClass == InstructionClass::Vopc /* ||
|
||||
instClass == InstructionClass::Smrd*/
|
||||
;
|
||||
}
|
||||
|
||||
spirv::BoolValue createExecTest(Fragment *fragment) {
|
||||
|
|
@ -274,10 +275,11 @@ private:
|
|||
};
|
||||
}; // namespace amdgpu::shader
|
||||
|
||||
amdgpu::shader::Shader amdgpu::shader::convert(
|
||||
RemoteMemory memory, Stage stage, std::uint64_t entry,
|
||||
std::span<const std::uint32_t> userSpgrs, int bindingOffset,
|
||||
std::uint32_t dimX, std::uint32_t dimY, std::uint32_t dimZ) {
|
||||
amdgpu::shader::Shader
|
||||
amdgpu::shader::convert(RemoteMemory memory, Stage stage, std::uint64_t entry,
|
||||
std::span<const std::uint32_t> userSpgrs,
|
||||
int bindingOffset, std::uint32_t dimX,
|
||||
std::uint32_t dimY, std::uint32_t dimZ) {
|
||||
ConverterContext ctxt(memory, stage);
|
||||
auto &builder = ctxt.getBuilder();
|
||||
builder.createCapability(spv::Capability::Shader);
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ UniformInfo *ConverterContext::createStorageBuffer(TypeId type) {
|
|||
newUniform.variable = uniformVariable;
|
||||
newUniform.isBuffer = true;
|
||||
std::printf("new storage buffer %u of type %u\n", newUniform.index,
|
||||
newUniform.typeId.raw);
|
||||
newUniform.typeId.raw);
|
||||
return &newUniform;
|
||||
}
|
||||
|
||||
|
|
@ -397,11 +397,11 @@ spirv::VariableValue ConverterContext::getFragCoord() {
|
|||
}
|
||||
|
||||
auto inputType = getPointerType(spv::StorageClass::Input, TypeId::Float32x4);
|
||||
mFragCoord =
|
||||
mBuilder.createVariable(inputType, spv::StorageClass::Input);
|
||||
mFragCoord = mBuilder.createVariable(inputType, spv::StorageClass::Input);
|
||||
|
||||
mBuilder.createDecorate(mFragCoord, spv::Decoration::BuiltIn,
|
||||
{{static_cast<std::uint32_t>(spv::BuiltIn::FragCoord)}});
|
||||
mBuilder.createDecorate(
|
||||
mFragCoord, spv::Decoration::BuiltIn,
|
||||
{{static_cast<std::uint32_t>(spv::BuiltIn::FragCoord)}});
|
||||
|
||||
mInterfaces.push_back(mFragCoord);
|
||||
return mFragCoord;
|
||||
|
|
|
|||
|
|
@ -3288,7 +3288,8 @@ void convertMimg(Fragment &fragment, Mimg inst) {
|
|||
fragment.registers->pc += Mimg::kMinInstSize * sizeof(std::uint32_t);
|
||||
switch (inst.op) {
|
||||
case Mimg::Op::IMAGE_GET_RESINFO: {
|
||||
auto image = fragment.createImage(RegisterId::Raw(inst.srsrc << 2), inst.r128);
|
||||
auto image =
|
||||
fragment.createImage(RegisterId::Raw(inst.srsrc << 2), inst.r128);
|
||||
spirv::Value values[4];
|
||||
auto uint32T = fragment.context->getUInt32Type();
|
||||
|
||||
|
|
@ -3314,13 +3315,15 @@ void convertMimg(Fragment &fragment, Mimg inst) {
|
|||
|
||||
for (std::size_t dstOffset = 0, i = 0; i < 4; ++i) {
|
||||
if (inst.dmask & (1 << i)) {
|
||||
fragment.setVectorOperand(inst.vdata + dstOffset++, {uint32T, values[i]});
|
||||
fragment.setVectorOperand(inst.vdata + dstOffset++,
|
||||
{uint32T, values[i]});
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Mimg::Op::IMAGE_SAMPLE: {
|
||||
auto image = fragment.createImage(RegisterId::Raw(inst.srsrc << 2), inst.r128);
|
||||
auto image =
|
||||
fragment.createImage(RegisterId::Raw(inst.srsrc << 2), inst.r128);
|
||||
auto sampler = fragment.createSampler(RegisterId::Raw(inst.ssamp << 2));
|
||||
auto coord0 = fragment.getVectorOperand(inst.vaddr, TypeId::Float32).value;
|
||||
auto coord1 =
|
||||
|
|
@ -3342,8 +3345,9 @@ void convertMimg(Fragment &fragment, Mimg inst) {
|
|||
for (std::uint32_t dstOffset = 0, i = 0; i < 4; ++i) {
|
||||
if (inst.dmask & (1 << i)) {
|
||||
fragment.setVectorOperand(
|
||||
inst.vdata + dstOffset++, {floatT, fragment.builder.createCompositeExtract(
|
||||
floatT, value, {{i}})});
|
||||
inst.vdata + dstOffset++,
|
||||
{floatT,
|
||||
fragment.builder.createCompositeExtract(floatT, value, {{i}})});
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -3353,8 +3357,8 @@ void convertMimg(Fragment &fragment, Mimg inst) {
|
|||
auto intT = fragment.context->getUInt32Type();
|
||||
for (std::uint32_t dstOffset = 0, i = 0; i < 4; ++i) {
|
||||
if (inst.dmask & (1 << i)) {
|
||||
fragment.setVectorOperand(
|
||||
inst.vdata + dstOffset++, {intT, fragment.context->getUInt32(0)});
|
||||
fragment.setVectorOperand(inst.vdata + dstOffset++,
|
||||
{intT, fragment.context->getUInt32(0)});
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -3457,19 +3461,19 @@ void convertExp(Fragment &fragment, Exp inst) {
|
|||
|
||||
auto resultType = fragment.context->getFloat32x4Type();
|
||||
auto floatType = fragment.context->getFloat32Type();
|
||||
/*
|
||||
if (inst.en != 0xf) {
|
||||
auto prevValue = fragment.getExportTarget(inst.target, TypeId::Float32x4);
|
||||
if (prevValue) {
|
||||
for (std::uint32_t i = 0; i < 4; ++i) {
|
||||
if (~inst.en & (1 << i)) {
|
||||
exports[i] = fragment.builder.createCompositeExtract(
|
||||
floatType, prevValue.value, {{i}});
|
||||
/*
|
||||
if (inst.en != 0xf) {
|
||||
auto prevValue = fragment.getExportTarget(inst.target, TypeId::Float32x4);
|
||||
if (prevValue) {
|
||||
for (std::uint32_t i = 0; i < 4; ++i) {
|
||||
if (~inst.en & (1 << i)) {
|
||||
exports[i] = fragment.builder.createCompositeExtract(
|
||||
floatType, prevValue.value, {{i}});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
auto value = fragment.builder.createCompositeConstruct(resultType, exports);
|
||||
fragment.setExportTarget(inst.target, {resultType, value});
|
||||
|
|
@ -3535,7 +3539,6 @@ void convertVop1(Fragment &fragment, Vop1 inst) {
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
case Vop1::Op::V_FRACT_F32: {
|
||||
auto src = spirv::cast<spirv::FloatValue>(
|
||||
fragment.getScalarOperand(inst.src0, TypeId::Float32).value);
|
||||
|
|
@ -5412,8 +5415,7 @@ Value amdgpu::shader::Fragment::getRegister(RegisterId id) {
|
|||
return result;
|
||||
}
|
||||
|
||||
Value amdgpu::shader::Fragment::getRegister(RegisterId id,
|
||||
spirv::Type type) {
|
||||
Value amdgpu::shader::Fragment::getRegister(RegisterId id, spirv::Type type) {
|
||||
auto result = getRegister(id);
|
||||
|
||||
if (!result) {
|
||||
|
|
|
|||
|
|
@ -268,7 +268,8 @@ void Function::insertReturn() {
|
|||
exitFragment.builder.createStore(valuePointer, value.value);
|
||||
}
|
||||
|
||||
auto resultValue = exitFragment.builder.createLoad(resultType, resultVariable);
|
||||
auto resultValue =
|
||||
exitFragment.builder.createLoad(resultType, resultVariable);
|
||||
|
||||
exitFragment.builder.createReturnValue(resultValue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3013,8 +3013,8 @@ void amdgpu::shader::Mtbuf::dump() const {
|
|||
printScalarOperand(soffset, inst + instSize);
|
||||
printf(" #offset=%x,offen=%x,idxen=%x,glc=%x,op=%x,dfmt=%x,nfmt=%x,vaddr=%x,"
|
||||
"vdata=%x,srsrc=%x,slc=%x,tfe=%x,soffset=%x",
|
||||
offset, offen, idxen, glc, (unsigned)op, dfmt, nfmt, vaddr, vdata, srsrc, slc,
|
||||
tfe, soffset);
|
||||
offset, offen, idxen, glc, (unsigned)op, dfmt, nfmt, vaddr, vdata,
|
||||
srsrc, slc, tfe, soffset);
|
||||
}
|
||||
void amdgpu::shader::Mimg::dump() const {
|
||||
int instSize = kMinInstSize;
|
||||
|
|
|
|||
|
|
@ -39,20 +39,35 @@ amdgpu::shader::RegisterState::getRegister(RegisterId regId) {
|
|||
util::unreachable();
|
||||
}
|
||||
|
||||
void amdgpu::shader::RegisterState::setRegister(RegisterId regId,
|
||||
Value value) {
|
||||
void amdgpu::shader::RegisterState::setRegister(RegisterId regId, Value value) {
|
||||
auto offset = regId.getOffset();
|
||||
|
||||
if (regId.isScalar()) {
|
||||
switch (offset) {
|
||||
case 0 ... 103: sgprs[offset] = value; return;
|
||||
case 106: vccLo = value; return;
|
||||
case 107: vccHi = value; return;
|
||||
case 124: m0 = value; return;
|
||||
case 126: execLo = value; return;
|
||||
case 127: execHi = value; return;
|
||||
case 253: scc = value; return;
|
||||
case 254: ldsDirect = value; return;
|
||||
case 0 ... 103:
|
||||
sgprs[offset] = value;
|
||||
return;
|
||||
case 106:
|
||||
vccLo = value;
|
||||
return;
|
||||
case 107:
|
||||
vccHi = value;
|
||||
return;
|
||||
case 124:
|
||||
m0 = value;
|
||||
return;
|
||||
case 126:
|
||||
execLo = value;
|
||||
return;
|
||||
case 127:
|
||||
execHi = value;
|
||||
return;
|
||||
case 253:
|
||||
scc = value;
|
||||
return;
|
||||
case 254:
|
||||
ldsDirect = value;
|
||||
return;
|
||||
}
|
||||
|
||||
util::unreachable();
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ std::size_t amdgpu::shader::TypeId::getElementsCount() const {
|
|||
case TypeId::Float32:
|
||||
case TypeId::Float64:
|
||||
return 1;
|
||||
|
||||
|
||||
case TypeId::UInt32x2:
|
||||
return 2;
|
||||
case TypeId::UInt32x3:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
void scf::Block::eraseFrom(Node *endBefore) {
|
||||
mEnd = endBefore->getPrev();
|
||||
if (mEnd != nullptr) {
|
||||
if (mEnd != nullptr) {
|
||||
mEnd->mNext = nullptr;
|
||||
} else {
|
||||
mBegin = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue