Exemple #1
0
def create_compute_shader():
    global compute_module

    with open('resources/shaders/compute_noise/compute_noise.comp.spv',
              'rb') as f:
        compute_module = hvk.create_shader_module(
            api, device, hvk.shader_module_create_info(code=f.read()))
Exemple #2
0
    def _compile_shader(self):
        engine, api, device = self.ctx
        shader = self.shader
        constants = shader.mapping.get('constants')
        modules = []
        stage_infos = []

        modules_src = (
            (vk.SHADER_STAGE_VERTEX_BIT, shader.vert),
            (vk.SHADER_STAGE_FRAGMENT_BIT, shader.frag),
        )

        for stage, code in modules_src:
            module = hvk.create_shader_module(
                api, device, hvk.shader_module_create_info(code=code))
            modules.append(module)

            spez = None
            if constants is not None and len(constants) > 0:
                spez = setup_specialization_constants(stage, constants)

            stage_infos.append(
                hvk.pipeline_shader_stage_create_info(
                    stage=stage, module=module, specialization_info=spez))

        self.modules = modules
        self.stage_infos = stage_infos
Exemple #3
0
    def _compile_shader(self):
        engine, api, device = self.ctx
        compute = self.compute

        module = hvk.create_shader_module(api, device, hvk.shader_module_create_info(code=compute.src))

        spez = None
        constants = compute.mapping.get('constants')
        if constants is not None and len(constants) > 0:
            spez = setup_specialization_constants(vk.SHADER_STAGE_COMPUTE_BIT, constants)

        stage = hvk.pipeline_shader_stage_create_info(
            stage = vk.SHADER_STAGE_COMPUTE_BIT,
            module = module,
            specialization_info = spez
        )

        self.module = module
        self.module_stage = stage
Exemple #4
0
def create_shaders():
    global shader_modules, stage_infos

    shader_modules, stage_infos = [], []
    shader_sources = {
        vk.SHADER_STAGE_VERTEX_BIT:
        'resources/shaders/simple_triangle/simple_triangle.vert.spv',
        vk.SHADER_STAGE_FRAGMENT_BIT:
        'resources/shaders/simple_triangle/simple_triangle.frag.spv'
    }
    for stage, src in shader_sources.items():
        with open(src, 'rb') as f:
            stage_module = hvk.create_shader_module(
                api, device, hvk.shader_module_create_info(code=f.read()))
            shader_modules.append(stage_module)

            stage_infos.append(
                hvk.pipeline_shader_stage_create_info(
                    stage=stage,
                    module=stage_module,
                ))