X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fspirv.h;h=6971e2a9c43eb2ec8cc180b94043a6388229858e;hb=6f06479b765946bdd3174b2c05e7a1dda24c31c2;hp=21f0ed5331c531c40455cdc5ae7d279f92ef1755;hpb=cc5483cc709fdf7b6966a3e69dabfcafebaaffa0;p=libs%2Fgl.git diff --git a/source/glsl/spirv.h b/source/glsl/spirv.h index 21f0ed53..6971e2a9 100644 --- a/source/glsl/spirv.h +++ b/source/glsl/spirv.h @@ -1,5 +1,5 @@ -#ifndef MSP_GL_SL_SPIRV -#define MSP_GL_SL_SPIRV +#ifndef MSP_GL_SL_SPIRV_H_ +#define MSP_GL_SL_SPIRV_H_ #include #include @@ -30,7 +30,8 @@ private: char arg_types[5]; char extension[13]; Word opcode; - UInt8 arg_order[4]; + std::uint8_t arg_order[4]; + Word capability; void (SpirVGenerator::*handler)(FunctionCall &, const std::vector &); }; @@ -48,6 +49,7 @@ private: unsigned detail; TypeKey(Id i, unsigned d): type_id(i), detail(d) { } + TypeKey(BasicTypeDeclaration::Kind, bool); bool operator<(const TypeKey &) const; }; @@ -62,13 +64,14 @@ private: }; ConstantKey(Id t, int i): type_id(t), int_value(i) { } + ConstantKey(Id t, unsigned u): type_id(t), int_value(u) { } ConstantKey(Id t, float f): type_id(t), float_value(f) { } bool operator<(const ConstantKey &) const; }; - Stage *stage; - FunctionDeclaration *current_function; + Stage *stage = 0; + FunctionDeclaration *current_function = 0; std::vector interface_layouts; SpirVContent content; SpirVWriter writer; @@ -77,23 +80,25 @@ private: std::map declared_ids; std::map declared_uniform_ids; std::map standard_type_ids; + std::map image_type_ids; std::map array_type_ids; std::map pointer_type_ids; std::map function_type_ids; std::map constant_ids; std::map variable_load_ids; - Id next_id; - Id r_expression_result_id; - bool constant_expression; - bool spec_constant; - bool reachable; - bool composite_access; - Id r_composite_base_id; - Node *r_composite_base; + Id next_id = 1; + Id r_expression_result_id = 0; + bool r_constant_result = false; + bool constant_expression = false; + bool spec_constant = false; + bool reachable = false; + bool composite_access = false; + Id r_composite_base_id = 0; + Node *r_composite_base = 0; std::vector r_composite_chain; - Id assignment_source_id; - Id loop_merge_block_id; - Id loop_continue_target_id; + Id assignment_source_id = 0; + Id loop_merge_block_id = 0; + Id loop_continue_target_id = 0; static const BuiltinFunctionInfo builtin_functions[]; @@ -110,11 +115,12 @@ private: Id import_extension(const std::string &); Id get_id(Node &) const; Id allocate_id(Node &, Id); + Id allocate_forward_id(Node &); Id write_constant(Id, Word, bool); static ConstantKey get_constant_key(Id, const Variant &value); Id get_constant_id(Id, const Variant &value); Id get_vector_constant_id(Id, unsigned, Id); - Id get_standard_type_id(BasicTypeDeclaration::Kind, unsigned); + Id get_standard_type_id(BasicTypeDeclaration::Kind, unsigned, bool = true); bool is_scalar_type(Id, BasicTypeDeclaration::Kind) const; Id get_array_type_id(TypeDeclaration &, unsigned); Id get_pointer_type_id(Id, StorageClass); @@ -127,7 +133,6 @@ private: Id write_expression(Opcode, Id, Id, Id); void write_deconstruct(Id, Id, Id *, unsigned); Id write_construct(Id, const Id *, unsigned); - static BasicTypeDeclaration &get_element_type(BasicTypeDeclaration &); virtual void visit(Block &); virtual void visit(Literal &); @@ -143,8 +148,9 @@ private: virtual void visit(Assignment &); virtual void visit(TernaryExpression &); virtual void visit(FunctionCall &); - void visit_constructor(FunctionCall &, const std::vector &); + void visit_constructor(FunctionCall &, const std::vector &, bool); void visit_builtin_matrix_comp_mult(FunctionCall &, const std::vector &); + void visit_builtin_texture_query(FunctionCall &, const std::vector &); void visit_builtin_texture(FunctionCall &, const std::vector &); void visit_builtin_texel_fetch(FunctionCall &, const std::vector &); void visit_builtin_interpolate(FunctionCall &, const std::vector &);