mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-20 02:14:56 +00:00
* shader_recompiler: Tessellation WIP * fix compiler errors after merge DONT MERGE set log file to /dev/null DONT MERGE linux pthread bb fix save work DONT MERGE dump ir save more work fix mistake with ES shader skip list add input patch control points dynamic state random stuff * WIP Tessellation partial implementation. Squash commits * test: make local/tcs use attr arrays * attr arrays in TCS/TES * dont define empty attr arrays * switch to special opcodes for tess tcs/tes reads and tcs writes * impl tcs/tes read attr insts * rebase fix * save some work * save work probably broken and slow * put Vertex LogicalStage after TCS and TES to fix bindings * more refactors * refactor pattern matching and optimize modulos (disabled) * enable modulo opt * copyright * rebase fixes * remove some prints * remove some stuff * Add TCS/TES support for shader patching and use LogicalStage * refactor and handle wider DS instructions * get rid of GetAttributes for special tess constants reads. Immediately replace some upon seeing readconstbuffer. Gets rid of some extra passes over IR * stop relying on GNMX HsConstants struct. Change runtime_info.hs_info and some regs * delete some more stuff * update comments for current implementation * some cleanup * uint error * more cleanup * remove patch control points dynamic state (because runtime_info already depends on it) * fix potential problem with determining passthrough --------- Co-authored-by: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com>
129 lines
3.4 KiB
C++
129 lines
3.4 KiB
C++
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <fmt/format.h>
|
|
#include "common/assert.h"
|
|
#include "common/types.h"
|
|
|
|
namespace Shader::IR {
|
|
|
|
enum class Attribute : u64 {
|
|
// Export targets
|
|
RenderTarget0 = 0,
|
|
RenderTarget1 = 1,
|
|
RenderTarget2 = 2,
|
|
RenderTarget3 = 3,
|
|
RenderTarget4 = 4,
|
|
RenderTarget5 = 5,
|
|
RenderTarget6 = 6,
|
|
RenderTarget7 = 7,
|
|
Depth = 8,
|
|
Null = 9,
|
|
Position0 = 12,
|
|
Position1 = 13,
|
|
Position2 = 14,
|
|
Position3 = 15,
|
|
Param0 = 32,
|
|
Param1 = 33,
|
|
Param2 = 34,
|
|
Param3 = 35,
|
|
Param4 = 36,
|
|
Param5 = 37,
|
|
Param6 = 38,
|
|
Param7 = 39,
|
|
Param8 = 40,
|
|
Param9 = 41,
|
|
Param10 = 42,
|
|
Param11 = 43,
|
|
Param12 = 44,
|
|
Param13 = 45,
|
|
Param14 = 46,
|
|
Param15 = 47,
|
|
Param16 = 48,
|
|
Param17 = 49,
|
|
Param18 = 50,
|
|
Param19 = 51,
|
|
Param20 = 52,
|
|
Param21 = 53,
|
|
Param22 = 54,
|
|
Param23 = 55,
|
|
Param24 = 56,
|
|
Param25 = 57,
|
|
Param26 = 58,
|
|
Param27 = 59,
|
|
Param28 = 60,
|
|
Param29 = 61,
|
|
Param30 = 62,
|
|
Param31 = 63,
|
|
// System values
|
|
ClipDistance = 64,
|
|
CullDistance = 65,
|
|
RenderTargetId = 66,
|
|
ViewportId = 67,
|
|
VertexId = 68,
|
|
PrimitiveId = 69,
|
|
InstanceId = 70,
|
|
IsFrontFace = 71,
|
|
SampleIndex = 72,
|
|
GlobalInvocationId = 73,
|
|
WorkgroupId = 74,
|
|
LocalInvocationId = 75,
|
|
LocalInvocationIndex = 76,
|
|
FragCoord = 77,
|
|
InstanceId0 = 78, // step rate 0
|
|
InstanceId1 = 79, // step rate 1
|
|
InvocationId = 80, // TCS id in output patch and instanced geometry shader id
|
|
PatchVertices = 81,
|
|
TessellationEvaluationPointU = 82,
|
|
TessellationEvaluationPointV = 83,
|
|
PackedHullInvocationInfo = 84, // contains patch id within the VGT and invocation ID
|
|
Max,
|
|
};
|
|
|
|
constexpr size_t NumAttributes = static_cast<size_t>(Attribute::Max);
|
|
constexpr size_t NumRenderTargets = 8;
|
|
constexpr size_t NumParams = 32;
|
|
|
|
constexpr bool IsPosition(Attribute attribute) noexcept {
|
|
return attribute >= Attribute::Position0 && attribute <= Attribute::Position3;
|
|
}
|
|
|
|
constexpr bool IsTessCoord(Attribute attribute) noexcept {
|
|
return attribute >= Attribute::TessellationEvaluationPointU &&
|
|
attribute <= Attribute::TessellationEvaluationPointV;
|
|
}
|
|
|
|
constexpr bool IsParam(Attribute attribute) noexcept {
|
|
return attribute >= Attribute::Param0 && attribute <= Attribute::Param31;
|
|
}
|
|
|
|
constexpr bool IsMrt(Attribute attribute) noexcept {
|
|
return attribute >= Attribute::RenderTarget0 && attribute <= Attribute::RenderTarget7;
|
|
}
|
|
|
|
[[nodiscard]] std::string NameOf(Attribute attribute);
|
|
|
|
[[nodiscard]] constexpr Attribute operator+(Attribute attr, int num) {
|
|
const int result{static_cast<int>(attr) + num};
|
|
if (result > static_cast<int>(Attribute::Param31)) {
|
|
UNREACHABLE_MSG("Overflow on register arithmetic");
|
|
}
|
|
if (result < static_cast<int>(Attribute::RenderTarget0)) {
|
|
UNREACHABLE_MSG("Underflow on register arithmetic");
|
|
}
|
|
return static_cast<Attribute>(result);
|
|
}
|
|
|
|
} // namespace Shader::IR
|
|
|
|
template <>
|
|
struct fmt::formatter<Shader::IR::Attribute> {
|
|
constexpr auto parse(format_parse_context& ctx) {
|
|
return ctx.begin();
|
|
}
|
|
auto format(const Shader::IR::Attribute attribute, format_context& ctx) const {
|
|
return fmt::format_to(ctx.out(), "{}", Shader::IR::NameOf(attribute));
|
|
}
|
|
};
|