libretro / libretro/RetroArch

Question about how to start a Vulkan front

Open
#18,303 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
14.1k
Forks
2.2k
Avg merge
7h 35m
Merged PRs (30d)
51

Description

I have a Libretro frontend for Reinforcement Learning that works perfectly with OpenGL. However, I wanted to implement Vulkan functionality and ran into some issues. One of them is how to properly implement Vulkan and pass information to the Libretro API and get cores to work. I couldn't find any documentation on this, and reading the extensive code behind the tips is a time-consuming, trial-and-error process.

I tried something and left some code below. I'd appreciate any help with any information.

    // already true, dont need to change
    case RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER: {
        unsigned* context_type = (unsigned*)data;
        *context_type = RETRO_HW_CONTEXT_VULKAN;
        printf("[ENV] RETRO_HW_CONTEXT_VULKAN >>>>>>>>>> \n");
        return true;
    }

    // already true, dont need to change
    case RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE: {
        unsigned *cb = (unsigned*)data;
        printf("[ENV] RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE\n");
        
        *cb = RETRO_HW_CONTEXT_VULKAN;
        return false;
    }

    // already true, dont need to change
    case RETRO_ENVIRONMENT_GET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_SUPPORT:
    {
        printf("[ENV] RETRO_ENVIRONMENT_GET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_SUPPORT\n");
        struct retro_hw_render_context_negotiation_interface *iface =
                (struct retro_hw_render_context_negotiation_interface*)data;

        
        iface->interface_version = RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN_VERSION;
        return true;
    }

    // TODO Implement this
    case RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE: {
        // video_driver_state_t *video_st = video_state_get_ptr();
        // struct retro_hw_render_context_negotiation_interface *iface =
        //     (struct retro_hw_render_context_negotiation_interface*)data;
        printf("[ENV] RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE\n");

        // What to do here?
        // video_st->hw_render_context_negotiation = iface;

        return true;
    }

    // TODO Implement this
    case RETRO_ENVIRONMENT_SET_HW_RENDER:
    case RETRO_ENVIRONMENT_SET_HW_RENDER | RETRO_ENVIRONMENT_EXPERIMENTAL: {
        // struct retro_hw_render_callback *hw = (struct retro_hw_render_callback*)data;

        if(hw->context_type == RETRO_HW_CONTEXT_VULKAN) {
            printf("[ENV] SET_HW_RENDER RETRO_HW_CONTEXT_VULKAN\n", hw->context_type);
        } else {
            printf("[ENV] SET_HW_RENDER received - context_type: %d\n", hw->context_type);
        }
        
        // What to do here?
        // if (hw->context_type == RETRO_HW_CONTEXT_VULKAN) {
        //     // Configure nossos callbacks
        //     hw->context_reset = vulkan_context_reset;
        //     hw->context_destroy = vulkan_context_destroy;
        //     hw->bottom_left_origin = true;
        // }
        
        // g_video.hw = *hw;
        return true;
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the listed RETRO_ENVIRONMENT_* handlers through the libretro API and comparing the OpenGL frontend path with the Vulkan requirements described in the issue. Document the required negotiation and render setup steps, including what the frontend must provide for cores to work, and verify the guidance against a working implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
computer-graphics, frontend
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.