From 9cdc34194637c523028178b42e83d0b83b443832 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 1 Nov 2017 16:43:04 +0100 Subject: [PATCH] [dxbc] Some shader signature stuff --- src/dxbc/dxbc_chunk_isgn.cpp | 17 +++++++------ src/dxbc/dxbc_chunk_isgn.h | 4 +++ src/dxbc/dxbc_compiler.cpp | 10 -------- src/dxbc/dxbc_compiler.h | 48 +++++++++++++++++++++++++++--------- src/spirv/spirv_module.cpp | 33 +++++++++++++++++++++++++ src/spirv/spirv_module.h | 13 ++++++++++ 6 files changed, 96 insertions(+), 29 deletions(-) diff --git a/src/dxbc/dxbc_chunk_isgn.cpp b/src/dxbc/dxbc_chunk_isgn.cpp index b4c088391..b47dcf165 100644 --- a/src/dxbc/dxbc_chunk_isgn.cpp +++ b/src/dxbc/dxbc_chunk_isgn.cpp @@ -20,13 +20,6 @@ namespace dxvk { entry.registerId = reader.readu32(); entry.componentMask = bit::extract(reader.readu32(), 0, 3); - Logger::info(str::format( - entry.semanticName, ",", - entry.semanticIndex, ",", - entry.systemValue, ",", -// entry.componentType, ",", - entry.registerId)); - m_entries.push_back(entry); } } @@ -36,4 +29,14 @@ namespace dxvk { } + + uint32_t DxbcIsgn::entryCount() const { + return m_entries.size(); + } + + + const DxbcSgnEntry& DxbcIsgn::entry(uint32_t id) const { + return m_entries.at(id); + } + } \ No newline at end of file diff --git a/src/dxbc/dxbc_chunk_isgn.h b/src/dxbc/dxbc_chunk_isgn.h index 2e2084eda..31b70caab 100644 --- a/src/dxbc/dxbc_chunk_isgn.h +++ b/src/dxbc/dxbc_chunk_isgn.h @@ -36,6 +36,10 @@ namespace dxvk { DxbcIsgn(DxbcReader reader); ~DxbcIsgn(); + uint32_t entryCount() const; + + const DxbcSgnEntry& entry(uint32_t id) const; + private: std::vector m_entries; diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index 4349d66ef..bddcba291 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -244,16 +244,6 @@ namespace dxvk { result = this->loadPointer(m_rRegs.at(index.immPart())); } break; - case DxbcOperandType::Input: { - const DxbcOperandIndex index = operand.index(0); - result = this->loadPointer(m_vRegs.at(index.immPart())); - } break; - - case DxbcOperandType::Output: { - const DxbcOperandIndex index = operand.index(0); - result = this->loadPointer(m_oRegs.at(index.immPart())); - } break; - default: throw DxvkError(str::format( "DxbcCompiler::loadOperandRegister: Unhandled operand type: ", diff --git a/src/dxbc/dxbc_compiler.h b/src/dxbc/dxbc_compiler.h index 514561678..e74c3b1a5 100644 --- a/src/dxbc/dxbc_compiler.h +++ b/src/dxbc/dxbc_compiler.h @@ -52,8 +52,10 @@ namespace dxvk { std::vector m_interfaces; std::vector m_rRegs; // Temps - std::vector m_vRegs; // Input registers - std::vector m_oRegs; // Output registers + + DxbcPointer m_svPosition; + std::vector m_svClipDistance; + std::vector m_svCullDistance; uint32_t m_entryPointId = 0; @@ -62,21 +64,42 @@ namespace dxvk { bool m_useRestrictedMath = false; + + void declareCapabilities(); void declareMemoryModel(); - void dclGlobalFlags(const DxbcInstruction& ins); - void dclInput(const DxbcInstruction& ins); - void dclOutputSiv(const DxbcInstruction& ins); - void dclTemps(const DxbcInstruction& ins); - void dclThreadGroup(const DxbcInstruction& ins); + void dclGlobalFlags( + const DxbcInstruction& ins); - void opMov(const DxbcInstruction& ins); - void opRet(const DxbcInstruction& ins); + void dclInput( + const DxbcInstruction& ins); + + void dclOutputSiv( + const DxbcInstruction& ins); + + void dclTemps( + const DxbcInstruction& ins); + + void dclThreadGroup( + const DxbcInstruction& ins); + + + void opMov( + const DxbcInstruction& ins); + + void opRet( + const DxbcInstruction& ins); + + uint32_t getScalarTypeId( + const DxbcScalarType& type); + + uint32_t getValueTypeId( + const DxbcValueType& type); + + uint32_t getPointerTypeId( + const DxbcPointerType& type); - uint32_t getScalarTypeId(const DxbcScalarType& type); - uint32_t getValueTypeId(const DxbcValueType& type); - uint32_t getPointerTypeId(const DxbcPointerType& type); DxbcValue loadPointer( const DxbcPointer& pointer); @@ -85,6 +108,7 @@ namespace dxvk { const DxbcOperand& operand, const DxbcValueType& type); + void storePointer( const DxbcPointer& pointer, const DxbcValue& value); diff --git a/src/spirv/spirv_module.cpp b/src/spirv/spirv_module.cpp index 47dec54e3..ab930bf7c 100644 --- a/src/spirv/spirv_module.cpp +++ b/src/spirv/spirv_module.cpp @@ -372,6 +372,39 @@ namespace dxvk { } + void SpirvModule::opLabel(uint32_t labelId) { + m_code.putIns (spv::OpReturn, 2); + m_code.putWord(labelId); + } + + + uint32_t SpirvModule::opLoad( + uint32_t typeId, + uint32_t pointerId) { + uint32_t resultId = this->allocateId(); + + m_code.putIns (spv::OpLoad, 4); + m_code.putWord(typeId); + m_code.putWord(resultId); + m_code.putWord(pointerId); + return resultId; + } + + + void SpirvModule::opStore( + uint32_t pointerId, + uint32_t valueId) { + m_code.putIns (spv::OpStore, 3); + m_code.putWord(pointerId); + m_code.putWord(valueId); + } + + + void SpirvModule::opReturn() { + m_code.putIns (spv::OpReturn, 1); + } + + uint32_t SpirvModule::defType( spv::Op op, uint32_t argCount, diff --git a/src/spirv/spirv_module.h b/src/spirv/spirv_module.h index 2828e6ab2..dc6f21b19 100644 --- a/src/spirv/spirv_module.h +++ b/src/spirv/spirv_module.h @@ -136,6 +136,19 @@ namespace dxvk { uint32_t argCount, const uint32_t* argIds); + void opLabel( + uint32_t labelId); + + uint32_t opLoad( + uint32_t typeId, + uint32_t pointerId); + + void opStore( + uint32_t pointerId, + uint32_t valueId); + + void opReturn(); + private: uint32_t m_id = 1;