mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-01-04 15:50:10 +01:00
gpu: implement mrtz exp target
This commit is contained in:
parent
f79e16eb4d
commit
43afb19855
|
|
@ -17,6 +17,7 @@ struct Context : ir::Context {
|
|||
ir::Value perVertex;
|
||||
std::map<int, ir::Value> outputs;
|
||||
std::map<int, ir::Value> inputs;
|
||||
ir::Value fragDepth;
|
||||
|
||||
ir::RegionLike localVariables;
|
||||
ir::RegionLike epilogue;
|
||||
|
|
@ -151,5 +152,7 @@ struct Context : ir::Context {
|
|||
ir::Value createOutput(ir::Location loc, int index);
|
||||
ir::Value createInput(ir::Location loc, int index);
|
||||
ir::Value createAttr(ir::Location loc, int attrId, bool perVertex, bool flat);
|
||||
|
||||
ir::Value createFragDepth(ir::Location loc);
|
||||
};
|
||||
} // namespace shader::spv
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "rx/die.hpp"
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <print>
|
||||
|
||||
using namespace shader;
|
||||
|
||||
|
|
@ -651,9 +652,9 @@ static void expToSpv(GcnConverter &converter, gcn::Stage stage,
|
|||
continue;
|
||||
}
|
||||
|
||||
auto src =
|
||||
builder.createSpvBitcast(loc, context.getTypeFloat32(),
|
||||
inst.getOperand(operandIndex++).getAsValue());
|
||||
auto src = builder.createSpvBitcast(
|
||||
loc, context.getTypeFloat32(),
|
||||
inst.getOperand(operandIndex++).getAsValue());
|
||||
|
||||
auto srcType = src.getOperand(0).getAsValue();
|
||||
ir::Value elementType;
|
||||
|
|
@ -786,6 +787,26 @@ static void expToSpv(GcnConverter &converter, gcn::Stage stage,
|
|||
return;
|
||||
}
|
||||
|
||||
if (target == ET_MRTZ) {
|
||||
auto output = context.createFragDepth(loc);
|
||||
auto channelType = context.getTypeFloat32();
|
||||
|
||||
for (int channel = 0; channel < 4; ++channel) {
|
||||
if (~swizzle & (1 << channel)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto channelValue =
|
||||
builder.createSpvCompositeExtract(loc, elemType, value, {{channel}});
|
||||
channelValue =
|
||||
context.createCast(loc, builder, channelType, channelValue);
|
||||
builder.createSpvStore(loc, output, channelValue);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (target >= ET_PARAM0 && target <= ET_PARAM31) {
|
||||
auto output = context.createOutput(loc, target - ET_PARAM0);
|
||||
auto floatT = context.getTypeFloat32();
|
||||
|
|
@ -849,8 +870,8 @@ static void expToSpv(GcnConverter &converter, gcn::Stage stage,
|
|||
return result;
|
||||
};
|
||||
|
||||
std::printf("exp target %s.%s\n", targetToString(target).c_str(),
|
||||
swizzleToString(swizzle).c_str());
|
||||
std::println(stderr, "exp target {}.{}", targetToString(target),
|
||||
swizzleToString(swizzle));
|
||||
std::abort();
|
||||
}
|
||||
|
||||
|
|
@ -1454,6 +1475,8 @@ static void createEntryPoint(gcn::Context &context, const gcn::Environment &env,
|
|||
executionModes.createSpvExecutionMode(
|
||||
mainFn.getLocation(), mainFn,
|
||||
ir::spv::ExecutionMode::OriginUpperLeft());
|
||||
executionModes.createSpvExecutionMode(
|
||||
mainFn.getLocation(), mainFn, ir::spv::ExecutionMode::DepthReplacing());
|
||||
}
|
||||
|
||||
if (executionModel == ir::spv::ExecutionModel::GLCompute) {
|
||||
|
|
|
|||
|
|
@ -571,8 +571,8 @@ ir::Value spv::Context::createOutput(ir::Location loc, int index) {
|
|||
auto annotations =
|
||||
Builder::createAppend(*this, layout.getOrCreateAnnotations(*this));
|
||||
|
||||
auto variable = globals.createSpvVariable(loc, variableType,
|
||||
ir::spv::StorageClass::Output, nullValue);
|
||||
auto variable = globals.createSpvVariable(
|
||||
loc, variableType, ir::spv::StorageClass::Output, nullValue);
|
||||
|
||||
annotations.createSpvDecorate(loc, variable,
|
||||
ir::spv::Decoration::Location(index));
|
||||
|
|
@ -647,3 +647,30 @@ ir::Value spv::Context::createAttr(ir::Location loc, int attrId, bool perVertex,
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
ir::Value spv::Context::createFragDepth(ir::Location loc) {
|
||||
if (fragDepth == nullptr) {
|
||||
auto floatType = getTypeFloat32();
|
||||
auto nullValue = getNull(floatType);
|
||||
|
||||
auto variableType =
|
||||
getTypePointer(ir::spv::StorageClass::Output, floatType);
|
||||
|
||||
auto globals =
|
||||
Builder::createAppend(*this, layout.getOrCreateGlobals(*this));
|
||||
auto annotations =
|
||||
Builder::createAppend(*this, layout.getOrCreateAnnotations(*this));
|
||||
|
||||
auto variable = globals.createSpvVariable(
|
||||
loc, variableType, ir::spv::StorageClass::Output, nullValue);
|
||||
|
||||
annotations.createSpvDecorate(
|
||||
loc, variable,
|
||||
ir::spv::Decoration::BuiltIn(ir::spv::BuiltIn::FragDepth));
|
||||
|
||||
setName(variable, "fragDepth");
|
||||
fragDepth = variable;
|
||||
}
|
||||
|
||||
return fragDepth;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue