Mostly complete new GLSL translator (modulo flow control).
This commit is contained in:
79
src/xenia/gpu/glsl_shader_translator.h
Normal file
79
src/xenia/gpu/glsl_shader_translator.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_GPU_GLSL_SHADER_TRANSLATOR_H_
|
||||
#define XENIA_GPU_GLSL_SHADER_TRANSLATOR_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/string_buffer.h"
|
||||
#include "xenia/gpu/shader_translator.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
class GlslShaderTranslator : public ShaderTranslator {
|
||||
public:
|
||||
enum class Dialect {
|
||||
kGL45,
|
||||
};
|
||||
|
||||
GlslShaderTranslator(Dialect dialect);
|
||||
~GlslShaderTranslator() override;
|
||||
|
||||
protected:
|
||||
void EmitTranslationError(const char* message) override;
|
||||
void EmitUnimplementedTranslationError() override;
|
||||
|
||||
void StartTranslation() override;
|
||||
std::vector<uint8_t> CompleteTranslation() override;
|
||||
|
||||
void ProcessLabel(uint32_t cf_index) override;
|
||||
void ProcessControlFlowNopInstruction() 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;
|
||||
void ProcessVertexFetchInstruction(
|
||||
const ParsedVertexFetchInstruction& instr) override;
|
||||
void ProcessTextureFetchInstruction(
|
||||
const ParsedTextureFetchInstruction& instr) override;
|
||||
void ProcessAluInstruction(const ParsedAluInstruction& instr) override;
|
||||
|
||||
private:
|
||||
void Indent();
|
||||
void Unindent();
|
||||
|
||||
void EmitLoadOperand(size_t i, const InstructionOperand& op);
|
||||
void EmitStoreVectorResult(const InstructionResult& result);
|
||||
void EmitStoreScalarResult(const InstructionResult& result);
|
||||
void EmitStoreResult(const InstructionResult& result, const char* temp);
|
||||
|
||||
Dialect dialect_;
|
||||
|
||||
StringBuffer source_;
|
||||
int depth_ = 0;
|
||||
char depth_prefix_[16] = {0};
|
||||
|
||||
void ProcessVectorAluInstruction(const ParsedAluInstruction& instr);
|
||||
void ProcessScalarAluInstruction(const ParsedAluInstruction& instr);
|
||||
};
|
||||
|
||||
} // namespace gpu
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_GPU_GLSL_SHADER_TRANSLATOR_H_
|
||||
Reference in New Issue
Block a user