1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-29 19:24:10 +01:00

[dxbc] Added interpolation mode decoder

This commit is contained in:
Philip Rebohle 2017-12-08 13:24:08 +01:00
parent e3533fb634
commit 0843349d72
10 changed files with 95 additions and 46 deletions

View File

@ -96,9 +96,18 @@ namespace dxvk {
if (hasSv)
sv = ins.readEnum<DxbcSystemValue>(op.length());
const bool hasInterpolationMode =
opcode == DxbcOpcode::DclInputPs
|| opcode == DxbcOpcode::DclInputPsSiv;
DxbcInterpolationMode im = DxbcInterpolationMode::Undefined;
if (hasInterpolationMode)
im = op.token().interpolationMode();
m_gen->dclInterfaceVar(
op.token().type(), regId, regDim,
op.token().componentMask(), sv);
op.token().componentMask(), sv, im);
} break;
default:

View File

@ -287,6 +287,17 @@ namespace dxvk {
return DxbcComponentMask(bit::extract(m_token, 4, 5));
}
/**
* \brief Interpolatin mode
*
* Used by input declarations in pixel shaders.
* Undefined for all other instructions.
*/
DxbcInterpolationMode interpolationMode() const {
return static_cast<DxbcInterpolationMode>(
bit::extract(m_token, 11, 14));
}
/**
* \brief Operand type
*

View File

@ -415,6 +415,18 @@ namespace dxvk {
};
enum class DxbcInterpolationMode : uint32_t {
Undefined = 0,
Constant = 1,
Linear = 2,
LinearCentroid = 3,
LinearNoPerspective = 4,
LinearNoperspectiveCentroid = 5,
LinearSample = 6,
LinearNoPerspectiveSample = 7,
};
enum class DxbcGlobalFlag : uint32_t {
RefactoringAllowed = 0,
DoublePrecision = 1,

View File

@ -95,11 +95,12 @@ namespace dxvk {
DxbcComponentMask mask);
virtual void dclInterfaceVar(
DxbcOperandType regType,
uint32_t regId,
uint32_t regDim,
DxbcComponentMask regMask,
DxbcSystemValue sv) = 0;
DxbcOperandType regType,
uint32_t regId,
uint32_t regDim,
DxbcComponentMask regMask,
DxbcSystemValue sv,
DxbcInterpolationMode im) = 0;
virtual DxbcPointer ptrInterfaceVar(
DxbcOperandType regType,

View File

@ -56,11 +56,12 @@ namespace dxvk {
void DxbcPsCodeGen::dclInterfaceVar(
DxbcOperandType regType,
uint32_t regId,
uint32_t regDim,
DxbcComponentMask regMask,
DxbcSystemValue sv) {
DxbcOperandType regType,
uint32_t regId,
uint32_t regDim,
DxbcComponentMask regMask,
DxbcSystemValue sv,
DxbcInterpolationMode im) {
switch (regType) {
case DxbcOperandType::Input: {
if (m_vRegs.at(regId).valueId == 0) {
@ -91,8 +92,8 @@ namespace dxvk {
DxbcPointer DxbcPsCodeGen::ptrInterfaceVar(
DxbcOperandType regType,
uint32_t regId) {
DxbcOperandType regType,
uint32_t regId) {
switch (regType) {
case DxbcOperandType::Input:
return m_vRegs.at(regId);
@ -109,9 +110,9 @@ namespace dxvk {
DxbcPointer DxbcPsCodeGen::ptrInterfaceVarIndexed(
DxbcOperandType regType,
uint32_t regId,
const DxbcValue& index) {
DxbcOperandType regType,
uint32_t regId,
const DxbcValue& index) {
throw DxvkError(str::format(
"DxbcPsCodeGen::ptrInterfaceVarIndexed:\n",
"Pixel shaders do not support indexed interface variables"));
@ -140,6 +141,7 @@ namespace dxvk {
spv::ExecutionModelFragment, "main",
m_entryPointInterfaces.size(),
m_entryPointInterfaces.data());
m_module.setOriginUpperLeft(m_entryPointId);
m_module.setDebugName(m_entryPointId, "main");
return m_module.compile();

View File

@ -16,20 +16,21 @@ namespace dxvk {
~DxbcPsCodeGen();
void dclInterfaceVar(
DxbcOperandType regType,
uint32_t regId,
uint32_t regDim,
DxbcComponentMask regMask,
DxbcSystemValue sv);
DxbcOperandType regType,
uint32_t regId,
uint32_t regDim,
DxbcComponentMask regMask,
DxbcSystemValue sv,
DxbcInterpolationMode im);
DxbcPointer ptrInterfaceVar(
DxbcOperandType regType,
uint32_t regId);
DxbcOperandType regType,
uint32_t regId);
DxbcPointer ptrInterfaceVarIndexed(
DxbcOperandType regType,
uint32_t regId,
const DxbcValue& index);
DxbcOperandType regType,
uint32_t regId,
const DxbcValue& index);
SpirvCodeBuffer finalize() final;

View File

@ -62,11 +62,12 @@ namespace dxvk {
void DxbcVsCodeGen::dclInterfaceVar(
DxbcOperandType regType,
uint32_t regId,
uint32_t regDim,
DxbcComponentMask regMask,
DxbcSystemValue sv) {
DxbcOperandType regType,
uint32_t regId,
uint32_t regDim,
DxbcComponentMask regMask,
DxbcSystemValue sv,
DxbcInterpolationMode im) {
switch (regType) {
case DxbcOperandType::Input: {
if (m_vRegs.at(regId).valueId == 0) {
@ -107,8 +108,8 @@ namespace dxvk {
DxbcPointer DxbcVsCodeGen::ptrInterfaceVar(
DxbcOperandType regType,
uint32_t regId) {
DxbcOperandType regType,
uint32_t regId) {
switch (regType) {
case DxbcOperandType::Input:
return m_vRegs.at(regId);
@ -125,9 +126,9 @@ namespace dxvk {
DxbcPointer DxbcVsCodeGen::ptrInterfaceVarIndexed(
DxbcOperandType regType,
uint32_t regId,
const DxbcValue& index) {
DxbcOperandType regType,
uint32_t regId,
const DxbcValue& index) {
throw DxvkError(str::format(
"DxbcVsCodeGen::ptrInterfaceVarIndexed:\n",
"Vertex shaders do not support indexed interface variables"));

View File

@ -16,20 +16,21 @@ namespace dxvk {
~DxbcVsCodeGen();
void dclInterfaceVar(
DxbcOperandType regType,
uint32_t regId,
uint32_t regDim,
DxbcComponentMask regMask,
DxbcSystemValue sv);
DxbcOperandType regType,
uint32_t regId,
uint32_t regDim,
DxbcComponentMask regMask,
DxbcSystemValue sv,
DxbcInterpolationMode im);
DxbcPointer ptrInterfaceVar(
DxbcOperandType regType,
uint32_t regId);
DxbcOperandType regType,
uint32_t regId);
DxbcPointer ptrInterfaceVarIndexed(
DxbcOperandType regType,
uint32_t regId,
const DxbcValue& index);
DxbcOperandType regType,
uint32_t regId,
const DxbcValue& index);
SpirvCodeBuffer finalize() final;

View File

@ -95,6 +95,14 @@ namespace dxvk {
}
void SpirvModule::setOriginUpperLeft(
uint32_t entryPointId) {
m_execModeInfo.putIns (spv::OpExecutionMode, 3);
m_execModeInfo.putWord(entryPointId);
m_execModeInfo.putWord(spv::ExecutionModeOriginUpperLeft);
}
void SpirvModule::setDebugName(
uint32_t expressionId,
const char* debugName) {

View File

@ -46,6 +46,9 @@ namespace dxvk {
uint32_t y,
uint32_t z);
void setOriginUpperLeft(
uint32_t entryPointId);
void setDebugName(
uint32_t expressionId,
const char* debugName);