[D3D12] Convert GlslShaderTranslator flow control to HLSL

This commit is contained in:
Triang3l
2018-07-21 23:37:28 +03:00
parent 7afc40820b
commit d60c8b29ca
2 changed files with 237 additions and 8 deletions

View File

@@ -46,6 +46,22 @@ class HlslShaderTranslator : public ShaderTranslator {
void EmitTranslationError(const char* message) override;
void EmitUnimplementedTranslationError() override;
void ProcessLabel(uint32_t cf_index) override;
void ProcessControlFlowNopInstruction(uint32_t cf_index) override;
void ProcessControlFlowInstructionBegin(uint32_t cf_index) override;
void ProcessControlFlowInstructionEnd(uint32_t cf_index) override;
void ProcessExecInstructionBegin(const ParsedExecInstruction& instr) override;
void ProcessExecInstructionEnd(const ParsedExecInstruction& instr) override;
void ProcessLoopStartInstruction(
const ParsedLoopStartInstruction& instr) override;
void ProcessLoopEndInstruction(
const ParsedLoopEndInstruction& instr) override;
void ProcessCallInstruction(const ParsedCallInstruction& instr) override;
void ProcessReturnInstruction(const ParsedReturnInstruction& instr) override;
void ProcessJumpInstruction(const ParsedJumpInstruction& instr) override;
void ProcessAllocInstruction(const ParsedAllocInstruction& instr) override;
private:
void Indent();
void Unindent();
@@ -54,6 +70,10 @@ class HlslShaderTranslator : public ShaderTranslator {
uint32_t depth_ = 0;
char depth_prefix_[16] = {0};
bool cf_wrote_pc_ = false;
bool cf_exec_pred_ = false;
bool cf_exec_pred_cond_ = false;
std::vector<SRVBinding> srv_bindings_;
// Finds or adds an SRV binding to the shader's SRV list, returns t# index.
uint32_t AddSRVBinding(SRVType type, uint32_t fetch_constant);
@@ -64,6 +84,10 @@ class HlslShaderTranslator : public ShaderTranslator {
uint32_t sampler_fetch_constants_[32];
uint32_t sampler_count_ = 0;
uint32_t AddSampler(uint32_t fetch_constant);
// Whether the cube instruction has been used and conversion functions need to
// be emitted.
bool cube_used_ = false;
};
} // namespace gpu