From: Travis Fort Date: Thu, 5 Mar 2020 21:05:07 +0000 (-0500) Subject: add c interface support for TBuiltInResource and glslang::DefaultTBuiltInResource X-Git-Tag: upstream/11.4.0~294^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bdcfc484660915c110c9e225fec69a00f6cc7b54;p=platform%2Fupstream%2Fglslang.git add c interface support for TBuiltInResource and glslang::DefaultTBuiltInResource --- diff --git a/glslang/CInterface/glslang_c_interface.cpp b/glslang/CInterface/glslang_c_interface.cpp index a05068d..59d509b 100644 --- a/glslang/CInterface/glslang_c_interface.cpp +++ b/glslang/CInterface/glslang_c_interface.cpp @@ -54,6 +54,8 @@ static_assert(int(GLSLANG_TEX_SAMP_TRANS_COUNT) == EShTexSampTransCount, ""); static_assert(int(GLSLANG_MSG_COUNT) == EShMsgCount, ""); static_assert(int(GLSLANG_REFLECTION_COUNT) == EShReflectionCount, ""); static_assert(int(GLSLANG_PROFILE_COUNT) == EProfileCount, ""); +static_assert(sizeof(glslang_limits_t) == sizeof(TLimits), ""); +static_assert(sizeof(glslang_resource_t) == sizeof(TBuiltInResource), ""); typedef struct glslang_shader_s { glslang::TShader* shader; @@ -165,6 +167,11 @@ int glslang_initialize_process() { return static_cast(glslang::InitializePr void glslang_finalize_process() { glslang::FinalizeProcess(); } +const glslang_resource_t* glslang_default_resource(void) +{ + return reinterpret_cast(&glslang::DefaultTBuiltInResource); +} + static EShLanguage c_shader_stage(glslang_stage_t stage) { switch (stage) { @@ -355,7 +362,7 @@ int glslang_shader_preprocess(glslang_shader_t* shader, const glslang_input_t* i DirStackFileIncluder Includer; /* TODO: use custom callbacks if they are available in 'i->callbacks' */ return shader->shader->preprocess( - input->resource, + reinterpret_cast(input->resource), input->default_version, c_shader_profile(input->default_profile), input->force_default_version_and_profile != 0, @@ -372,7 +379,7 @@ int glslang_shader_parse(glslang_shader_t* shader, const glslang_input_t* input) shader->shader->setStrings(&preprocessedCStr, 1); return shader->shader->parse( - input->resource, + reinterpret_cast(input->resource), input->default_version, input->forward_compatible != 0, (EShMessages)c_shader_messages(input->messages) diff --git a/glslang/Include/glslang_c_interface.h b/glslang/Include/glslang_c_interface.h index 11036be..05c707e 100644 --- a/glslang/Include/glslang_c_interface.h +++ b/glslang/Include/glslang_c_interface.h @@ -39,7 +39,117 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. typedef struct glslang_shader_s glslang_shader_t; typedef struct glslang_program_s glslang_program_t; -typedef struct TBuiltInResource glslang_resource_t; + +/* TLimits counterpart */ +typedef struct glslang_limits_s { + bool non_inductive_for_loops; + bool while_loops; + bool do_while_loops; + bool general_uniform_indexing; + bool general_attribute_matrix_vector_indexing; + bool general_varying_indexing; + bool general_sampler_indexing; + bool general_variable_indexing; + bool general_constant_matrix_vector_indexing; +} glslang_limits_t; + +/* TBuiltInResource counterpart */ +typedef struct glslang_resource_s { + int max_lights; + int max_clip_planes; + int max_texture_units; + int max_texture_coords; + int max_vertex_attribs; + int max_vertex_uniform_components; + int max_varying_floats; + int max_vertex_texture_image_units; + int max_combined_texture_image_units; + int max_texture_image_units; + int max_fragment_uniform_components; + int max_draw_buffers; + int max_vertex_uniform_vectors; + int max_varying_vectors; + int max_fragment_uniform_vectors; + int max_vertex_output_vectors; + int max_fragment_input_vectors; + int min_program_texel_offset; + int max_program_texel_offset; + int max_clip_distances; + int max_compute_work_group_count_x; + int max_compute_work_group_count_y; + int max_compute_work_group_count_z; + int max_compute_work_group_size_x; + int max_compute_work_group_size_y; + int max_compute_work_group_size_z; + int max_compute_uniform_components; + int max_compute_texture_image_units; + int max_compute_image_uniforms; + int max_compute_atomic_counters; + int max_compute_atomic_counter_buffers; + int max_varying_components; + int max_vertex_output_components; + int max_geometry_input_components; + int max_geometry_output_components; + int max_fragment_input_components; + int max_image_units; + int max_combined_image_units_and_fragment_outputs; + int max_combined_shader_output_resources; + int max_image_samples; + int max_vertex_image_uniforms; + int max_tess_control_image_uniforms; + int max_tess_evaluation_image_uniforms; + int max_geometry_image_uniforms; + int max_fragment_image_uniforms; + int max_combined_image_uniforms; + int max_geometry_texture_image_units; + int max_geometry_output_vertices; + int max_geometry_total_output_components; + int max_geometry_uniform_components; + int max_geometry_varying_components; + int max_tess_control_input_components; + int max_tess_control_output_components; + int max_tess_control_texture_image_units; + int max_tess_control_uniform_components; + int max_tess_control_total_output_components; + int max_tess_evaluation_input_components; + int max_tess_evaluation_output_components; + int max_tess_evaluation_texture_image_units; + int max_tess_evaluation_uniform_components; + int max_tess_patch_components; + int max_patch_vertices; + int max_tess_gen_level; + int max_viewports; + int max_vertex_atomic_counters; + int max_tess_control_atomic_counters; + int max_tess_evaluation_atomic_counters; + int max_geometry_atomic_counters; + int max_fragment_atomic_counters; + int max_combined_atomic_counters; + int max_atomic_counter_bindings; + int max_vertex_atomic_counter_buffers; + int max_tess_control_atomic_counter_buffers; + int max_tess_evaluation_atomic_counter_buffers; + int max_geometry_atomic_counter_buffers; + int max_fragment_atomic_counter_buffers; + int max_combined_atomic_counter_buffers; + int max_atomic_counter_buffer_size; + int max_transform_feedback_buffers; + int max_transform_feedback_interleaved_components; + int max_cull_distances; + int max_combined_clip_and_cull_distances; + int max_samples; + int max_mesh_output_vertices_nv; + int max_mesh_output_primitives_nv; + int max_mesh_work_group_size_x_nv; + int max_mesh_work_group_size_y_nv; + int max_mesh_work_group_size_z_nv; + int max_task_work_group_size_x_nv; + int max_task_work_group_size_y_nv; + int max_task_work_group_size_z_nv; + int max_mesh_view_count_nv; + + glslang_limits_t limits; +} glslang_resource_t; typedef struct glslang_input_s { glslang_source_t language; @@ -94,6 +204,8 @@ extern "C" { int glslang_initialize_process(); void glslang_finalize_process(); +const glslang_resource_t* glslang_default_resource(void); + glslang_shader_t* glslang_shader_create(const glslang_input_t* input); void glslang_shader_delete(glslang_shader_t* shader); int glslang_shader_preprocess(glslang_shader_t* shader, const glslang_input_t* input);