For now, all 512 constants live in the same block.
This commit is contained in:
parent
92a8a03caa
commit
1d82d7bd92
|
@ -100,7 +100,7 @@ void SpirvShaderTranslator::StartTranslation() {
|
||||||
|
|
||||||
// Uniform constants.
|
// Uniform constants.
|
||||||
Id float_consts_type =
|
Id float_consts_type =
|
||||||
b.makeArrayType(vec4_float_type_, b.makeUintConstant(256), 1);
|
b.makeArrayType(vec4_float_type_, b.makeUintConstant(512), 1);
|
||||||
Id loop_consts_type =
|
Id loop_consts_type =
|
||||||
b.makeArrayType(b.makeUintType(32), b.makeUintConstant(32), 1);
|
b.makeArrayType(b.makeUintType(32), b.makeUintConstant(32), 1);
|
||||||
Id bool_consts_type =
|
Id bool_consts_type =
|
||||||
|
@ -119,14 +119,14 @@ void SpirvShaderTranslator::StartTranslation() {
|
||||||
|
|
||||||
b.addMemberDecoration(consts_struct_type, 1,
|
b.addMemberDecoration(consts_struct_type, 1,
|
||||||
spv::Decoration::DecorationOffset,
|
spv::Decoration::DecorationOffset,
|
||||||
256 * 4 * sizeof(float));
|
512 * 4 * sizeof(float));
|
||||||
b.addMemberDecoration(consts_struct_type, 1,
|
b.addMemberDecoration(consts_struct_type, 1,
|
||||||
spv::Decoration::DecorationArrayStride,
|
spv::Decoration::DecorationArrayStride,
|
||||||
sizeof(uint32_t));
|
sizeof(uint32_t));
|
||||||
|
|
||||||
b.addMemberDecoration(consts_struct_type, 2,
|
b.addMemberDecoration(consts_struct_type, 2,
|
||||||
spv::Decoration::DecorationOffset,
|
spv::Decoration::DecorationOffset,
|
||||||
256 * 4 * sizeof(float) + 32 * sizeof(uint32_t));
|
512 * 4 * sizeof(float) + 32 * sizeof(uint32_t));
|
||||||
b.addMemberDecoration(consts_struct_type, 2,
|
b.addMemberDecoration(consts_struct_type, 2,
|
||||||
spv::Decoration::DecorationArrayStride,
|
spv::Decoration::DecorationArrayStride,
|
||||||
sizeof(uint32_t));
|
sizeof(uint32_t));
|
||||||
|
@ -840,22 +840,28 @@ Id SpirvShaderTranslator::LoadFromOperand(const InstructionOperand& op) {
|
||||||
Id storage_index = 0; // Storage index at lowest level
|
Id storage_index = 0; // Storage index at lowest level
|
||||||
std::vector<Id> storage_offsets; // Offsets in nested arrays -> storage
|
std::vector<Id> storage_offsets; // Offsets in nested arrays -> storage
|
||||||
|
|
||||||
|
// Out of the 512 constant registers pixel shaders get the last 256.
|
||||||
|
uint32_t storage_base = 0;
|
||||||
|
if (op.storage_source == InstructionStorageSource::kConstantFloat) {
|
||||||
|
storage_base = is_pixel_shader() ? 256 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
switch (op.storage_addressing_mode) {
|
switch (op.storage_addressing_mode) {
|
||||||
case InstructionStorageAddressingMode::kStatic: {
|
case InstructionStorageAddressingMode::kStatic: {
|
||||||
storage_index = b.makeUintConstant(op.storage_index);
|
storage_index = b.makeUintConstant(storage_base + op.storage_index);
|
||||||
} break;
|
} break;
|
||||||
case InstructionStorageAddressingMode::kAddressAbsolute: {
|
case InstructionStorageAddressingMode::kAddressAbsolute: {
|
||||||
// storage_index + a0
|
// storage_index + a0
|
||||||
storage_index =
|
storage_index =
|
||||||
b.createBinOp(spv::Op::OpIAdd, b.makeUintType(32), b.createLoad(a0_),
|
b.createBinOp(spv::Op::OpIAdd, b.makeUintType(32), b.createLoad(a0_),
|
||||||
b.makeUintConstant(op.storage_index));
|
b.makeUintConstant(storage_base + op.storage_index));
|
||||||
} break;
|
} break;
|
||||||
case InstructionStorageAddressingMode::kAddressRelative: {
|
case InstructionStorageAddressingMode::kAddressRelative: {
|
||||||
// TODO: Based on loop index
|
// TODO: Based on loop index
|
||||||
// storage_index + aL.x
|
// storage_index + aL.x
|
||||||
storage_index = b.createBinOp(spv::Op::OpIAdd, b.makeUintType(32),
|
storage_index = b.createBinOp(
|
||||||
b.makeUintConstant(0),
|
spv::Op::OpIAdd, b.makeUintType(32), b.makeUintConstant(0),
|
||||||
b.makeUintConstant(op.storage_index));
|
b.makeUintConstant(storage_base + op.storage_index));
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
assert_always();
|
assert_always();
|
||||||
|
@ -1063,7 +1069,7 @@ void SpirvShaderTranslator::StoreToResult(Id source_value_id,
|
||||||
source_value_id = CreateGlslStd450InstructionCall(
|
source_value_id = CreateGlslStd450InstructionCall(
|
||||||
spv::Decoration::DecorationInvariant, b.getTypeId(source_value_id),
|
spv::Decoration::DecorationInvariant, b.getTypeId(source_value_id),
|
||||||
spv::GLSLstd450::kFClamp,
|
spv::GLSLstd450::kFClamp,
|
||||||
{b.makeFloatConstant(0.0), b.makeFloatConstant(1.0)});
|
{source_value_id, b.makeFloatConstant(0.0), b.makeFloatConstant(1.0)});
|
||||||
}
|
}
|
||||||
|
|
||||||
// swizzle
|
// swizzle
|
||||||
|
|
Loading…
Reference in New Issue