From 79a4da4259d6cd18d3c177d33e1574da12b11a4f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 27 May 2026 21:28:15 +0100 Subject: [PATCH] Add OBS program texture source --- docs/implementation-plan.md | 13 +- docs/obs-stem-plugin.md | 48 +- native/obs_stem_source/CMakeLists.txt | 3 +- .../mimir_obs_program_texture_source.cpp | 426 ++++++++++++++++++ .../obs_stem_source/mimir_obs_stem_source.cpp | 5 +- notes/current-system-map.md | 12 +- src/Mimir.EveRelay/Program.cs | 8 + state/evidence.jsonl | 1 + state/map.yaml | 11 +- 9 files changed, 507 insertions(+), 20 deletions(-) create mode 100644 native/obs_stem_source/mimir_obs_program_texture_source.cpp diff --git a/docs/implementation-plan.md b/docs/implementation-plan.md index 9d0a110..abe43fd 100644 --- a/docs/implementation-plan.md +++ b/docs/implementation-plan.md @@ -159,10 +159,15 @@ a named invariant that the native runtime cannot protect yet. audio and validates ready/missing/unconfigured lanes against the alignment-actuator OBS stem profile. `MimirObsStemSharedMemoryPublisher` now publishes those validated stems into a fixed Windows shared-memory ABI, and - `native/obs_stem_source` is the first OBS source plugin that reads one named - stem and submits it to OBS as an audio source. `scripts/build-obs-stem-plugin.ps1` - stages the upstream OBS plugin template SDK under `artifacts/obs-sdk/` and - builds the plugin DLL locally. + `native/obs_stem_source` is the first OBS source plugin bundle. It registers + `Mimir Audio Stem`, which reads one named stem and submits it to OBS as an + audio source, and `Mimir Program Texture`, which opens Fensalir's named D3D12 + program-output texture and feeds OBS through a GPU-to-GPU D3D12-to-D3D11 + bridge texture. This avoids CPU readback and removes Spout2 as a required + program-video dependency, while preserving the explicit boundary cost that + libobs is D3D11 on Windows. `scripts/build-obs-stem-plugin.ps1` stages the + upstream OBS plugin template SDK under `artifacts/obs-sdk/` and builds the + plugin DLL locally. - `MimirRuntime` no longer submits the legacy direct `AquariumSplineFrame` spectrum dashboard. Live spectrum visualization authority is the `AquariumFieldEvidenceFrame`: Mimir declares the rolling resource, emits a diff --git a/docs/obs-stem-plugin.md b/docs/obs-stem-plugin.md index d83ae76..2c54939 100644 --- a/docs/obs-stem-plugin.md +++ b/docs/obs-stem-plugin.md @@ -1,22 +1,49 @@ -# OBS Stem Plugin +# OBS Native Plugin -The production audio path is a Mimir/Fensalir-owned stem bus plus a narrow OBS -source plugin. +The production OBS path is a Mimir/Fensalir-owned program texture plus a +Mimir/Fensalir-owned stem bus, exposed through a narrow native OBS plugin. ## Authority +- Fensalir owns the completed program pixels. - Mimir/Fensalir own timing, alignment, DSP, and stem identity. - OBS owns broadcast mixing and scene composition. -- The plugin reads already-processed stem samples. It does not synchronize raw - sources, estimate clocks, or decide which stem is true. +- The plugin imports already-produced program pixels and reads already-processed + stem samples. It does not synchronize raw sources, estimate clocks, render the + field, or decide which payload is true. ## Current Contract +### Video + +Fensalir publishes the completed backbuffer into a named shared D3D12 +`B8G8R8A8_UNorm` texture when these environment variables are set: + +```text +FENSALIR_PROGRAM_OUTPUT_D3D12=1 +FENSALIR_PROGRAM_OUTPUT_NAME=Global\MimirFensalirProgramTexture +``` + +The native OBS plugin in `native/obs_stem_source` exposes a `Mimir Program +Texture` video source. Set: + +```text +Shared D3D12 texture name: Global\MimirFensalirProgramTexture +``` + +OBS/libobs is D3D11 internally on Windows, so this source opens the named D3D12 +texture, creates an OBS-readable shared D3D11 texture, and performs a GPU-to-GPU +copy during OBS render before drawing the source. This avoids CPU readback and +does not require Spout2. It is not pure zero-copy yet; the remaining copy is the +D3D12-to-libobs-D3D11 boundary. + +### Audio + `MimirObsStemSharedMemoryPublisher` writes the latest validated `MimirObsStemPublicationSnapshot` into a Windows shared-memory map named `Local\MimirObsStemBus` by default. The native OBS plugin in -`native/obs_stem_source` exposes one audio input source. Add one source per stem -and set: +`native/obs_stem_source` exposes a `Mimir Audio Stem` input source. Add one +source per stem and set: ```text Shared memory map: Local\MimirObsStemBus @@ -48,3 +75,10 @@ The local native plugin build currently succeeds and emits: ```text native\obs_stem_source\build\Release\mimir_obs_stem_source.dll ``` + +That DLL currently registers both source types: + +```text +Mimir Program Texture +Mimir Audio Stem +``` diff --git a/native/obs_stem_source/CMakeLists.txt b/native/obs_stem_source/CMakeLists.txt index d4c5199..19a05a3 100644 --- a/native/obs_stem_source/CMakeLists.txt +++ b/native/obs_stem_source/CMakeLists.txt @@ -5,6 +5,7 @@ project(mimir_obs_stem_source LANGUAGES CXX) find_package(libobs REQUIRED CONFIG) add_library(mimir_obs_stem_source MODULE + mimir_obs_program_texture_source.cpp mimir_obs_stem_source.cpp) target_compile_features(mimir_obs_stem_source PRIVATE cxx_std_20) @@ -12,4 +13,4 @@ target_compile_definitions(mimir_obs_stem_source PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _WIN32_WINNT=0x0A00) -target_link_libraries(mimir_obs_stem_source PRIVATE OBS::libobs) +target_link_libraries(mimir_obs_stem_source PRIVATE OBS::libobs d3d11 d3d12 dxgi) diff --git a/native/obs_stem_source/mimir_obs_program_texture_source.cpp b/native/obs_stem_source/mimir_obs_program_texture_source.cpp new file mode 100644 index 0000000..eaceb27 --- /dev/null +++ b/native/obs_stem_source/mimir_obs_program_texture_source.cpp @@ -0,0 +1,426 @@ +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using Microsoft::WRL::ComPtr; + +namespace { + +struct MimirProgramTextureSource { + obs_source_t *source = nullptr; + std::string texture_name = "Global\\MimirFensalirProgramTexture"; + uint32_t width = 0; + uint32_t height = 0; + uint64_t fence_value = 0; + uint64_t next_retry_ns = 0; + HANDLE bridge_shared_handle = nullptr; + HANDLE fence_event = nullptr; + gs_texture_t *obs_texture = nullptr; + ComPtr d3d12_device; + ComPtr command_queue; + ComPtr command_allocator; + ComPtr command_list; + ComPtr fence; + ComPtr source_texture; + ComPtr bridge_texture_d3d12; + ComPtr d3d11_device; + ComPtr d3d11_context; + ComPtr bridge_texture_d3d11; +}; + +static std::wstring utf8_to_wide(const std::string &value) +{ + if (value.empty()) { + return {}; + } + + const int count = MultiByteToWideChar(CP_UTF8, 0, value.c_str(), -1, nullptr, 0); + if (count <= 0) { + return {}; + } + + std::wstring wide(static_cast(count), L'\0'); + MultiByteToWideChar(CP_UTF8, 0, value.c_str(), -1, wide.data(), count); + if (!wide.empty() && wide.back() == L'\0') { + wide.pop_back(); + } + + return wide; +} + +static std::string obs_string(obs_data_t *settings, const char *key, const char *fallback) +{ + const char *value = obs_data_get_string(settings, key); + return value && *value ? std::string(value) : std::string(fallback); +} + +static void release_bridge(MimirProgramTextureSource *ctx) +{ + if (ctx->obs_texture) { + gs_texture_destroy(ctx->obs_texture); + ctx->obs_texture = nullptr; + } + + ctx->bridge_texture_d3d12.Reset(); + ctx->bridge_texture_d3d11.Reset(); + ctx->source_texture.Reset(); + ctx->fence.Reset(); + ctx->command_list.Reset(); + ctx->command_allocator.Reset(); + ctx->command_queue.Reset(); + ctx->d3d12_device.Reset(); + ctx->d3d11_context.Reset(); + ctx->d3d11_device.Reset(); + ctx->width = 0; + ctx->height = 0; + ctx->fence_value = 0; + + if (ctx->bridge_shared_handle) { + CloseHandle(ctx->bridge_shared_handle); + ctx->bridge_shared_handle = nullptr; + } + + if (ctx->fence_event) { + CloseHandle(ctx->fence_event); + ctx->fence_event = nullptr; + } +} + +static bool wait_for_copy(MimirProgramTextureSource *ctx) +{ + const uint64_t value = ++ctx->fence_value; + HRESULT hr = ctx->command_queue->Signal(ctx->fence.Get(), value); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: D3D12 Signal failed: 0x%08lx", static_cast(hr)); + return false; + } + + if (ctx->fence->GetCompletedValue() >= value) { + return true; + } + + hr = ctx->fence->SetEventOnCompletion(value, ctx->fence_event); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: SetEventOnCompletion failed: 0x%08lx", static_cast(hr)); + return false; + } + + WaitForSingleObject(ctx->fence_event, 100); + return ctx->fence->GetCompletedValue() >= value; +} + +static bool create_devices(MimirProgramTextureSource *ctx) +{ + HRESULT hr = D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&ctx->d3d12_device)); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: D3D12CreateDevice failed: 0x%08lx", static_cast(hr)); + return false; + } + + D3D12_COMMAND_QUEUE_DESC queue_desc = {}; + queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; + hr = ctx->d3d12_device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&ctx->command_queue)); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: CreateCommandQueue failed: 0x%08lx", static_cast(hr)); + return false; + } + + hr = ctx->d3d12_device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&ctx->command_allocator)); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: CreateCommandAllocator failed: 0x%08lx", static_cast(hr)); + return false; + } + + hr = ctx->d3d12_device->CreateCommandList( + 0, + D3D12_COMMAND_LIST_TYPE_DIRECT, + ctx->command_allocator.Get(), + nullptr, + IID_PPV_ARGS(&ctx->command_list)); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: CreateCommandList failed: 0x%08lx", static_cast(hr)); + return false; + } + + ctx->command_list->Close(); + + hr = ctx->d3d12_device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&ctx->fence)); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: CreateFence failed: 0x%08lx", static_cast(hr)); + return false; + } + + ctx->fence_event = CreateEventW(nullptr, FALSE, FALSE, nullptr); + if (!ctx->fence_event) { + blog(LOG_WARNING, "Mimir OBS program texture: CreateEvent failed: %lu", GetLastError()); + return false; + } + + UINT flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; + D3D_FEATURE_LEVEL feature_levels[] = {D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0}; + D3D_FEATURE_LEVEL selected = D3D_FEATURE_LEVEL_11_0; + hr = D3D11CreateDevice( + nullptr, + D3D_DRIVER_TYPE_HARDWARE, + nullptr, + flags, + feature_levels, + 2, + D3D11_SDK_VERSION, + &ctx->d3d11_device, + &selected, + &ctx->d3d11_context); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: D3D11CreateDevice failed: 0x%08lx", static_cast(hr)); + return false; + } + + return true; +} + +static bool open_source_texture(MimirProgramTextureSource *ctx) +{ + const auto wide_name = utf8_to_wide(ctx->texture_name); + if (wide_name.empty()) { + return false; + } + + HANDLE source_handle = nullptr; + HRESULT hr = ctx->d3d12_device->OpenSharedHandleByName(wide_name.c_str(), GENERIC_READ, &source_handle); + if (FAILED(hr)) { + return false; + } + + hr = ctx->d3d12_device->OpenSharedHandle(source_handle, IID_PPV_ARGS(&ctx->source_texture)); + CloseHandle(source_handle); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: OpenSharedHandle failed: 0x%08lx", static_cast(hr)); + return false; + } + + const D3D12_RESOURCE_DESC desc = ctx->source_texture->GetDesc(); + if (desc.Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D || desc.Format != DXGI_FORMAT_B8G8R8A8_UNORM) { + blog(LOG_WARNING, "Mimir OBS program texture: expected BGRA8 Texture2D, got dimension=%u format=%u", + static_cast(desc.Dimension), + static_cast(desc.Format)); + return false; + } + + ctx->width = static_cast(desc.Width); + ctx->height = desc.Height; + return ctx->width > 0 && ctx->height > 0; +} + +static bool create_obs_bridge_texture(MimirProgramTextureSource *ctx) +{ + D3D11_TEXTURE2D_DESC desc = {}; + desc.Width = ctx->width; + desc.Height = ctx->height; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_NTHANDLE; + + HRESULT hr = ctx->d3d11_device->CreateTexture2D(&desc, nullptr, &ctx->bridge_texture_d3d11); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: CreateTexture2D bridge failed: 0x%08lx", static_cast(hr)); + return false; + } + + ComPtr dxgi_resource; + hr = ctx->bridge_texture_d3d11.As(&dxgi_resource); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: bridge texture is not IDXGIResource1: 0x%08lx", static_cast(hr)); + return false; + } + + hr = dxgi_resource->CreateSharedHandle( + nullptr, + DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE, + nullptr, + &ctx->bridge_shared_handle); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: CreateSharedHandle bridge failed: 0x%08lx", static_cast(hr)); + return false; + } + + hr = ctx->d3d12_device->OpenSharedHandle(ctx->bridge_shared_handle, IID_PPV_ARGS(&ctx->bridge_texture_d3d12)); + if (FAILED(hr)) { + blog(LOG_WARNING, "Mimir OBS program texture: D3D12 open bridge handle failed: 0x%08lx", static_cast(hr)); + return false; + } + + ctx->obs_texture = gs_texture_open_nt_shared(static_cast(reinterpret_cast(ctx->bridge_shared_handle))); + if (!ctx->obs_texture) { + blog(LOG_WARNING, "Mimir OBS program texture: OBS failed to open bridge shared texture"); + return false; + } + + return true; +} + +static bool ensure_bridge(MimirProgramTextureSource *ctx) +{ + if (ctx->obs_texture) { + return true; + } + + const uint64_t now = os_gettime_ns(); + if (now < ctx->next_retry_ns) { + return false; + } + + ctx->next_retry_ns = now + 1000000000ULL; + release_bridge(ctx); + + if (!create_devices(ctx) || !open_source_texture(ctx) || !create_obs_bridge_texture(ctx)) { + release_bridge(ctx); + return false; + } + + blog(LOG_INFO, "Mimir OBS program texture source opened %s (%ux%u)", + ctx->texture_name.c_str(), + ctx->width, + ctx->height); + return true; +} + +static bool copy_source_to_bridge(MimirProgramTextureSource *ctx) +{ + HRESULT hr = ctx->command_allocator->Reset(); + if (FAILED(hr)) { + return false; + } + + hr = ctx->command_list->Reset(ctx->command_allocator.Get(), nullptr); + if (FAILED(hr)) { + return false; + } + + D3D12_RESOURCE_BARRIER barriers[2] = {}; + barriers[0].Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barriers[0].Transition.pResource = ctx->source_texture.Get(); + barriers[0].Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON; + barriers[0].Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE; + barriers[0].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; + barriers[1].Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barriers[1].Transition.pResource = ctx->bridge_texture_d3d12.Get(); + barriers[1].Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON; + barriers[1].Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST; + barriers[1].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; + ctx->command_list->ResourceBarrier(2, barriers); + ctx->command_list->CopyResource(ctx->bridge_texture_d3d12.Get(), ctx->source_texture.Get()); + + std::swap(barriers[0].Transition.StateBefore, barriers[0].Transition.StateAfter); + std::swap(barriers[1].Transition.StateBefore, barriers[1].Transition.StateAfter); + ctx->command_list->ResourceBarrier(2, barriers); + + hr = ctx->command_list->Close(); + if (FAILED(hr)) { + return false; + } + + ID3D12CommandList *lists[] = {ctx->command_list.Get()}; + ctx->command_queue->ExecuteCommandLists(1, lists); + return wait_for_copy(ctx); +} + +static const char *mimir_program_texture_get_name(void *) +{ + return "Mimir Program Texture"; +} + +static void mimir_program_texture_update(void *data, obs_data_t *settings) +{ + auto *ctx = static_cast(data); + ctx->texture_name = obs_string(settings, "texture_name", "Global\\MimirFensalirProgramTexture"); + release_bridge(ctx); +} + +static void *mimir_program_texture_create(obs_data_t *settings, obs_source_t *source) +{ + auto *ctx = new MimirProgramTextureSource(); + ctx->source = source; + mimir_program_texture_update(ctx, settings); + return ctx; +} + +static void mimir_program_texture_destroy(void *data) +{ + auto *ctx = static_cast(data); + release_bridge(ctx); + delete ctx; +} + +static uint32_t mimir_program_texture_width(void *data) +{ + auto *ctx = static_cast(data); + ensure_bridge(ctx); + return ctx->width; +} + +static uint32_t mimir_program_texture_height(void *data) +{ + auto *ctx = static_cast(data); + ensure_bridge(ctx); + return ctx->height; +} + +static void mimir_program_texture_defaults(obs_data_t *settings) +{ + obs_data_set_default_string(settings, "texture_name", "Global\\MimirFensalirProgramTexture"); +} + +static obs_properties_t *mimir_program_texture_properties(void *) +{ + obs_properties_t *props = obs_properties_create(); + obs_properties_add_text(props, "texture_name", "Shared D3D12 texture name", OBS_TEXT_DEFAULT); + return props; +} + +static void mimir_program_texture_render(void *data, gs_effect_t *) +{ + auto *ctx = static_cast(data); + if (!ensure_bridge(ctx)) { + return; + } + + if (copy_source_to_bridge(ctx)) { + obs_source_draw(ctx->obs_texture, 0, 0, ctx->width, ctx->height, false); + } +} + +static obs_source_info mimir_program_texture_source_info = { + .id = "mimir_program_texture_source", + .type = OBS_SOURCE_TYPE_INPUT, + .output_flags = OBS_SOURCE_VIDEO, + .get_name = mimir_program_texture_get_name, + .create = mimir_program_texture_create, + .destroy = mimir_program_texture_destroy, + .get_width = mimir_program_texture_width, + .get_height = mimir_program_texture_height, + .get_defaults = mimir_program_texture_defaults, + .get_properties = mimir_program_texture_properties, + .update = mimir_program_texture_update, + .video_render = mimir_program_texture_render, +}; + +} // namespace + +void mimir_register_program_texture_source() +{ + obs_register_source(&mimir_program_texture_source_info); +} diff --git a/native/obs_stem_source/mimir_obs_stem_source.cpp b/native/obs_stem_source/mimir_obs_stem_source.cpp index c77a091..8e23119 100644 --- a/native/obs_stem_source/mimir_obs_stem_source.cpp +++ b/native/obs_stem_source/mimir_obs_stem_source.cpp @@ -15,6 +15,8 @@ OBS_DECLARE_MODULE() OBS_MODULE_USE_DEFAULT_LOCALE("mimir-obs-stem-source", "en-US") +void mimir_register_program_texture_source(); + struct MimirStemSource { obs_source_t *source = nullptr; std::string map_name = "Local\\MimirObsStemBus"; @@ -206,6 +208,7 @@ static obs_source_info mimir_stem_source_info = { bool obs_module_load(void) { obs_register_source(&mimir_stem_source_info); - blog(LOG_INFO, "Mimir OBS audio stem source loaded"); + mimir_register_program_texture_source(); + blog(LOG_INFO, "Mimir OBS sources loaded"); return true; } diff --git a/notes/current-system-map.md b/notes/current-system-map.md index bd6eafd..59ca6d6 100644 --- a/notes/current-system-map.md +++ b/notes/current-system-map.md @@ -320,10 +320,14 @@ publication now has a first readiness surface: reports ready, missing, and unconfigured stems against the alignment actuator stem-bus profile. `MimirObsStemSharedMemoryPublisher` writes the validated stem frames into `Local\MimirObsStemBus`, and `native/obs_stem_source` is the first -OBS source plugin: one OBS source reads one named stem from that map and submits -it through libobs audio. `scripts/build-obs-stem-plugin.ps1` stages the -upstream OBS plugin-template SDK under `artifacts/obs-sdk/` and builds the -plugin DLL locally. +OBS source plugin bundle: `Mimir Audio Stem` reads one named stem from that map +and submits it through libobs audio, while `Mimir Program Texture` opens +Fensalir's named shared D3D12 program-output texture and draws it through an +OBS-readable shared D3D11 bridge texture. The video path is GPU-to-GPU and does +not require Spout2 or CPU readback; the remaining copy is the explicit D3D12 to +libobs-D3D11 boundary. `scripts/build-obs-stem-plugin.ps1` stages the upstream +OBS plugin-template SDK under `artifacts/obs-sdk/` and builds the plugin DLL +locally. ## Visual Fusion diff --git a/src/Mimir.EveRelay/Program.cs b/src/Mimir.EveRelay/Program.cs index 9a2fd79..18e846a 100644 --- a/src/Mimir.EveRelay/Program.cs +++ b/src/Mimir.EveRelay/Program.cs @@ -304,7 +304,15 @@ internal sealed unsafe class D3D12SharedTextureReader : IDisposable Offset = 0, Footprint = new SubresourceFootPrint(Format.B8G8R8A8_UNorm, (uint)Width, (uint)Height, 1, (uint)readbackRowPitch), }); + commandList.ResourceBarrier(ResourceBarrier.BarrierTransition( + texture, + ResourceStates.Common, + ResourceStates.CopySource)); commandList.CopyTextureRegion(dest, 0, 0, 0, source, null); + commandList.ResourceBarrier(ResourceBarrier.BarrierTransition( + texture, + ResourceStates.CopySource, + ResourceStates.Common)); commandList.Close(); queue.ExecuteCommandList(commandList); WaitForGpu(); diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 0818d6a..169e71b 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -191,3 +191,4 @@ {"ts": "2026-05-27T20:33:41+01:00", "type": "verification", "status": "ok", "note": "Mimir now has an OBS-facing stem publication state for the Fensalir Faust stem bus. It consumes AquariumAudioStemFrame records without copying audio, validates them against the alignment-actuator stem profile, reports ready/missing/unconfigured stems, and telemetry can print publication readiness. --audio-stem-publication-smoke passed; Mimir build passed."} {"ts": "2026-05-27T20:55:23+01:00", "type": "verification", "status": "blocked", "note": "OBS stem plugin path is now chosen and scaffolded. Mimir publishes validated stem snapshots into a fixed Windows shared-memory ABI (Local\\\\MimirObsStemBus), and native/obs_stem_source defines the first libobs audio source plugin that reads one named stem and calls obs_source_output_audio. dotnet build and --obs-stem-shared-memory-smoke passed. Local native plugin build is blocked until an OBS/libobs SDK with libobsConfig.cmake is installed or supplied via libobs_DIR."} {"ts": "2026-05-27T21:03:27+01:00", "type": "verification", "status": "ok", "note": "The OBS/libobs SDK is now staged locally through obsproject/obs-plugintemplate under artifacts/obs-sdk. Its CMake bootstrap downloaded obs-deps, Qt deps, and OBS 31.1.1 sources, built Debug/Release libobs development components, and installed libobsConfig.cmake under .deps/cmake. native/obs_stem_source configured with libobs_DIR plus CMAKE_PREFIX_PATH and built Release/mimir_obs_stem_source.dll successfully. Added scripts/build-obs-stem-plugin.ps1 to repeat the SDK staging/build."} +{"ts": "2026-05-27T21:26:51+01:00", "type": "verification", "status": "ok", "note": "native/obs_stem_source now registers both OBS sources: Mimir Audio Stem for Local\\\\MimirObsStemBus stem blocks and Mimir Program Texture for Fensalir's named shared D3D12 program output. The video source opens Global\\\\MimirFensalirProgramTexture, copies it GPU-to-GPU into an OBS-readable shared D3D11 texture during render, and draws it without CPU readback or Spout2. Mimir build and scripts/build-obs-stem-plugin.ps1 passed; Fensalir build passed after publishing the program texture back to COMMON for external readers."} diff --git a/state/map.yaml b/state/map.yaml index 163d617..516525c 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -197,9 +197,14 @@ accepted_design: stem-bus profile without copying audio. `MimirObsStemSharedMemoryPublisher` writes validated stems into the `Local\MimirObsStemBus` Windows shared-memory ABI, and `native/obs_stem_source` is the first OBS source - plugin that reads one named stem from that map and submits it as libobs - audio. `scripts/build-obs-stem-plugin.ps1` stages the upstream OBS plugin - template SDK under `artifacts/obs-sdk/` and builds the plugin DLL locally. + plugin bundle. It registers `Mimir Audio Stem`, which reads one named stem + from that map and submits it as libobs audio, and `Mimir Program Texture`, + which opens Fensalir's named shared D3D12 program-output texture and draws + it through an OBS-readable shared D3D11 bridge texture. The video path is + GPU-to-GPU and does not require Spout2 or CPU readback; the remaining copy + is the explicit D3D12 to libobs-D3D11 boundary. + `scripts/build-obs-stem-plugin.ps1` stages the upstream OBS plugin template + SDK under `artifacts/obs-sdk/` and builds the plugin DLL locally. The synthetic codebook proof is `dotnet run --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --bioacoustic-self-test`.