Class ShadercSpvc


  • public class ShadercSpvc
    extends java.lang.Object
    Native bindings to the libshaderc_spvc C API of the shaderc library.
    • Method Detail

      • shaderc_spvc_compiler_initialize

        public static long shaderc_spvc_compiler_initialize()
        Create a compiler.

        A return of NULL indicates that there was an error. Any function operating on a *_compiler_t must offer the basic thread-safety guarantee. That is: concurrent invocation of these functions on DIFFERENT objects needs no synchronization; concurrent invocation of these functions on the SAME object requires synchronization IF AND ONLY IF some of them take a non-const argument.

      • shaderc_spvc_compiler_release

        public static void shaderc_spvc_compiler_release​(long compiler)
        Release resources.

        After this the handle cannot be used.

      • shaderc_spvc_compile_options_initialize

        public static long shaderc_spvc_compile_options_initialize()
        Returns default compiler options.

        A return of NULL indicates that there was an error initializing the options. Any function operating on shaderc_spvc_compile_options_t must offer the basic thread-safety guarantee.

      • shaderc_spvc_compile_options_clone

        public static long shaderc_spvc_compile_options_clone​(long options)
        Returns a copy of the given options.

        If NULL is passed as the parameter the call is the same as compile_options_initialize.

      • shaderc_spvc_compile_options_release

        public static void shaderc_spvc_compile_options_release​(long options)
        Releases the compilation options.

        It is invalid to use the given option object in any future calls. It is safe to pass NULL to this function, and doing such will have no effect.

      • nshaderc_spvc_compile_options_set_entry_point

        public static void nshaderc_spvc_compile_options_set_entry_point​(long options,
                                                                         long entry_point)
      • shaderc_spvc_compile_options_set_entry_point

        public static void shaderc_spvc_compile_options_set_entry_point​(long options,
                                                                        java.nio.ByteBuffer entry_point)
        
        public static void shaderc_spvc_compile_options_set_entry_point​(long options,
                                                                        java.lang.CharSequence entry_point)
        
        Sets the entry point.
      • shaderc_spvc_compile_options_set_remove_unused_variables

        public static void shaderc_spvc_compile_options_set_remove_unused_variables​(long options,
                                                                                    boolean b)
        If true, unused variables will not appear in the output.
      • shaderc_spvc_compile_options_set_robust_buffer_access_pass

        public static void shaderc_spvc_compile_options_set_robust_buffer_access_pass​(long options,
                                                                                      boolean b)
        If true, enable robust buffer access pass in the spirv-opt, meaning:

        Inject code to clamp indexed accesses to buffers and internal arrays, providing guarantees satisfying Vulkan's robustBufferAccess rules. This is useful when an implementation does not support robust-buffer access as a driver option.

      • shaderc_spvc_compile_options_set_source_env

        public static void shaderc_spvc_compile_options_set_source_env​(long options,
                                                                       int env,
                                                                       int version)
        Sets the source shader environment, affecting which warnings or errors will be issued during validation.

        Default value for environment is Vulkan 1.0.

      • shaderc_spvc_compile_options_set_target_env

        public static void shaderc_spvc_compile_options_set_target_env​(long options,
                                                                       int env,
                                                                       int version)
        Sets the target shader environment, if this is different from the source environment, then a transform between the environments will be performed if possible.

        Currently only WebGPU <-> Vulkan 1.1 are defined. Default value for environment is Vulkan 1.0.

      • shaderc_spvc_compile_options_set_vulkan_semantics

        public static void shaderc_spvc_compile_options_set_vulkan_semantics​(long options,
                                                                             boolean b)
        If true, Vulkan GLSL features are used instead of GL-compatible features.
      • shaderc_spvc_compile_options_set_separate_shader_objects

        public static void shaderc_spvc_compile_options_set_separate_shader_objects​(long options,
                                                                                    boolean b)
        If true, gl_PerVertex is explicitly redeclared in vertex, geometry and tessellation shaders.

        The members of gl_PerVertex is determined by which built-ins are declared by the shader.

      • shaderc_spvc_compile_options_set_flatten_ubo

        public static void shaderc_spvc_compile_options_set_flatten_ubo​(long options,
                                                                        boolean b)
        Flatten uniform or push constant variable into (i|u)vec4 array.
      • shaderc_spvc_compile_options_set_glsl_language_version

        public static void shaderc_spvc_compile_options_set_glsl_language_version​(long options,
                                                                                  int version)
        Set GLSL language version.

        Default is 450 (i.e. 4.5).

      • shaderc_spvc_compile_options_set_flatten_multidimensional_arrays

        public static void shaderc_spvc_compile_options_set_flatten_multidimensional_arrays​(long options,
                                                                                            boolean b)
        If true, flatten multidimensional arrays, e.g. foo[a][b][c] -> foo[a*b*c]. Default is false.
      • shaderc_spvc_compile_options_set_es

        public static void shaderc_spvc_compile_options_set_es​(long options,
                                                               boolean b)
        Force interpretion as ES, or not. Default is to detect from source.
      • shaderc_spvc_compile_options_set_glsl_emit_push_constant_as_ubo

        public static void shaderc_spvc_compile_options_set_glsl_emit_push_constant_as_ubo​(long options,
                                                                                           boolean b)
        If true, emit push constants as uniform buffer objects. Default is false.
      • shaderc_spvc_compile_options_set_msl_language_version

        public static void shaderc_spvc_compile_options_set_msl_language_version​(long options,
                                                                                 int version)
        Set MSL language version.

        Default is 10200 (i.e. 1.2).

      • shaderc_spvc_compile_options_set_msl_swizzle_texture_samples

        public static void shaderc_spvc_compile_options_set_msl_swizzle_texture_samples​(long options,
                                                                                        boolean b)
        If true, swizzle MSL texture samples. Default is false.
      • shaderc_spvc_compile_options_set_msl_platform

        public static void shaderc_spvc_compile_options_set_msl_platform​(long options,
                                                                         int platform)
        Choose MSL platform. Default is MacOS.
      • shaderc_spvc_compile_options_set_msl_pad_fragment_output

        public static void shaderc_spvc_compile_options_set_msl_pad_fragment_output​(long options,
                                                                                    boolean b)
        If true, pad MSL fragment output. Default is false.
      • shaderc_spvc_compile_options_set_msl_capture

        public static void shaderc_spvc_compile_options_set_msl_capture​(long options,
                                                                        boolean b)
        If true, capture MSL output to buffer. Default is false.
      • shaderc_spvc_compile_options_set_msl_domain_lower_left

        public static void shaderc_spvc_compile_options_set_msl_domain_lower_left​(long options,
                                                                                  boolean b)
        If true, flip the Y-coord of the built-in TessCoord. Default is top left.
      • shaderc_spvc_compile_options_set_msl_argument_buffers

        public static void shaderc_spvc_compile_options_set_msl_argument_buffers​(long options,
                                                                                 boolean b)
        Enable use of MSL 2.0 indirect argument buffers. Default is not to use them.
      • nshaderc_spvc_compile_options_set_msl_discrete_descriptor_sets

        public static void nshaderc_spvc_compile_options_set_msl_discrete_descriptor_sets​(long options,
                                                                                          long descriptors,
                                                                                          long num_descriptors)
      • shaderc_spvc_compile_options_set_msl_discrete_descriptor_sets

        public static void shaderc_spvc_compile_options_set_msl_discrete_descriptor_sets​(long options,
                                                                                         java.nio.IntBuffer descriptors)
        When using MSL argument buffers, force "classic" MSL 1.0 binding for the given descriptor sets. This corresponds to VK_KHR_push_descriptor in Vulkan.
      • shaderc_spvc_compile_options_set_hlsl_shader_model

        public static void shaderc_spvc_compile_options_set_hlsl_shader_model​(long options,
                                                                              int model)
        Set HLSL shader model.

        Default is 30.

      • shaderc_spvc_compile_options_set_hlsl_point_size_compat

        public static void shaderc_spvc_compile_options_set_hlsl_point_size_compat​(long options,
                                                                                   boolean b)
        If true, ignore PointSize. Default is false.
      • shaderc_spvc_compile_options_set_hlsl_point_coord_compat

        public static void shaderc_spvc_compile_options_set_hlsl_point_coord_compat​(long options,
                                                                                    boolean b)
        If true, ignore PointCoord. Default is false.
      • shaderc_spvc_compile_options_set_fixup_clipspace

        public static void shaderc_spvc_compile_options_set_fixup_clipspace​(long options,
                                                                            boolean b)
        If true (default is false):
        • GLSL: map depth from Vulkan/D3D style to GL style, i.e. [ 0,w] -> [-w,w]
        • MSL : map depth from GL style to Vulkan/D3D style, i.e. [-w,w] -> [ 0,w]
        • HLSL: map depth from GL style to Vulkan/D3D style, i.e. [-w,w] -> [ 0,w]
      • shaderc_spvc_compile_options_set_flip_vert_y

        public static void shaderc_spvc_compile_options_set_flip_vert_y​(long options,
                                                                        boolean b)
        If true invert gl_Position.y or equivalent.

        Default is false.

      • shaderc_spvc_compile_options_set_validate

        public static void shaderc_spvc_compile_options_set_validate​(long options,
                                                                     boolean b)
        Set if validation should be performed. Default is true.
      • nshaderc_spvc_compile_options_set_for_fuzzing

        public static long nshaderc_spvc_compile_options_set_for_fuzzing​(long options,
                                                                         long data,
                                                                         long size)
      • shaderc_spvc_compile_options_set_for_fuzzing

        public static long shaderc_spvc_compile_options_set_for_fuzzing​(long options,
                                                                        java.nio.ByteBuffer data)
        Fill options with given data.
        Returns:
        amount of data used, or zero if not enough data was given
      • nshaderc_spvc_compile_into_glsl

        public static long nshaderc_spvc_compile_into_glsl​(long compiler,
                                                           long source,
                                                           long source_len,
                                                           long options)
        Unsafe version of: compile_into_glsl
      • shaderc_spvc_compile_into_glsl

        public static long shaderc_spvc_compile_into_glsl​(long compiler,
                                                          java.nio.IntBuffer source,
                                                          long options)
        Takes SPIR-V as a sequence of 32-bit words, validates it, then compiles to GLSL.
      • nshaderc_spvc_compile_into_hlsl

        public static long nshaderc_spvc_compile_into_hlsl​(long compiler,
                                                           long source,
                                                           long source_len,
                                                           long options)
        Unsafe version of: compile_into_hlsl
      • shaderc_spvc_compile_into_hlsl

        public static long shaderc_spvc_compile_into_hlsl​(long compiler,
                                                          java.nio.IntBuffer source,
                                                          long options)
        Takes SPIR-V as a sequence of 32-bit words, validates it, then compiles to HLSL.
      • nshaderc_spvc_compile_into_msl

        public static long nshaderc_spvc_compile_into_msl​(long compiler,
                                                          long source,
                                                          long source_len,
                                                          long options)
        Unsafe version of: compile_into_msl
      • shaderc_spvc_compile_into_msl

        public static long shaderc_spvc_compile_into_msl​(long compiler,
                                                         java.nio.IntBuffer source,
                                                         long options)
        Takes SPIR-V as a sequence of 32-bit words, validates it, then compiles to MSL.
      • nshaderc_spvc_compile_into_vulkan

        public static long nshaderc_spvc_compile_into_vulkan​(long compiler,
                                                             long source,
                                                             long source_len,
                                                             long options)
        Unsafe version of: compile_into_vulkan
      • shaderc_spvc_compile_into_vulkan

        public static long shaderc_spvc_compile_into_vulkan​(long compiler,
                                                            java.nio.IntBuffer source,
                                                            long options)
        Takes SPIR-V as a sequence of 32-bit words, validates it, then compiles to Vulkan specific SPIR-V.
      • shaderc_spvc_result_release

        public static void shaderc_spvc_result_release​(long result)
        Releases the resources held by the result object.

        It is invalid to use the result object for any further operations.

      • shaderc_spvc_result_get_status

        public static int shaderc_spvc_result_get_status​(long result)
        Returns the compilation status, indicating whether the compilation succeeded, or failed due to some reasons, like invalid shader stage or compilation errors.
      • nshaderc_spvc_result_get_messages

        public static long nshaderc_spvc_result_get_messages​(long result)
        Unsafe version of: result_get_messages
      • shaderc_spvc_result_get_messages

        @Nullable
        public static java.lang.String shaderc_spvc_result_get_messages​(long result)
        Get validation/compilation error or informational messages.
      • nshaderc_spvc_result_get_string_output

        public static long nshaderc_spvc_result_get_string_output​(long result)
        Unsafe version of: result_get_string_output
      • shaderc_spvc_result_get_string_output

        @Nullable
        public static java.lang.String shaderc_spvc_result_get_string_output​(long result)
        Get validation/compilation result as a string.

        This is only supported compiling to GLSL, HSL, and MSL.

      • nshaderc_spvc_result_get_binary_output

        public static long nshaderc_spvc_result_get_binary_output​(long result)
        Unsafe version of: result_get_binary_output
      • shaderc_spvc_result_get_binary_output

        @Nullable
        public static java.nio.IntBuffer shaderc_spvc_result_get_binary_output​(long result)
        
        @Nullable
        public static java.nio.IntBuffer shaderc_spvc_result_get_binary_output​(long result,
                                                                               long length)
        
        Get validation/compilation result as a binary buffer.

        This is only supported compiling to Vulkan.

      • shaderc_spvc_result_get_binary_length

        public static int shaderc_spvc_result_get_binary_length​(long result)
        Get length of validation/compilation result as a binary buffer.

        This is only supported compiling to Vulkan.