mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-30 04:24:11 +01:00
[dxbc] Scalar values can be expanded to multiple vector components during a store operation
This commit is contained in:
parent
d941446ca0
commit
93f79742e9
@ -545,11 +545,16 @@ namespace dxvk {
|
||||
DxbcComponentMask mask) {
|
||||
const DxbcPointer ptr = this->getOperandPtr(operand);
|
||||
|
||||
// The value to store is actually allowed to be scalar,
|
||||
// so we might need to create a vector from it.
|
||||
if (value.type.componentCount == 1)
|
||||
value = m_gen->regVector(value, mask.componentCount());
|
||||
|
||||
// Cast source value to destination register type.
|
||||
// TODO verify that this actually works as intended.
|
||||
DxbcValueType dstType;
|
||||
dstType.componentType = ptr.type.valueType.componentType;
|
||||
dstType.componentCount = mask.componentCount();
|
||||
dstType.componentCount = value.type.componentCount;
|
||||
value = m_gen->regCast(value, dstType);
|
||||
|
||||
m_gen->regStore(ptr, value, mask);
|
||||
|
@ -533,6 +533,24 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
DxbcValue DxbcCodeGen::regVector(
|
||||
const DxbcValue& src,
|
||||
uint32_t size) {
|
||||
if (size == 1)
|
||||
return src;
|
||||
|
||||
std::array<uint32_t, 4> ids = {
|
||||
src.valueId, src.valueId, src.valueId, src.valueId,
|
||||
};
|
||||
|
||||
DxbcValue result;
|
||||
result.type = DxbcValueType(src.type.componentType, size);
|
||||
result.valueId = m_module.opCompositeConstruct(
|
||||
this->defValueType(result.type), size, ids.data());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
DxbcValue DxbcCodeGen::regLoad(const DxbcPointer& ptr) {
|
||||
DxbcValue result;
|
||||
result.type = ptr.type.valueType;
|
||||
|
@ -145,6 +145,10 @@ namespace dxvk {
|
||||
const DxbcValue& src,
|
||||
DxbcComponentMask mask);
|
||||
|
||||
DxbcValue regVector(
|
||||
const DxbcValue& src,
|
||||
uint32_t size);
|
||||
|
||||
DxbcValue regLoad(
|
||||
const DxbcPointer& ptr);
|
||||
|
||||
|
@ -578,6 +578,22 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
uint32_t SpirvModule::opCompositeConstruct(
|
||||
uint32_t resultType,
|
||||
uint32_t valueCount,
|
||||
const uint32_t* valueArray) {
|
||||
uint32_t resultId = this->allocateId();
|
||||
|
||||
m_code.putIns (spv::OpCompositeConstruct, 3 + valueCount);
|
||||
m_code.putWord(resultType);
|
||||
m_code.putWord(resultId);
|
||||
|
||||
for (uint32_t i = 0; i < valueCount; i++)
|
||||
m_code.putWord(valueArray[i]);
|
||||
return resultId;
|
||||
}
|
||||
|
||||
|
||||
uint32_t SpirvModule::opCompositeExtract(
|
||||
uint32_t resultType,
|
||||
uint32_t composite,
|
||||
|
@ -214,6 +214,11 @@ namespace dxvk {
|
||||
uint32_t resultType,
|
||||
uint32_t operand);
|
||||
|
||||
uint32_t opCompositeConstruct(
|
||||
uint32_t resultType,
|
||||
uint32_t valueCount,
|
||||
const uint32_t* valueArray);
|
||||
|
||||
uint32_t opCompositeExtract(
|
||||
uint32_t resultType,
|
||||
uint32_t composite,
|
||||
|
Loading…
Reference in New Issue
Block a user