mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +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) {
|
DxbcComponentMask mask) {
|
||||||
const DxbcPointer ptr = this->getOperandPtr(operand);
|
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.
|
// Cast source value to destination register type.
|
||||||
// TODO verify that this actually works as intended.
|
// TODO verify that this actually works as intended.
|
||||||
DxbcValueType dstType;
|
DxbcValueType dstType;
|
||||||
dstType.componentType = ptr.type.valueType.componentType;
|
dstType.componentType = ptr.type.valueType.componentType;
|
||||||
dstType.componentCount = mask.componentCount();
|
dstType.componentCount = value.type.componentCount;
|
||||||
value = m_gen->regCast(value, dstType);
|
value = m_gen->regCast(value, dstType);
|
||||||
|
|
||||||
m_gen->regStore(ptr, value, mask);
|
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 DxbcCodeGen::regLoad(const DxbcPointer& ptr) {
|
||||||
DxbcValue result;
|
DxbcValue result;
|
||||||
result.type = ptr.type.valueType;
|
result.type = ptr.type.valueType;
|
||||||
|
@ -145,6 +145,10 @@ namespace dxvk {
|
|||||||
const DxbcValue& src,
|
const DxbcValue& src,
|
||||||
DxbcComponentMask mask);
|
DxbcComponentMask mask);
|
||||||
|
|
||||||
|
DxbcValue regVector(
|
||||||
|
const DxbcValue& src,
|
||||||
|
uint32_t size);
|
||||||
|
|
||||||
DxbcValue regLoad(
|
DxbcValue regLoad(
|
||||||
const DxbcPointer& ptr);
|
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 SpirvModule::opCompositeExtract(
|
||||||
uint32_t resultType,
|
uint32_t resultType,
|
||||||
uint32_t composite,
|
uint32_t composite,
|
||||||
|
@ -214,6 +214,11 @@ namespace dxvk {
|
|||||||
uint32_t resultType,
|
uint32_t resultType,
|
||||||
uint32_t operand);
|
uint32_t operand);
|
||||||
|
|
||||||
|
uint32_t opCompositeConstruct(
|
||||||
|
uint32_t resultType,
|
||||||
|
uint32_t valueCount,
|
||||||
|
const uint32_t* valueArray);
|
||||||
|
|
||||||
uint32_t opCompositeExtract(
|
uint32_t opCompositeExtract(
|
||||||
uint32_t resultType,
|
uint32_t resultType,
|
||||||
uint32_t composite,
|
uint32_t composite,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user