mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 10:54:16 +01:00
[dxbc] Implemented derivatives
This commit is contained in:
parent
342e99a11c
commit
d1720c0c52
@ -74,6 +74,9 @@ namespace dxvk {
|
|||||||
case DxbcInstClass::VectorCmp:
|
case DxbcInstClass::VectorCmp:
|
||||||
return this->emitVectorCmp(ins);
|
return this->emitVectorCmp(ins);
|
||||||
|
|
||||||
|
case DxbcInstClass::VectorDeriv:
|
||||||
|
return this->emitVectorDeriv(ins);
|
||||||
|
|
||||||
case DxbcInstClass::VectorDot:
|
case DxbcInstClass::VectorDot:
|
||||||
return this->emitVectorDot(ins);
|
return this->emitVectorDot(ins);
|
||||||
|
|
||||||
@ -981,6 +984,50 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxbcCompiler::emitVectorDeriv(const DxbcShaderInstruction& ins) {
|
||||||
|
// Derivative instructions have two operands:
|
||||||
|
// (dst0) Destination register for the derivative
|
||||||
|
// (src0) The operand to compute the derivative of
|
||||||
|
DxbcRegisterValue value = emitRegisterLoad(ins.src[0], ins.dst[0].mask);
|
||||||
|
const uint32_t typeId = getVectorTypeId(value.type);
|
||||||
|
|
||||||
|
switch (ins.op) {
|
||||||
|
case DxbcOpcode::DerivRtx:
|
||||||
|
value.id = m_module.opDpdx(typeId, value.id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DxbcOpcode::DerivRty:
|
||||||
|
value.id = m_module.opDpdy(typeId, value.id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DxbcOpcode::DerivRtxCoarse:
|
||||||
|
value.id = m_module.opDpdxCoarse(typeId, value.id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DxbcOpcode::DerivRtyCoarse:
|
||||||
|
value.id = m_module.opDpdyCoarse(typeId, value.id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DxbcOpcode::DerivRtxFine:
|
||||||
|
value.id = m_module.opDpdxFine(typeId, value.id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DxbcOpcode::DerivRtyFine:
|
||||||
|
value.id = m_module.opDpdyFine(typeId, value.id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Logger::warn(str::format(
|
||||||
|
"DxbcCompiler: Unhandled instruction: ",
|
||||||
|
ins.op));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = emitDstOperandModifiers(value, ins.modifiers);
|
||||||
|
emitRegisterStore(ins.dst[0], value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxbcCompiler::emitVectorDot(const DxbcShaderInstruction& ins) {
|
void DxbcCompiler::emitVectorDot(const DxbcShaderInstruction& ins) {
|
||||||
const DxbcRegMask srcMask(true,
|
const DxbcRegMask srcMask(true,
|
||||||
ins.op >= DxbcOpcode::Dp2,
|
ins.op >= DxbcOpcode::Dp2,
|
||||||
|
@ -305,6 +305,9 @@ namespace dxvk {
|
|||||||
void emitVectorCmp(
|
void emitVectorCmp(
|
||||||
const DxbcShaderInstruction& ins);
|
const DxbcShaderInstruction& ins);
|
||||||
|
|
||||||
|
void emitVectorDeriv(
|
||||||
|
const DxbcShaderInstruction& ins);
|
||||||
|
|
||||||
void emitVectorDot(
|
void emitVectorDot(
|
||||||
const DxbcShaderInstruction& ins);
|
const DxbcShaderInstruction& ins);
|
||||||
|
|
||||||
|
@ -42,9 +42,15 @@ namespace dxvk {
|
|||||||
/* Default */
|
/* Default */
|
||||||
{ },
|
{ },
|
||||||
/* DerivRtx */
|
/* DerivRtx */
|
||||||
{ },
|
{ 2, DxbcInstClass::VectorDeriv, {
|
||||||
|
{ DxbcOperandKind::DstReg, DxbcScalarType::Float32 },
|
||||||
|
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
|
||||||
|
} },
|
||||||
/* DerivRty */
|
/* DerivRty */
|
||||||
{ },
|
{ 2, DxbcInstClass::VectorDeriv, {
|
||||||
|
{ DxbcOperandKind::DstReg, DxbcScalarType::Float32 },
|
||||||
|
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
|
||||||
|
} },
|
||||||
/* Discard */
|
/* Discard */
|
||||||
{ 1, DxbcInstClass::ControlFlow, {
|
{ 1, DxbcInstClass::ControlFlow, {
|
||||||
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
|
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
|
||||||
@ -457,13 +463,25 @@ namespace dxvk {
|
|||||||
/* BufInfo */
|
/* BufInfo */
|
||||||
{ },
|
{ },
|
||||||
/* DerivRtxCoarse */
|
/* DerivRtxCoarse */
|
||||||
{ },
|
{ 2, DxbcInstClass::VectorDeriv, {
|
||||||
|
{ DxbcOperandKind::DstReg, DxbcScalarType::Float32 },
|
||||||
|
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
|
||||||
|
} },
|
||||||
/* DerivRtxFine */
|
/* DerivRtxFine */
|
||||||
{ },
|
{ 2, DxbcInstClass::VectorDeriv, {
|
||||||
|
{ DxbcOperandKind::DstReg, DxbcScalarType::Float32 },
|
||||||
|
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
|
||||||
|
} },
|
||||||
/* DerivRtyCoarse */
|
/* DerivRtyCoarse */
|
||||||
{ },
|
{ 2, DxbcInstClass::VectorDeriv, {
|
||||||
|
{ DxbcOperandKind::DstReg, DxbcScalarType::Float32 },
|
||||||
|
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
|
||||||
|
} },
|
||||||
/* DerivRtyFine */
|
/* DerivRtyFine */
|
||||||
{ },
|
{ 2, DxbcInstClass::VectorDeriv, {
|
||||||
|
{ DxbcOperandKind::DstReg, DxbcScalarType::Float32 },
|
||||||
|
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
|
||||||
|
} },
|
||||||
/* Gather4C */
|
/* Gather4C */
|
||||||
{ },
|
{ },
|
||||||
/* Gather4Po */
|
/* Gather4Po */
|
||||||
|
@ -36,6 +36,7 @@ namespace dxvk {
|
|||||||
VectorAlu, ///< Component-wise vector instructions
|
VectorAlu, ///< Component-wise vector instructions
|
||||||
VectorCmov, ///< Component-wise conditional move
|
VectorCmov, ///< Component-wise conditional move
|
||||||
VectorCmp, ///< Component-wise vector comparison
|
VectorCmp, ///< Component-wise vector comparison
|
||||||
|
VectorDeriv, ///< Vector derivatives
|
||||||
VectorDot, ///< Dot product instruction
|
VectorDot, ///< Dot product instruction
|
||||||
VectorIdiv, ///< Component-wise integer division
|
VectorIdiv, ///< Component-wise integer division
|
||||||
VectorImul, ///< Component-wise integer multiplication
|
VectorImul, ///< Component-wise integer multiplication
|
||||||
|
@ -59,12 +59,14 @@ namespace dxvk {
|
|||||||
m_memory(memory),
|
m_memory(memory),
|
||||||
m_mapPtr(mapPtr),
|
m_mapPtr(mapPtr),
|
||||||
m_size (size) {
|
m_size (size) {
|
||||||
|
TRACE(this, heap, size);
|
||||||
// Mark the entire chunk as free
|
// Mark the entire chunk as free
|
||||||
m_freeList.push_back(FreeSlice { 0, size });
|
m_freeList.push_back(FreeSlice { 0, size });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkMemoryChunk::~DxvkMemoryChunk() {
|
DxvkMemoryChunk::~DxvkMemoryChunk() {
|
||||||
|
TRACE(this);
|
||||||
m_heap->freeDeviceMemory(m_memory);
|
m_heap->freeDeviceMemory(m_memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,6 +641,19 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t SpirvModule::opNot(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand) {
|
||||||
|
uint32_t resultId = this->allocateId();
|
||||||
|
|
||||||
|
m_code.putIns (spv::OpNot, 4);
|
||||||
|
m_code.putWord(resultType);
|
||||||
|
m_code.putWord(resultId);
|
||||||
|
m_code.putWord(operand);
|
||||||
|
return resultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t SpirvModule::opConvertFtoS(
|
uint32_t SpirvModule::opConvertFtoS(
|
||||||
uint32_t resultType,
|
uint32_t resultType,
|
||||||
uint32_t operand) {
|
uint32_t operand) {
|
||||||
@ -693,19 +706,6 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t SpirvModule::opNot(
|
|
||||||
uint32_t resultType,
|
|
||||||
uint32_t operand) {
|
|
||||||
uint32_t resultId = this->allocateId();
|
|
||||||
|
|
||||||
m_code.putIns (spv::OpNot, 4);
|
|
||||||
m_code.putWord(resultType);
|
|
||||||
m_code.putWord(resultId);
|
|
||||||
m_code.putWord(operand);
|
|
||||||
return resultId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t SpirvModule::opCompositeConstruct(
|
uint32_t SpirvModule::opCompositeConstruct(
|
||||||
uint32_t resultType,
|
uint32_t resultType,
|
||||||
uint32_t valueCount,
|
uint32_t valueCount,
|
||||||
@ -760,6 +760,84 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t SpirvModule::opDpdx(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand) {
|
||||||
|
uint32_t resultId = this->allocateId();
|
||||||
|
|
||||||
|
m_code.putIns (spv::OpDPdx, 4);
|
||||||
|
m_code.putWord(resultType);
|
||||||
|
m_code.putWord(resultId);
|
||||||
|
m_code.putWord(operand);
|
||||||
|
return resultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t SpirvModule::opDpdy(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand) {
|
||||||
|
uint32_t resultId = this->allocateId();
|
||||||
|
|
||||||
|
m_code.putIns (spv::OpDPdy, 4);
|
||||||
|
m_code.putWord(resultType);
|
||||||
|
m_code.putWord(resultId);
|
||||||
|
m_code.putWord(operand);
|
||||||
|
return resultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t SpirvModule::opDpdxCoarse(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand) {
|
||||||
|
uint32_t resultId = this->allocateId();
|
||||||
|
|
||||||
|
m_code.putIns (spv::OpDPdxCoarse, 4);
|
||||||
|
m_code.putWord(resultType);
|
||||||
|
m_code.putWord(resultId);
|
||||||
|
m_code.putWord(operand);
|
||||||
|
return resultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t SpirvModule::opDpdyCoarse(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand) {
|
||||||
|
uint32_t resultId = this->allocateId();
|
||||||
|
|
||||||
|
m_code.putIns (spv::OpDPdyCoarse, 4);
|
||||||
|
m_code.putWord(resultType);
|
||||||
|
m_code.putWord(resultId);
|
||||||
|
m_code.putWord(operand);
|
||||||
|
return resultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t SpirvModule::opDpdxFine(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand) {
|
||||||
|
uint32_t resultId = this->allocateId();
|
||||||
|
|
||||||
|
m_code.putIns (spv::OpDPdxFine, 4);
|
||||||
|
m_code.putWord(resultType);
|
||||||
|
m_code.putWord(resultId);
|
||||||
|
m_code.putWord(operand);
|
||||||
|
return resultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t SpirvModule::opDpdyFine(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand) {
|
||||||
|
uint32_t resultId = this->allocateId();
|
||||||
|
|
||||||
|
m_code.putIns (spv::OpDPdyFine, 4);
|
||||||
|
m_code.putWord(resultType);
|
||||||
|
m_code.putWord(resultId);
|
||||||
|
m_code.putWord(operand);
|
||||||
|
return resultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t SpirvModule::opVectorShuffle(
|
uint32_t SpirvModule::opVectorShuffle(
|
||||||
uint32_t resultType,
|
uint32_t resultType,
|
||||||
uint32_t vectorLeft,
|
uint32_t vectorLeft,
|
||||||
|
@ -236,6 +236,10 @@ namespace dxvk {
|
|||||||
uint32_t operand1,
|
uint32_t operand1,
|
||||||
uint32_t operand2);
|
uint32_t operand2);
|
||||||
|
|
||||||
|
uint32_t opNot(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand);
|
||||||
|
|
||||||
uint32_t opConvertFtoS(
|
uint32_t opConvertFtoS(
|
||||||
uint32_t resultType,
|
uint32_t resultType,
|
||||||
uint32_t operand);
|
uint32_t operand);
|
||||||
@ -252,10 +256,6 @@ namespace dxvk {
|
|||||||
uint32_t resultType,
|
uint32_t resultType,
|
||||||
uint32_t operand);
|
uint32_t operand);
|
||||||
|
|
||||||
uint32_t opNot(
|
|
||||||
uint32_t resultType,
|
|
||||||
uint32_t operand);
|
|
||||||
|
|
||||||
uint32_t opCompositeConstruct(
|
uint32_t opCompositeConstruct(
|
||||||
uint32_t resultType,
|
uint32_t resultType,
|
||||||
uint32_t valueCount,
|
uint32_t valueCount,
|
||||||
@ -274,6 +274,30 @@ namespace dxvk {
|
|||||||
uint32_t indexCount,
|
uint32_t indexCount,
|
||||||
const uint32_t* indexArray);
|
const uint32_t* indexArray);
|
||||||
|
|
||||||
|
uint32_t opDpdx(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand);
|
||||||
|
|
||||||
|
uint32_t opDpdy(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand);
|
||||||
|
|
||||||
|
uint32_t opDpdxCoarse(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand);
|
||||||
|
|
||||||
|
uint32_t opDpdyCoarse(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand);
|
||||||
|
|
||||||
|
uint32_t opDpdxFine(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand);
|
||||||
|
|
||||||
|
uint32_t opDpdyFine(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t operand);
|
||||||
|
|
||||||
uint32_t opVectorShuffle(
|
uint32_t opVectorShuffle(
|
||||||
uint32_t resultType,
|
uint32_t resultType,
|
||||||
uint32_t vectorLeft,
|
uint32_t vectorLeft,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user