[SPIR-V] Use Builder createSelectionMerge directly
This commit is contained in:
parent
64d2a80f79
commit
78f1d55a36
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2023 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_GPU_SPIRV_BUILDER_H_
|
||||
#define XENIA_GPU_SPIRV_BUILDER_H_
|
||||
|
||||
#include "third_party/glslang/SPIRV/SpvBuilder.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
// SpvBuilder with extra helpers.
|
||||
|
||||
class SpirvBuilder : public spv::Builder {
|
||||
public:
|
||||
SpirvBuilder(unsigned int spv_version, unsigned int user_number,
|
||||
spv::SpvBuildLogger* logger)
|
||||
: spv::Builder(spv_version, user_number, logger) {}
|
||||
|
||||
// Make public rather than protected.
|
||||
using spv::Builder::createSelectionMerge;
|
||||
};
|
||||
|
||||
} // namespace gpu
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_GPU_SPIRV_BUILDER_H_
|
|
@ -161,7 +161,7 @@ uint32_t SpirvShaderTranslator::GetModificationRegisterCount() const {
|
|||
|
||||
void SpirvShaderTranslator::StartTranslation() {
|
||||
// TODO(Triang3l): Logger.
|
||||
builder_ = std::make_unique<spv::Builder>(
|
||||
builder_ = std::make_unique<SpirvBuilder>(
|
||||
features_.spirv_version, (kSpirvMagicToolId << 16) | 1, nullptr);
|
||||
|
||||
builder_->addCapability(IsSpirvTessEvalShader() ? spv::CapabilityTessellation
|
||||
|
@ -591,8 +591,8 @@ void SpirvShaderTranslator::StartTranslation() {
|
|||
main_switch_header_ = builder_->getBuildPoint();
|
||||
main_switch_merge_ =
|
||||
new spv::Block(builder_->getUniqueId(), *function_main_);
|
||||
SpirvCreateSelectionMerge(main_switch_merge_->getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(main_switch_merge_,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
main_switch_op_ = std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
main_switch_op_->addIdOperand(main_loop_pc_current);
|
||||
main_switch_op_->addIdOperand(main_switch_merge_->getId());
|
||||
|
@ -914,7 +914,7 @@ void SpirvShaderTranslator::ProcessLoopStartInstruction(
|
|||
spv::OpIEqual, type_bool_, loop_count_new, const_uint_0_);
|
||||
spv::Block& skip_block = builder_->makeNewBlock();
|
||||
spv::Block& body_block = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(body_block.getId());
|
||||
builder_->createSelectionMerge(&body_block, spv::SelectionControlMaskNone);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> branch_conditional_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpBranchConditional);
|
||||
|
@ -976,7 +976,7 @@ void SpirvShaderTranslator::ProcessLoopEndInstruction(
|
|||
spv::Block& body_block = *builder_->getBuildPoint();
|
||||
spv::Block& continue_block = builder_->makeNewBlock();
|
||||
spv::Block& break_block = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(break_block.getId());
|
||||
builder_->createSelectionMerge(&break_block, spv::SelectionControlMaskNone);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> branch_conditional_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpBranchConditional);
|
||||
|
@ -1293,8 +1293,8 @@ void SpirvShaderTranslator::StartVertexOrTessEvalShaderInMain() {
|
|||
spv::Block& block_load_vertex_index_pre = *builder_->getBuildPoint();
|
||||
spv::Block& block_load_vertex_index_start = builder_->makeNewBlock();
|
||||
spv::Block& block_load_vertex_index_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_load_vertex_index_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_load_vertex_index_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(load_vertex_index,
|
||||
&block_load_vertex_index_start,
|
||||
&block_load_vertex_index_merge);
|
||||
|
@ -1389,8 +1389,8 @@ void SpirvShaderTranslator::StartVertexOrTessEvalShaderInMain() {
|
|||
spv::Block& block_load_vertex_index_pre = *builder_->getBuildPoint();
|
||||
spv::Block& block_load_vertex_index_start = builder_->makeNewBlock();
|
||||
spv::Block& block_load_vertex_index_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_load_vertex_index_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_load_vertex_index_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(load_vertex_index,
|
||||
&block_load_vertex_index_start,
|
||||
&block_load_vertex_index_merge);
|
||||
|
@ -1992,8 +1992,8 @@ void SpirvShaderTranslator::StartFragmentShaderInMain() {
|
|||
builder_->makeNewBlock();
|
||||
main_fsi_early_depth_stencil_execute_quad_merge_ =
|
||||
&builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(
|
||||
main_fsi_early_depth_stencil_execute_quad_merge_->getId(),
|
||||
builder_->createSelectionMerge(
|
||||
main_fsi_early_depth_stencil_execute_quad_merge_,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(
|
||||
quad_needs_execution, &main_fsi_early_depth_stencil_execute_quad,
|
||||
|
@ -2244,7 +2244,8 @@ void SpirvShaderTranslator::UpdateExecConditionals(
|
|||
cf_exec_condition_ = condition;
|
||||
cf_exec_conditional_merge_ = new spv::Block(
|
||||
builder_->getUniqueId(), builder_->getBuildPoint()->getParent());
|
||||
SpirvCreateSelectionMerge(cf_exec_conditional_merge_->getId());
|
||||
builder_->createSelectionMerge(cf_exec_conditional_merge_,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
spv::Block& inner_block = builder_->makeNewBlock();
|
||||
builder_->createConditionalBranch(
|
||||
condition_id, condition ? &inner_block : cf_exec_conditional_merge_,
|
||||
|
@ -2284,7 +2285,8 @@ void SpirvShaderTranslator::UpdateInstructionPredication(bool predicated,
|
|||
spv::Block& predicated_block = builder_->makeNewBlock();
|
||||
cf_instruction_predicate_merge_ = new spv::Block(
|
||||
builder_->getUniqueId(), builder_->getBuildPoint()->getParent());
|
||||
SpirvCreateSelectionMerge(cf_instruction_predicate_merge_->getId());
|
||||
builder_->createSelectionMerge(cf_instruction_predicate_merge_,
|
||||
spv::SelectionControlMaskNone);
|
||||
builder_->createConditionalBranch(
|
||||
predicate_id,
|
||||
condition ? &predicated_block : cf_instruction_predicate_merge_,
|
||||
|
@ -2870,7 +2872,8 @@ spv::Id SpirvShaderTranslator::EndianSwap32Uint(spv::Id value, spv::Id endian) {
|
|||
assert_false(block_pre_8in16.isTerminated());
|
||||
spv::Block& block_8in16 = builder_->makeNewBlock();
|
||||
spv::Block& block_8in16_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_8in16_merge.getId());
|
||||
builder_->createSelectionMerge(&block_8in16_merge,
|
||||
spv::SelectionControlMaskNone);
|
||||
builder_->createConditionalBranch(is_8in16_or_8in32, &block_8in16,
|
||||
&block_8in16_merge);
|
||||
builder_->setBuildPoint(&block_8in16);
|
||||
|
@ -2910,7 +2913,8 @@ spv::Id SpirvShaderTranslator::EndianSwap32Uint(spv::Id value, spv::Id endian) {
|
|||
spv::Block& block_pre_16in32 = *builder_->getBuildPoint();
|
||||
spv::Block& block_16in32 = builder_->makeNewBlock();
|
||||
spv::Block& block_16in32_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_16in32_merge.getId());
|
||||
builder_->createSelectionMerge(&block_16in32_merge,
|
||||
spv::SelectionControlMaskNone);
|
||||
builder_->createConditionalBranch(is_8in32_or_16in32, &block_16in32,
|
||||
&block_16in32_merge);
|
||||
builder_->setBuildPoint(&block_16in32);
|
||||
|
@ -2982,8 +2986,8 @@ spv::Id SpirvShaderTranslator::LoadUint32FromSharedMemory(
|
|||
std::unique_ptr<spv::Instruction> value_phi_op =
|
||||
std::make_unique<spv::Instruction>(value_phi_result, type_uint_,
|
||||
spv::OpPhi);
|
||||
SpirvCreateSelectionMerge(switch_merge_block.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&switch_merge_block,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "third_party/glslang/SPIRV/SpvBuilder.h"
|
||||
#include "xenia/gpu/shader_translator.h"
|
||||
#include "xenia/gpu/spirv_builder.h"
|
||||
#include "xenia/gpu/xenos.h"
|
||||
#include "xenia/ui/vulkan/vulkan_provider.h"
|
||||
|
||||
|
@ -374,30 +374,30 @@ class SpirvShaderTranslator : public ShaderTranslator {
|
|||
|
||||
// Converts the color value externally clamped to [0, 31.875] to 7e3 floating
|
||||
// point, with zeros in bits 10:31, rounding to the nearest even.
|
||||
static spv::Id PreClampedFloat32To7e3(spv::Builder& builder,
|
||||
static spv::Id PreClampedFloat32To7e3(SpirvBuilder& builder,
|
||||
spv::Id f32_scalar,
|
||||
spv::Id ext_inst_glsl_std_450);
|
||||
// Same as PreClampedFloat32To7e3, but clamps the input to [0, 31.875].
|
||||
static spv::Id UnclampedFloat32To7e3(spv::Builder& builder,
|
||||
static spv::Id UnclampedFloat32To7e3(SpirvBuilder& builder,
|
||||
spv::Id f32_scalar,
|
||||
spv::Id ext_inst_glsl_std_450);
|
||||
// Converts the 7e3 number in bits [f10_shift, f10_shift + 10) to a 32-bit
|
||||
// float.
|
||||
static spv::Id Float7e3To32(spv::Builder& builder, spv::Id f10_uint_scalar,
|
||||
static spv::Id Float7e3To32(SpirvBuilder& builder, spv::Id f10_uint_scalar,
|
||||
uint32_t f10_shift, bool result_as_uint,
|
||||
spv::Id ext_inst_glsl_std_450);
|
||||
// Converts the depth value externally clamped to the representable [0, 2)
|
||||
// range to 20e4 floating point, with zeros in bits 24:31, rounding to the
|
||||
// nearest even or towards zero. If remap_from_0_to_0_5 is true, it's assumed
|
||||
// that 0...1 is pre-remapped to 0...0.5 in the input.
|
||||
static spv::Id PreClampedDepthTo20e4(spv::Builder& builder,
|
||||
static spv::Id PreClampedDepthTo20e4(SpirvBuilder& builder,
|
||||
spv::Id f32_scalar,
|
||||
bool round_to_nearest_even,
|
||||
bool remap_from_0_to_0_5,
|
||||
spv::Id ext_inst_glsl_std_450);
|
||||
// Converts the 20e4 number in bits [f24_shift, f24_shift + 10) to a 32-bit
|
||||
// float.
|
||||
static spv::Id Depth20e4To32(spv::Builder& builder, spv::Id f24_uint_scalar,
|
||||
static spv::Id Depth20e4To32(SpirvBuilder& builder, spv::Id f24_uint_scalar,
|
||||
uint32_t f24_shift, bool remap_to_0_to_0_5,
|
||||
bool result_as_uint,
|
||||
spv::Id ext_inst_glsl_std_450);
|
||||
|
@ -451,15 +451,6 @@ class SpirvShaderTranslator : public ShaderTranslator {
|
|||
|
||||
// Builder helpers.
|
||||
spv::Id SpirvSmearScalarResultOrConstant(spv::Id scalar, spv::Id vector_type);
|
||||
void SpirvCreateSelectionMerge(
|
||||
spv::Id merge_block_id, spv::SelectionControlMask selection_control_mask =
|
||||
spv::SelectionControlMaskNone) {
|
||||
std::unique_ptr<spv::Instruction> selection_merge_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSelectionMerge);
|
||||
selection_merge_op->addIdOperand(merge_block_id);
|
||||
selection_merge_op->addImmediateOperand(selection_control_mask);
|
||||
builder_->getBuildPoint()->addInstruction(std::move(selection_merge_op));
|
||||
}
|
||||
|
||||
Modification GetSpirvShaderModification() const {
|
||||
return Modification(current_translation().modification());
|
||||
|
@ -689,7 +680,7 @@ class SpirvShaderTranslator : public ShaderTranslator {
|
|||
// and stencil testing with fragment shader interlock.
|
||||
bool is_depth_only_fragment_shader_ = false;
|
||||
|
||||
std::unique_ptr<spv::Builder> builder_;
|
||||
std::unique_ptr<SpirvBuilder> builder_;
|
||||
|
||||
std::vector<spv::Id> id_vector_temp_;
|
||||
// For helper functions like operand loading, so they don't conflict with
|
||||
|
|
|
@ -62,7 +62,7 @@ void SpirvShaderTranslator::KillPixel(spv::Id condition) {
|
|||
builder_->createBranch(merge_block);
|
||||
|
||||
builder_->setBuildPoint(&header_block);
|
||||
SpirvCreateSelectionMerge(merge_block->getId());
|
||||
builder_->createSelectionMerge(merge_block, spv::SelectionControlMaskNone);
|
||||
builder_->createConditionalBranch(condition, kill_block, merge_block);
|
||||
|
||||
function.addBlock(merge_block);
|
||||
|
|
|
@ -1178,8 +1178,8 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
|||
spv::Block& block_dimension_head = *builder_->getBuildPoint();
|
||||
spv::Block& block_dimension_merge = builder_->makeNewBlock();
|
||||
spv::Block& block_dimension_3d = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_dimension_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_dimension_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
assert_true(data_is_3d != spv::NoResult);
|
||||
builder_->createConditionalBranch(data_is_3d, &block_dimension_3d,
|
||||
&block_dimension_merge);
|
||||
|
@ -1209,8 +1209,8 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
|||
spv::Block* block_dimension_3d =
|
||||
z_offset != spv::NoResult ? &builder_->makeNewBlock() : nullptr;
|
||||
spv::Block& block_dimension_stacked = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_dimension_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_dimension_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
assert_true(data_is_3d != spv::NoResult);
|
||||
builder_->createConditionalBranch(
|
||||
data_is_3d,
|
||||
|
@ -1318,7 +1318,8 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
|||
spv::Block& block_ma_y = builder_->makeNewBlock();
|
||||
spv::Block& block_ma_z = builder_->makeNewBlock();
|
||||
spv::Block& block_ma_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_ma_merge.getId());
|
||||
builder_->createSelectionMerge(&block_ma_merge,
|
||||
spv::SelectionControlMaskNone);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> ma_switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
@ -1441,8 +1442,8 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
|||
spv::Block& block_dimension_3d_start = builder_->makeNewBlock();
|
||||
spv::Block& block_dimension_stacked_start = builder_->makeNewBlock();
|
||||
spv::Block& block_dimension_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_dimension_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_dimension_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
assert_true(data_is_3d != spv::NoResult);
|
||||
builder_->createConditionalBranch(data_is_3d,
|
||||
&block_dimension_3d_start,
|
||||
|
@ -1843,8 +1844,8 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
|||
spv::Block& block_dimension_3d_start = builder_->makeNewBlock();
|
||||
spv::Block& block_dimension_stacked_start = builder_->makeNewBlock();
|
||||
spv::Block& block_dimension_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_dimension_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_dimension_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
assert_true(data_is_3d != spv::NoResult);
|
||||
builder_->createConditionalBranch(data_is_3d,
|
||||
&block_dimension_3d_start,
|
||||
|
@ -2021,8 +2022,8 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
|||
? builder_->makeNewBlock()
|
||||
: block_z_head;
|
||||
if (vol_filter_is_linear != spv::NoResult) {
|
||||
SpirvCreateSelectionMerge(block_z_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(
|
||||
&block_z_merge, spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(
|
||||
vol_filter_is_linear, &block_z_linear, &block_z_merge);
|
||||
builder_->setBuildPoint(&block_z_linear);
|
||||
|
@ -2187,8 +2188,8 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
|||
spv::Block& block_swizzle_constant = builder_->makeNewBlock();
|
||||
spv::Block& block_swizzle_component = builder_->makeNewBlock();
|
||||
spv::Block& block_swizzle_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_swizzle_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(
|
||||
&block_swizzle_merge, spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(swizzle_bit_2,
|
||||
&block_swizzle_constant,
|
||||
&block_swizzle_component);
|
||||
|
@ -2279,8 +2280,8 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
|||
spv::Block& block_sign_unsigned_biased = builder_->makeNewBlock();
|
||||
spv::Block& block_sign_gamma_start = builder_->makeNewBlock();
|
||||
spv::Block& block_sign_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_sign_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(
|
||||
&block_sign_merge, spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> sign_switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
@ -2543,8 +2544,8 @@ void SpirvShaderTranslator::SampleTexture(
|
|||
spv::Block& block_sign_head = *builder_->getBuildPoint();
|
||||
spv::Block& block_sign = builder_->makeNewBlock();
|
||||
spv::Block& block_sign_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_sign_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_sign_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
// Unsigned (i == 0) - if there are any non-signed components.
|
||||
// Signed (i == 1) - if there are any signed components.
|
||||
builder_->createConditionalBranch(i ? is_any_signed : is_all_signed,
|
||||
|
@ -2601,8 +2602,8 @@ spv::Id SpirvShaderTranslator::QueryTextureLod(
|
|||
spv::Block& block_sign_signed = builder_->makeNewBlock();
|
||||
spv::Block& block_sign_unsigned = builder_->makeNewBlock();
|
||||
spv::Block& block_sign_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_sign_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_sign_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(is_all_signed, &block_sign_signed,
|
||||
&block_sign_unsigned);
|
||||
builder_->setBuildPoint(&block_sign_signed);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace xe {
|
|||
namespace gpu {
|
||||
|
||||
spv::Id SpirvShaderTranslator::PreClampedFloat32To7e3(
|
||||
spv::Builder& builder, spv::Id f32_scalar, spv::Id ext_inst_glsl_std_450) {
|
||||
SpirvBuilder& builder, spv::Id f32_scalar, spv::Id ext_inst_glsl_std_450) {
|
||||
// https://github.com/Microsoft/DirectXTex/blob/master/DirectXTex/DirectXTexConvert.cpp
|
||||
// Assuming the value is already clamped to [0, 31.875].
|
||||
|
||||
|
@ -107,7 +107,7 @@ spv::Id SpirvShaderTranslator::PreClampedFloat32To7e3(
|
|||
}
|
||||
|
||||
spv::Id SpirvShaderTranslator::UnclampedFloat32To7e3(
|
||||
spv::Builder& builder, spv::Id f32_scalar, spv::Id ext_inst_glsl_std_450) {
|
||||
SpirvBuilder& builder, spv::Id f32_scalar, spv::Id ext_inst_glsl_std_450) {
|
||||
spv::Id type_float = builder.makeFloatType(32);
|
||||
|
||||
// Need the source as float for clamping.
|
||||
|
@ -136,7 +136,7 @@ spv::Id SpirvShaderTranslator::UnclampedFloat32To7e3(
|
|||
return PreClampedFloat32To7e3(builder, f32_scalar, ext_inst_glsl_std_450);
|
||||
}
|
||||
|
||||
spv::Id SpirvShaderTranslator::Float7e3To32(spv::Builder& builder,
|
||||
spv::Id SpirvShaderTranslator::Float7e3To32(SpirvBuilder& builder,
|
||||
spv::Id f10_uint_scalar,
|
||||
uint32_t f10_shift,
|
||||
bool result_as_uint,
|
||||
|
@ -234,7 +234,7 @@ spv::Id SpirvShaderTranslator::Float7e3To32(spv::Builder& builder,
|
|||
}
|
||||
|
||||
spv::Id SpirvShaderTranslator::PreClampedDepthTo20e4(
|
||||
spv::Builder& builder, spv::Id f32_scalar, bool round_to_nearest_even,
|
||||
SpirvBuilder& builder, spv::Id f32_scalar, bool round_to_nearest_even,
|
||||
bool remap_from_0_to_0_5, spv::Id ext_inst_glsl_std_450) {
|
||||
// CFloat24 from d3dref9.dll +
|
||||
// https://github.com/Microsoft/DirectXTex/blob/master/DirectXTex/DirectXTexConvert.cpp
|
||||
|
@ -325,7 +325,7 @@ spv::Id SpirvShaderTranslator::PreClampedDepthTo20e4(
|
|||
builder.makeUintConstant(24));
|
||||
}
|
||||
|
||||
spv::Id SpirvShaderTranslator::Depth20e4To32(spv::Builder& builder,
|
||||
spv::Id SpirvShaderTranslator::Depth20e4To32(SpirvBuilder& builder,
|
||||
spv::Id f24_uint_scalar,
|
||||
uint32_t f24_shift,
|
||||
bool remap_to_0_to_0_5,
|
||||
|
@ -463,8 +463,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
builder_->createLoad(var_main_kill_pixel_, spv::NoPrecision);
|
||||
spv::Block& block_kill = builder_->makeNewBlock();
|
||||
spv::Block& block_kill_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_kill_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_kill_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(kill_pixel, &block_kill,
|
||||
&block_kill_merge);
|
||||
builder_->setBuildPoint(&block_kill);
|
||||
|
@ -500,8 +500,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
spv::Block& block_fsi_rt_0_alpha_tests_rt_written =
|
||||
builder_->makeNewBlock();
|
||||
block_fsi_rt_0_alpha_tests_rt_written_merge = &builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(
|
||||
block_fsi_rt_0_alpha_tests_rt_written_merge->getId(),
|
||||
builder_->createSelectionMerge(
|
||||
block_fsi_rt_0_alpha_tests_rt_written_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> rt_0_written_branch_conditional_op =
|
||||
|
@ -538,8 +538,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
builder_->makeUintConstant(uint32_t(xenos::CompareFunction::kAlways)));
|
||||
spv::Block& block_alpha_test = builder_->makeNewBlock();
|
||||
spv::Block& block_alpha_test_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_alpha_test_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_alpha_test_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(alpha_test_function_is_non_always,
|
||||
&block_alpha_test,
|
||||
&block_alpha_test_merge);
|
||||
|
@ -571,8 +571,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
spv::Block& block_alpha_test_not_equal = builder_->makeNewBlock();
|
||||
spv::Block& block_alpha_test_non_not_equal = builder_->makeNewBlock();
|
||||
spv::Block& block_alpha_test_not_equal_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_alpha_test_not_equal_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_alpha_test_not_equal_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(alpha_test_function_is_not_equal,
|
||||
&block_alpha_test_not_equal,
|
||||
&block_alpha_test_non_not_equal);
|
||||
|
@ -631,8 +631,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
// since SPIR-V requires structured control flow in shaders.
|
||||
spv::Block& block_alpha_test_kill = builder_->makeNewBlock();
|
||||
spv::Block& block_alpha_test_kill_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_alpha_test_kill_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_alpha_test_kill_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(alpha_test_result,
|
||||
&block_alpha_test_kill_merge,
|
||||
&block_alpha_test_kill);
|
||||
|
@ -707,8 +707,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
spv::OpINotEqual, type_bool_, main_fsi_sample_mask_, const_uint_0_);
|
||||
block_fsi_if_after_kill = &builder_->makeNewBlock();
|
||||
block_fsi_if_after_kill_merge = &builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_fsi_if_after_kill_merge->getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(block_fsi_if_after_kill_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(pixel_not_killed,
|
||||
block_fsi_if_after_kill,
|
||||
block_fsi_if_after_kill_merge);
|
||||
|
@ -729,8 +729,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
builder_->makeNewBlock();
|
||||
spv::Block& block_sample_late_depth_stencil_write_merge =
|
||||
builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(
|
||||
block_sample_late_depth_stencil_write_merge.getId(),
|
||||
builder_->createSelectionMerge(
|
||||
&block_sample_late_depth_stencil_write_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(
|
||||
sample_late_depth_stencil_write_needed,
|
||||
|
@ -790,8 +790,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
// Skip all color operations if the pixel has failed the tests entirely.
|
||||
block_fsi_if_after_depth_stencil = &builder_->makeNewBlock();
|
||||
block_fsi_if_after_depth_stencil_merge = &builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_fsi_if_after_depth_stencil_merge->getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(block_fsi_if_after_depth_stencil_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(color_write_depth_stencil_condition,
|
||||
block_fsi_if_after_depth_stencil,
|
||||
block_fsi_if_after_depth_stencil_merge);
|
||||
|
@ -856,8 +856,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
spv::Block& fsi_color_written_if_head = *builder_->getBuildPoint();
|
||||
spv::Block& fsi_color_written_if = builder_->makeNewBlock();
|
||||
spv::Block& fsi_color_written_if_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(fsi_color_written_if_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&fsi_color_written_if_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> rt_written_branch_conditional_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpBranchConditional);
|
||||
|
@ -917,8 +917,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
const_uint32_max));
|
||||
spv::Block& rt_write_mask_not_empty_if = builder_->makeNewBlock();
|
||||
spv::Block& rt_write_mask_not_empty_if_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(rt_write_mask_not_empty_if_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&rt_write_mask_not_empty_if_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(rt_write_mask_not_empty,
|
||||
&rt_write_mask_not_empty_if,
|
||||
&rt_write_mask_not_empty_if_merge);
|
||||
|
@ -986,8 +986,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
spv::Block& rt_blend_enabled_if = builder_->makeNewBlock();
|
||||
spv::Block& rt_blend_enabled_else = builder_->makeNewBlock();
|
||||
spv::Block& rt_blend_enabled_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(rt_blend_enabled_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&rt_blend_enabled_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(
|
||||
rt_blend_enabled, &rt_blend_enabled_if, &rt_blend_enabled_else);
|
||||
|
||||
|
@ -1100,8 +1100,9 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
for (uint32_t i = 0; i < 4; ++i) {
|
||||
spv::Block& block_sample_covered = builder_->makeNewBlock();
|
||||
spv::Block& block_sample_covered_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_sample_covered_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(
|
||||
&block_sample_covered_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(fsi_samples_covered[i],
|
||||
&block_sample_covered,
|
||||
&block_sample_covered_merge);
|
||||
|
@ -1134,8 +1135,9 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
spv::Block& block_load_64bpp_head = *builder_->getBuildPoint();
|
||||
spv::Block& block_load_64bpp = builder_->makeNewBlock();
|
||||
spv::Block& block_load_64bpp_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_load_64bpp_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(
|
||||
&block_load_64bpp_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(rt_is_64bpp, &block_load_64bpp,
|
||||
&block_load_64bpp_merge);
|
||||
builder_->setBuildPoint(&block_load_64bpp);
|
||||
|
@ -1204,8 +1206,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
rt_access_chain_0);
|
||||
spv::Block& block_store_64bpp = builder_->makeNewBlock();
|
||||
spv::Block& block_store_64bpp_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_store_64bpp_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(
|
||||
&block_store_64bpp_merge, spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(rt_is_64bpp, &block_store_64bpp,
|
||||
&block_store_64bpp_merge);
|
||||
builder_->setBuildPoint(&block_store_64bpp);
|
||||
|
@ -1247,8 +1249,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
spv::Block& rt_keep_mask_not_empty_if_else = builder_->makeNewBlock();
|
||||
spv::Block& rt_keep_mask_not_empty_if_merge =
|
||||
builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(rt_keep_mask_not_empty_if_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&rt_keep_mask_not_empty_if_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(rt_keep_mask_not_empty,
|
||||
&rt_keep_mask_not_empty_if,
|
||||
&rt_keep_mask_not_empty_if_else);
|
||||
|
@ -1266,8 +1268,9 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
for (uint32_t i = 0; i < 4; ++i) {
|
||||
spv::Block& block_sample_covered = builder_->makeNewBlock();
|
||||
spv::Block& block_sample_covered_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_sample_covered_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(
|
||||
&block_sample_covered_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(fsi_samples_covered[i],
|
||||
&block_sample_covered,
|
||||
&block_sample_covered_merge);
|
||||
|
@ -1295,8 +1298,9 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
rt_access_chain_0);
|
||||
spv::Block& block_store_64bpp = builder_->makeNewBlock();
|
||||
spv::Block& block_store_64bpp_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_store_64bpp_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(
|
||||
&block_store_64bpp_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(rt_is_64bpp, &block_store_64bpp,
|
||||
&block_store_64bpp_merge);
|
||||
builder_->setBuildPoint(&block_store_64bpp);
|
||||
|
@ -1331,8 +1335,9 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
for (uint32_t i = 0; i < 4; ++i) {
|
||||
spv::Block& block_sample_covered = builder_->makeNewBlock();
|
||||
spv::Block& block_sample_covered_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_sample_covered_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(
|
||||
&block_sample_covered_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(fsi_samples_covered[i],
|
||||
&block_sample_covered,
|
||||
&block_sample_covered_merge);
|
||||
|
@ -1351,8 +1356,9 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
buffer_edram_, id_vector_temp_));
|
||||
spv::Block& block_store_64bpp = builder_->makeNewBlock();
|
||||
spv::Block& block_store_64bpp_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_store_64bpp_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(
|
||||
&block_store_64bpp_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(rt_is_64bpp, &block_store_64bpp,
|
||||
&block_store_64bpp_merge);
|
||||
builder_->setBuildPoint(&block_store_64bpp);
|
||||
|
@ -1403,7 +1409,8 @@ void SpirvShaderTranslator::CompleteFragmentShaderInMain() {
|
|||
spv::Block& block_gamma_head = *builder_->getBuildPoint();
|
||||
spv::Block& block_gamma = builder_->makeNewBlock();
|
||||
spv::Block& block_gamma_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_gamma_merge.getId());
|
||||
builder_->createSelectionMerge(&block_gamma_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(is_gamma, &block_gamma,
|
||||
&block_gamma_merge);
|
||||
builder_->setBuildPoint(&block_gamma);
|
||||
|
@ -1491,7 +1498,8 @@ void SpirvShaderTranslator::FSI_LoadSampleMask(spv::Id msaa_samples) {
|
|||
spv::Block& block_msaa_2x = builder_->makeNewBlock();
|
||||
spv::Block& block_msaa_4x = builder_->makeNewBlock();
|
||||
spv::Block& block_msaa_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_msaa_merge.getId());
|
||||
builder_->createSelectionMerge(&block_msaa_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> msaa_switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
@ -1754,8 +1762,8 @@ void SpirvShaderTranslator::FSI_DepthStencilTest(
|
|||
spv::Block& block_depth_stencil_enabled_head = *builder_->getBuildPoint();
|
||||
spv::Block& block_depth_stencil_enabled = builder_->makeNewBlock();
|
||||
spv::Block& block_depth_stencil_enabled_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_depth_stencil_enabled_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_depth_stencil_enabled_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(depth_stencil_enabled,
|
||||
&block_depth_stencil_enabled,
|
||||
&block_depth_stencil_enabled_merge);
|
||||
|
@ -1788,8 +1796,8 @@ void SpirvShaderTranslator::FSI_DepthStencilTest(
|
|||
block_any_sample_covered_head = builder_->getBuildPoint();
|
||||
block_any_sample_covered = &builder_->makeNewBlock();
|
||||
block_any_sample_covered_merge = &builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_any_sample_covered_merge->getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(block_any_sample_covered_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(any_sample_covered,
|
||||
block_any_sample_covered,
|
||||
block_any_sample_covered_merge);
|
||||
|
@ -1986,8 +1994,8 @@ void SpirvShaderTranslator::FSI_DepthStencilTest(
|
|||
spv::Block& block_sample_covered_head = *builder_->getBuildPoint();
|
||||
spv::Block& block_sample_covered = builder_->makeNewBlock();
|
||||
spv::Block& block_sample_covered_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_sample_covered_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_sample_covered_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(sample_covered, &block_sample_covered,
|
||||
&block_sample_covered_merge);
|
||||
builder_->setBuildPoint(&block_sample_covered);
|
||||
|
@ -2090,8 +2098,8 @@ void SpirvShaderTranslator::FSI_DepthStencilTest(
|
|||
spv::Block& block_depth_format_float = builder_->makeNewBlock();
|
||||
spv::Block& block_depth_format_unorm = builder_->makeNewBlock();
|
||||
spv::Block& block_depth_format_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_depth_format_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_depth_format_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(
|
||||
depth_is_float24, &block_depth_format_float, &block_depth_format_unorm);
|
||||
// Float24 case.
|
||||
|
@ -2151,8 +2159,8 @@ void SpirvShaderTranslator::FSI_DepthStencilTest(
|
|||
spv::Block& block_stencil_enabled_head = *builder_->getBuildPoint();
|
||||
spv::Block& block_stencil_enabled = builder_->makeNewBlock();
|
||||
spv::Block& block_stencil_enabled_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_stencil_enabled_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_stencil_enabled_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(stencil_enabled, &block_stencil_enabled,
|
||||
&block_stencil_enabled_merge);
|
||||
builder_->setBuildPoint(&block_stencil_enabled);
|
||||
|
@ -2200,8 +2208,8 @@ void SpirvShaderTranslator::FSI_DepthStencilTest(
|
|||
spv::Block& block_stencil_op_increment_wrap = builder_->makeNewBlock();
|
||||
spv::Block& block_stencil_op_decrement_wrap = builder_->makeNewBlock();
|
||||
spv::Block& block_stencil_op_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_stencil_op_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_stencil_op_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> stencil_op_switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
@ -2409,8 +2417,8 @@ void SpirvShaderTranslator::FSI_DepthStencilTest(
|
|||
if (new_depth_stencil_write_condition != spv::NoResult) {
|
||||
spv::Block& block_depth_stencil_write = builder_->makeNewBlock();
|
||||
spv::Block& block_depth_stencil_write_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_depth_stencil_write_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_depth_stencil_write_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(new_depth_stencil_write_condition,
|
||||
&block_depth_stencil_write,
|
||||
&block_depth_stencil_write_merge);
|
||||
|
@ -2499,7 +2507,8 @@ std::array<spv::Id, 2> SpirvShaderTranslator::FSI_ClampAndPackColor(
|
|||
spv::Block& block_format_16_float = builder_->makeNewBlock();
|
||||
spv::Block& block_format_32_float = builder_->makeNewBlock();
|
||||
spv::Block& block_format_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_format_merge.getId());
|
||||
builder_->createSelectionMerge(&block_format_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> format_switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
@ -2939,7 +2948,8 @@ std::array<spv::Id, 4> SpirvShaderTranslator::FSI_UnpackColor(
|
|||
spv::Block& block_format_32_float = builder_->makeNewBlock();
|
||||
spv::Block& block_format_32_32_float = builder_->makeNewBlock();
|
||||
spv::Block& block_format_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_format_merge.getId());
|
||||
builder_->createSelectionMerge(&block_format_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> format_switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
@ -3247,8 +3257,8 @@ spv::Id SpirvShaderTranslator::FSI_FlushNaNClampAndInBlending(
|
|||
spv::Block& block_is_fixed_point_head = *builder_->getBuildPoint();
|
||||
spv::Block& block_is_fixed_point_if = builder_->makeNewBlock();
|
||||
spv::Block& block_is_fixed_point_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_is_fixed_point_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_is_fixed_point_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(is_fixed_point, &block_is_fixed_point_if,
|
||||
&block_is_fixed_point_merge);
|
||||
builder_->setBuildPoint(&block_is_fixed_point_if);
|
||||
|
@ -3290,7 +3300,8 @@ spv::Id SpirvShaderTranslator::FSI_ApplyColorBlendFactor(
|
|||
spv::Block& block_not_zero_head = *builder_->getBuildPoint();
|
||||
spv::Block& block_not_zero_if = builder_->makeNewBlock();
|
||||
spv::Block& block_not_zero_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_not_zero_merge.getId());
|
||||
builder_->createSelectionMerge(&block_not_zero_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(factor_not_zero, &block_not_zero_if,
|
||||
&block_not_zero_merge);
|
||||
|
||||
|
@ -3318,8 +3329,8 @@ spv::Id SpirvShaderTranslator::FSI_ApplyColorBlendFactor(
|
|||
one_minus_alpha_factor_blocks[2] = &builder_->makeNewBlock();
|
||||
spv::Block& block_factor_source_alpha_saturate = builder_->makeNewBlock();
|
||||
spv::Block& block_factor_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_factor_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_factor_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> factor_switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
@ -3522,7 +3533,8 @@ spv::Id SpirvShaderTranslator::FSI_ApplyAlphaBlendFactor(
|
|||
spv::Block& block_not_zero_head = *builder_->getBuildPoint();
|
||||
spv::Block& block_not_zero_if = builder_->makeNewBlock();
|
||||
spv::Block& block_not_zero_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_not_zero_merge.getId());
|
||||
builder_->createSelectionMerge(&block_not_zero_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createConditionalBranch(factor_not_zero, &block_not_zero_if,
|
||||
&block_not_zero_merge);
|
||||
|
||||
|
@ -3542,8 +3554,8 @@ spv::Id SpirvShaderTranslator::FSI_ApplyAlphaBlendFactor(
|
|||
one_minus_alpha_factor_blocks[2] = &builder_->makeNewBlock();
|
||||
spv::Block& block_factor_source_alpha_saturate = builder_->makeNewBlock();
|
||||
spv::Block& block_factor_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_factor_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_factor_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> factor_switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
@ -3710,8 +3722,8 @@ spv::Id SpirvShaderTranslator::FSI_BlendColorOrAlphaWithUnclampedResult(
|
|||
spv::Block& block_min_max_max = builder_->makeNewBlock();
|
||||
spv::Block& block_min_max_default = builder_->makeNewBlock();
|
||||
spv::Block& block_min_max_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_min_max_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_min_max_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> min_max_switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
@ -3779,8 +3791,8 @@ spv::Id SpirvShaderTranslator::FSI_BlendColorOrAlphaWithUnclampedResult(
|
|||
spv::Block& block_signs_subtract = builder_->makeNewBlock();
|
||||
spv::Block& block_signs_reverse_subtract = builder_->makeNewBlock();
|
||||
spv::Block& block_signs_merge = builder_->makeNewBlock();
|
||||
SpirvCreateSelectionMerge(block_signs_merge.getId(),
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
builder_->createSelectionMerge(&block_signs_merge,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> signs_switch_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSwitch);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <vector>
|
||||
|
||||
#include "third_party/fmt/include/fmt/format.h"
|
||||
#include "third_party/glslang/SPIRV/SpvBuilder.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
@ -28,6 +27,7 @@
|
|||
#include "xenia/gpu/gpu_flags.h"
|
||||
#include "xenia/gpu/register_file.h"
|
||||
#include "xenia/gpu/registers.h"
|
||||
#include "xenia/gpu/spirv_builder.h"
|
||||
#include "xenia/gpu/spirv_shader_translator.h"
|
||||
#include "xenia/gpu/vulkan/vulkan_command_processor.h"
|
||||
#include "xenia/gpu/vulkan/vulkan_shader.h"
|
||||
|
@ -952,7 +952,7 @@ VkShaderModule VulkanPipelineCache::GetGeometryShader(GeometryShaderKey key) {
|
|||
(key.user_clip_plane_cull ? key.user_clip_plane_count : 0) +
|
||||
key.has_vertex_kill_and;
|
||||
|
||||
spv::Builder builder(spv::Spv_1_0,
|
||||
SpirvBuilder builder(spv::Spv_1_0,
|
||||
(SpirvShaderTranslator::kSpirvMagicToolId << 16) | 1,
|
||||
nullptr);
|
||||
spv::Id ext_inst_glsl_std_450 = builder.import("GLSL.std.450");
|
||||
|
@ -1233,14 +1233,8 @@ VkShaderModule VulkanPipelineCache::GetGeometryShader(GeometryShaderKey key) {
|
|||
spv::Block& discard_predecessor = *builder.getBuildPoint();
|
||||
spv::Block& discard_then_block = builder.makeNewBlock();
|
||||
spv::Block& discard_merge_block = builder.makeNewBlock();
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> selection_merge_op(
|
||||
std::make_unique<spv::Instruction>(spv::OpSelectionMerge));
|
||||
selection_merge_op->addIdOperand(discard_merge_block.getId());
|
||||
selection_merge_op->addImmediateOperand(
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
discard_predecessor.addInstruction(std::move(selection_merge_op));
|
||||
}
|
||||
builder.createSelectionMerge(&discard_merge_block,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> branch_conditional_op(
|
||||
std::make_unique<spv::Instruction>(spv::OpBranchConditional));
|
||||
|
@ -1295,14 +1289,8 @@ VkShaderModule VulkanPipelineCache::GetGeometryShader(GeometryShaderKey key) {
|
|||
spv::Block& discard_predecessor = *builder.getBuildPoint();
|
||||
spv::Block& discard_then_block = builder.makeNewBlock();
|
||||
spv::Block& discard_merge_block = builder.makeNewBlock();
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> selection_merge_op(
|
||||
std::make_unique<spv::Instruction>(spv::OpSelectionMerge));
|
||||
selection_merge_op->addIdOperand(discard_merge_block.getId());
|
||||
selection_merge_op->addImmediateOperand(
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
discard_predecessor.addInstruction(std::move(selection_merge_op));
|
||||
}
|
||||
builder.createSelectionMerge(&discard_merge_block,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> branch_conditional_op(
|
||||
std::make_unique<spv::Instruction>(spv::OpBranchConditional));
|
||||
|
@ -1378,15 +1366,8 @@ VkShaderModule VulkanPipelineCache::GetGeometryShader(GeometryShaderKey key) {
|
|||
spv::Block& point_size_zero_predecessor = *builder.getBuildPoint();
|
||||
spv::Block& point_size_zero_then_block = builder.makeNewBlock();
|
||||
spv::Block& point_size_zero_merge_block = builder.makeNewBlock();
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> selection_merge_op(
|
||||
std::make_unique<spv::Instruction>(spv::OpSelectionMerge));
|
||||
selection_merge_op->addIdOperand(point_size_zero_merge_block.getId());
|
||||
selection_merge_op->addImmediateOperand(
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
point_size_zero_predecessor.addInstruction(
|
||||
std::move(selection_merge_op));
|
||||
}
|
||||
builder.createSelectionMerge(&point_size_zero_merge_block,
|
||||
spv::SelectionControlDontFlattenMask);
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> branch_conditional_op(
|
||||
std::make_unique<spv::Instruction>(spv::OpBranchConditional));
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
#include <vector>
|
||||
|
||||
#include "third_party/glslang/SPIRV/GLSL.std.450.h"
|
||||
#include "third_party/glslang/SPIRV/SpvBuilder.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/cvar.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/gpu/draw_util.h"
|
||||
#include "xenia/gpu/registers.h"
|
||||
#include "xenia/gpu/spirv_builder.h"
|
||||
#include "xenia/gpu/spirv_shader_translator.h"
|
||||
#include "xenia/gpu/texture_cache.h"
|
||||
#include "xenia/gpu/vulkan/deferred_command_buffer.h"
|
||||
|
@ -2166,7 +2166,7 @@ VkShaderModule VulkanRenderTargetCache::GetTransferShader(
|
|||
std::vector<spv::Id> id_vector_temp;
|
||||
std::vector<unsigned int> uint_vector_temp;
|
||||
|
||||
spv::Builder builder(spv::Spv_1_0,
|
||||
SpirvBuilder builder(spv::Spv_1_0,
|
||||
(SpirvShaderTranslator::kSpirvMagicToolId << 16) | 1,
|
||||
nullptr);
|
||||
spv::Id ext_inst_glsl_std_450 = builder.import("GLSL.std.450");
|
||||
|
@ -4213,16 +4213,8 @@ VkShaderModule VulkanRenderTargetCache::GetTransferShader(
|
|||
builder.makeNewBlock();
|
||||
depth24_to_depth32_merge = &depth24_to_depth32_merge_block;
|
||||
}
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> depth24_to_depth32_merge_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSelectionMerge);
|
||||
depth24_to_depth32_merge_op->addIdOperand(
|
||||
depth24_to_depth32_merge->getId());
|
||||
depth24_to_depth32_merge_op->addImmediateOperand(
|
||||
spv::SelectionControlMaskNone);
|
||||
builder.getBuildPoint()->addInstruction(
|
||||
std::move(depth24_to_depth32_merge_op));
|
||||
}
|
||||
builder.createSelectionMerge(depth24_to_depth32_merge,
|
||||
spv::SelectionControlMaskNone);
|
||||
builder.createConditionalBranch(host_depth_outdated,
|
||||
&depth24_to_depth32_convert_entry,
|
||||
depth24_to_depth32_merge);
|
||||
|
@ -4304,15 +4296,8 @@ VkShaderModule VulkanRenderTargetCache::GetTransferShader(
|
|||
builder.makeUintConstant(0));
|
||||
spv::Block& stencil_bit_kill_block = builder.makeNewBlock();
|
||||
spv::Block& stencil_bit_merge_block = builder.makeNewBlock();
|
||||
{
|
||||
std::unique_ptr<spv::Instruction> stencil_bit_merge_op =
|
||||
std::make_unique<spv::Instruction>(spv::OpSelectionMerge);
|
||||
stencil_bit_merge_op->addIdOperand(stencil_bit_merge_block.getId());
|
||||
stencil_bit_merge_op->addImmediateOperand(
|
||||
spv::SelectionControlMaskNone);
|
||||
builder.getBuildPoint()->addInstruction(
|
||||
std::move(stencil_bit_merge_op));
|
||||
}
|
||||
builder.createSelectionMerge(&stencil_bit_merge_block,
|
||||
spv::SelectionControlMaskNone);
|
||||
builder.createConditionalBranch(stencil_sample_passed,
|
||||
&stencil_bit_merge_block,
|
||||
&stencil_bit_kill_block);
|
||||
|
@ -5582,7 +5567,7 @@ VkPipeline VulkanRenderTargetCache::GetDumpPipeline(DumpPipelineKey key) {
|
|||
|
||||
std::vector<spv::Id> id_vector_temp;
|
||||
|
||||
spv::Builder builder(spv::Spv_1_0,
|
||||
SpirvBuilder builder(spv::Spv_1_0,
|
||||
(SpirvShaderTranslator::kSpirvMagicToolId << 16) | 1,
|
||||
nullptr);
|
||||
spv::Id ext_inst_glsl_std_450 = builder.import("GLSL.std.450");
|
||||
|
|
Loading…
Reference in New Issue