2017-11-01 00:01:40 +01:00
|
|
|
#include "dxbc_chunk_isgn.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2018-05-31 22:13:08 +02:00
|
|
|
DxbcIsgn::DxbcIsgn(DxbcReader reader, DxbcTag tag) {
|
2017-11-01 00:01:40 +01:00
|
|
|
uint32_t elementCount = reader.readu32();
|
|
|
|
reader.skip(sizeof(uint32_t));
|
|
|
|
|
|
|
|
std::array<DxbcScalarType, 4> componentTypes = {
|
|
|
|
DxbcScalarType::Uint32, DxbcScalarType::Uint32,
|
|
|
|
DxbcScalarType::Sint32, DxbcScalarType::Float32,
|
|
|
|
};
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < elementCount; i++) {
|
|
|
|
DxbcSgnEntry entry;
|
2018-05-31 22:13:08 +02:00
|
|
|
entry.streamId = tag == "OSG5" ? reader.readu32() : 0;
|
2017-11-01 00:01:40 +01:00
|
|
|
entry.semanticName = reader.clone(reader.readu32()).readString();
|
|
|
|
entry.semanticIndex = reader.readu32();
|
|
|
|
entry.systemValue = static_cast<DxbcSystemValue>(reader.readu32());
|
|
|
|
entry.componentType = componentTypes.at(reader.readu32());
|
|
|
|
entry.registerId = reader.readu32();
|
|
|
|
entry.componentMask = bit::extract(reader.readu32(), 0, 3);
|
2018-05-31 22:13:08 +02:00
|
|
|
|
2017-11-01 00:01:40 +01:00
|
|
|
m_entries.push_back(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DxbcIsgn::~DxbcIsgn() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-07 12:45:02 +01:00
|
|
|
|
2018-01-01 23:31:01 +01:00
|
|
|
const DxbcSgnEntry* DxbcIsgn::findByRegister(uint32_t registerId) const {
|
|
|
|
for (auto e = this->begin(); e != this->end(); e++) {
|
|
|
|
if (e->registerId == registerId)
|
|
|
|
return &(*e);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-07 12:45:02 +01:00
|
|
|
const DxbcSgnEntry* DxbcIsgn::find(
|
|
|
|
const std::string& semanticName,
|
2018-06-23 20:13:00 +02:00
|
|
|
uint32_t semanticIndex,
|
|
|
|
uint32_t streamId) const {
|
2017-12-07 12:45:02 +01:00
|
|
|
for (auto e = this->begin(); e != this->end(); e++) {
|
2017-12-30 15:30:31 +01:00
|
|
|
if (e->semanticIndex == semanticIndex
|
2018-06-23 20:13:00 +02:00
|
|
|
&& e->streamId == streamId
|
2017-12-30 15:30:31 +01:00
|
|
|
&& compareSemanticNames(semanticName, e->semanticName))
|
2017-12-07 12:45:02 +01:00
|
|
|
return &(*e);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-12-30 15:30:31 +01:00
|
|
|
|
2018-07-01 15:24:21 +02:00
|
|
|
DxbcRegMask DxbcIsgn::regMask(
|
|
|
|
uint32_t registerId) const {
|
|
|
|
DxbcRegMask mask;
|
|
|
|
|
|
|
|
for (auto e = this->begin(); e != this->end(); e++) {
|
|
|
|
if (e->registerId == registerId)
|
|
|
|
mask |= e->componentMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-30 15:30:31 +01:00
|
|
|
bool DxbcIsgn::compareSemanticNames(
|
|
|
|
const std::string& a, const std::string& b) const {
|
|
|
|
if (a.size() != b.size())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < a.size(); i++) {
|
|
|
|
if (std::toupper(a[i]) != std::toupper(b[i]))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-01 00:01:40 +01:00
|
|
|
}
|