luv

Workshop wiki

video-interop-tests.lisp

luvcraft/video-interop-tests.lisp

system luvcraft/core/test · 29 definitions · on GitHub

in-package#:luvcraft.tests
defclassvideo-interop-test-device
events:initarg:events:readervideo-interop-test-device-events
next-plane:initformnil:accessorvideo-interop-test-device-next-plane
view-release-failures:initarg:view-release-failures:initform0:accessorvideo-interop-test-device-view-release-failures
defclassvideo-interop-test-resource
events:initarg:events:readervideo-interop-test-resource-events
owner:initarg:owner:readervideo-interop-test-resource-owner
kind:initarg:kind:readervideo-interop-test-resource-kind
plane:initarg:plane:readervideo-interop-test-resource-plane
failures:initarg:failures:initform0:accessorvideo-interop-test-resource-failures
defmethoddestroy
vector-push-extend
list:destroy
video-interop-test-resource-ownerresource
video-interop-test-resource-kindresource
video-interop-test-resource-planeresource
video-interop-test-resource-eventsresource
when
plusp
video-interop-test-resource-failuresresource
decf
video-interop-test-resource-failuresresource
error"Injected decoded-video resource release failure."
values
defmethodcreate
declare
ignoredescriptor
make-instance'video-interop-test-resource:events
video-interop-test-device-eventsdevice
:owner:candidate:kind:view:plane
video-interop-test-device-next-planedevice
:failures
prog1
video-interop-test-device-view-release-failuresdevice
setf
video-interop-test-device-view-release-failuresdevice
0
defclassvideo-interop-test-importer
fail-plane:initarg:fail-plane:initformnil:readervideo-interop-test-importer-fail-plane
defmethodluvcraft::adopt-decoded-video-frame
declare
let
device
luvcraft::video-frame-importer-deviceimporter
luvcraft::make-decoded-video-picture-from-planesdevice2
lambda
plane
when
eqlplane
video-interop-test-importer-fail-planeimporter
error"Injected decoded-video plane ~D failure."plane
setf
video-interop-test-device-next-planedevice
plane
make-instance'video-interop-test-resource:events
video-interop-test-device-eventsdevice
:owner:candidate:kind:texture:planeplane

A backend-free model of the HAL's logical/native retirement split. These resources disappear from a picture as soon as destroy transfers their teardown into the device ledger; native failure cannot return ownership to that now-invalid wrapper.

defclassvideo-interop-retirement-test-device
retirement-ledger:initform
luv::make-gpu-retirement-ledger
:readervideo-interop-retirement-test-device-ledger
resources:initformnil:accessorvideo-interop-retirement-test-device-resources
view-fail-plane:initarg:view-fail-plane:initformnil:readervideo-interop-retirement-test-device-view-fail-plane
texture-native-failures:initarg:texture-native-failures:initform0:readervideo-interop-retirement-test-device-texture-native-failures
defclassvideo-interop-retirement-test-resource
device:initarg:device:readervideo-interop-retirement-test-resource-device
native-owner-release:initarg:native-owner-release:initformnil:readervideo-interop-retirement-test-resource-native-owner-release
native-failures:initarg:native-failures:initform0:accessorvideo-interop-retirement-test-resource-native-failures
destroyed-p:initformnil:accessorvideo-interop-retirement-test-resource-destroyed-p
defunnote-video-interop-retirement-event
resourcestage
vector-push-extend
liststage
video-interop-test-resource-kindresource
video-interop-test-resource-planeresource
video-interop-test-resource-eventsresource
defmethoddestroy
unless
video-interop-retirement-test-resource-destroyed-presource
let
device
video-interop-retirement-test-resource-deviceresource
luv::transfer-gpu-retirement
video-interop-retirement-test-device-ledgerdevice
resource0
lambda
when
plusp
video-interop-retirement-test-resource-native-failuresresource
decf
video-interop-retirement-test-resource-native-failuresresource
error"Injected native decoded-video retirement failure."
when
video-interop-retirement-test-resource-native-owner-releaseresource
funcall
video-interop-retirement-test-resource-native-owner-releaseresource
lambda
setf
video-interop-retirement-test-resource-destroyed-presource
t
values
defmethodcreate
declare
ignoredescriptor
let
plane
video-interop-test-device-next-planedevice
when
eqlplane
video-interop-retirement-test-device-view-fail-planedevice
error"Injected decoded-video view ~D construction failure."plane
let
resource
make-instance'video-interop-retirement-test-resource:devicedevice:events
video-interop-test-device-eventsdevice
:owner:candidate:kind:view:planeplane
pushresource
video-interop-retirement-test-device-resourcesdevice
resource
defclassvideo-interop-retirement-test-importer
events:initarg:events:readervideo-interop-retirement-test-importer-events
fail-plane:initarg:fail-plane:initformnil:readervideo-interop-retirement-test-importer-fail-plane
native-state-failures:initarg:native-state-failures:initform0:accessorvideo-interop-retirement-test-importer-native-state-failures
defmethodluvcraft::release-video-frame-importer-native-state
vector-push-extend'
:native:importernil
video-interop-retirement-test-importer-eventsimporter
when
plusp
video-interop-retirement-test-importer-native-state-failuresimporter
decf
video-interop-retirement-test-importer-native-state-failuresimporter
error"Injected video importer native-state release failure."
values
defmethodluvcraft::adopt-decoded-video-frame
declare
let
device
luvcraft::video-frame-importer-deviceimporter
luvcraft::make-decoded-video-picture-from-planesdevice2
lambda
plane
when
eqlplane
video-interop-retirement-test-importer-fail-planeimporter
error"Injected decoded-video plane ~D construction failure."plane
setf
video-interop-test-device-next-planedevice
plane
let*
events
video-interop-test-device-eventsdevice
release-owner
luvcraft::make-video-frame-importer-owner-releaseimporter
lambda
vector-push-extend
list:native-owner:textureplane
events
resource
make-instance'video-interop-retirement-test-resource:devicedevice:eventsevents:owner:candidate:kind:texture:planeplane:native-owner-releaserelease-owner:native-failures
if
zeropplane
video-interop-retirement-test-device-texture-native-failuresdevice
0
pushresource
video-interop-retirement-test-device-resourcesdevice
resource
defunmaintain-video-interop-retirement-test-device
device
handler-bind
luv::maintain-gpu-retirement-ledger
video-interop-retirement-test-device-ledgerdevice
0:operation:video-interop-test
defmethodluv::retire-gpu-native-owner
ownerteardowninvalidate

Model the live backend contract: transfer before logical invalidation, then make one immediate maintenance attempt. Recursive entry from a plane callback leaves this newly enqueued owner for the next outer pass.

luv::transfer-gpu-retirement
video-interop-retirement-test-device-ledgerdevice
owner0teardowninvalidate
owner
defunmake-video-interop-test-events
make-array0:adjustablet:fill-pointer0
defunmake-video-interop-test-picture
eventsownerplane-count&key
view-failures0
make-instance'luvcraft::decoded-video-picture:textures
loopforplanebelowplane-countcollect
make-instance'video-interop-test-resource:eventsevents:ownerowner:kind:texture:planeplane
:views
loopforplanebelowplane-countcollect
make-instance'video-interop-test-resource:eventsevents:ownerowner:kind:view:planeplane:failures
if
zeropplane
view-failures0
defunmake-video-interop-test-screen
importerpicture
make-instance'luvcraft::video-screen:videonil:width64:height32:importerimporter:picturepicture:hardware-pt:samplernil:layoutnil:pipelinenil:vertex-buffernil:instance-buffernil:resourcesnil
deftestdecoded-video-second-plane-failure-rolls-back-without-publication
let*
device
make-instance'video-interop-test-device:eventsevents
importer
make-instance'video-interop-test-importer:devicedevice:fail-plane1
previous
screen
ok
ok
eqprevious
luvcraft::video-screen-picturescreen
ok
null
luvcraft::video-screen-retired-picturesscreen
ok
equal'
:destroy:candidate:view0
:destroy:candidate:texture0
coerceevents'list
deftestdecoded-video-picture-releases-every-view-before-any-texture
let*
ok
equal'
:destroy:picture:view0
:destroy:picture:view1
:destroy:picture:texture0
:destroy:picture:texture1
coerceevents'list
deftestfailed-published-picture-retirement-remains-screen-owned
let*
device
make-instance'video-interop-test-device:eventsevents
importer
make-instance'video-interop-test-importer:devicedevice
previous
make-video-interop-test-pictureevents:previous1:view-failures1
screen
handler-bind
warning#'muffle-warning
ok
not
eqprevious
luvcraft::video-screen-picturescreen
ok
equal
listprevious
luvcraft::video-screen-retired-picturesscreen
ok
equal'
:destroy:previous:view0
coerceevents'list
ok
null
luvcraft::video-screen-retired-picturesscreen
ok
equal'
:destroy:previous:view0
:destroy:previous:view0
:destroy:previous:texture0
coerceevents'list
deftestterminal-film-stop-retains-a-screen-until-logical-release-succeeds
let*
bind-group
make-instance'video-interop-test-resource:eventsevents:owner:screen:kind:bind-group:plane0:failures1
resource
make-instance'video-interop-test-resource:eventsevents:owner:screen:kind:buffer:plane0
display
allocate-instance
find-class'terminal-display
session
allocate-instance
find-class'luvcraft-session
setf
luvcraft::video-screen-bind-groupscreen
bind-group
luvcraft::video-screen-resourcesscreen
listresource
terminal-display-film-screendisplay
screen
luvcraft::luvcraft-session-video-screensession
screen
ok
eqscreen
terminal-display-film-screendisplay
ok
eqscreen
luvcraft::luvcraft-session-video-screensession
ok
eqbind-group
luvcraft::video-screen-bind-groupscreen
ok
null
luvcraft::video-screen-resourcesscreen
ok
null
terminal-display-film-screendisplay
ok
null
luvcraft::luvcraft-session-video-screensession
ok
equal'
:destroy:screen:bind-group0
:destroy:screen:buffer0
:destroy:screen:bind-group0
coerceevents'list
deftestfailed-startup-screen-release-enters-a-retryable-backlog
let*
resource
make-instance'video-interop-test-resource:eventsevents:owner:startup:kind:buffer:plane0:failures1
setf
luvcraft::video-screen-resourcesscreen
listresource
ok
equal'
:destroy:startup:buffer0
:destroy:startup:buffer0
coerceevents'list
deftestfailed-native-plane-retirement-keeps-importer-until-ledger-retry
let*
device
make-instance'video-interop-retirement-test-device:eventsevents:texture-native-failures1
importer
make-instance'video-interop-retirement-test-importer:devicedevice:eventsevents:fail-plane1
handler-bind
warning#'muffle-warning
ok
signals'error

The failed candidate owns no retryable wrapper. Logical invalidation succeeded, and the backend ledger is now the durable native owner.

ok
every#'video-interop-retirement-test-resource-destroyed-p
video-interop-retirement-test-device-resourcesdevice
ok
=2
length
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
ok
=1
luvcraft::video-frame-importer-native-owner-retainersimporter
ok
eq:requested
luvcraft::video-frame-importer-release-stateimporter

View retirement succeeds; plane 0's native teardown does not. The texture entry and its importer retainer both survive the attempt.

ok
=1
length
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
ok
=1
luvcraft::video-frame-importer-native-owner-retainersimporter
ok
eq:requested
luvcraft::video-frame-importer-release-stateimporter
ok
not
member'
:native-owner:texture0
coerceevents'list
:test#'equal

Maintenance retries the durable texture entry. Its owner succeeds and drops the final retainer, but importer retirement is deliberately a new FIFO entry rather than part of this texture callback's success.

ok
=1
length
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
ok
zerop
luvcraft::video-frame-importer-native-owner-retainersimporter
ok
eq:queued
luvcraft::video-frame-importer-release-stateimporter
ok
not
member'
:native:importernil
coerceevents'list
:test#'equal

The next pass owns only the importer and closes it independently.

ok
null
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
ok
eq:released
luvcraft::video-frame-importer-release-stateimporter
ok
equal'
:logical:view0
:logical:texture0
:native:view0
:native:texture0
:native:texture0
:native-owner:texture0
:native:importernil
coerceevents'list
deftestimporter-native-failure-retries-without-releasing-plane-owner-twice
let*
device
make-instance'video-interop-retirement-test-device:eventsevents
importer
make-instance'video-interop-retirement-test-importer:devicedevice:eventsevents:fail-plane1:native-state-failures1
handler-bind
warning#'muffle-warning
ok
signals'error

The plane and its owner retire first. The last callback enqueues a separate importer entry with a consumed (zero) retainer; it does not run importer-native closure recursively inside texture retirement.

ok
=1
length
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
ok
zerop
luvcraft::video-frame-importer-native-owner-retainersimporter
ok
eq:queued
luvcraft::video-frame-importer-release-stateimporter
ok
=1
count'
:native-owner:texture0
coerceevents'list
:test#'equal
ok
zerop
count'
:native:importernil
coerceevents'list
:test#'equal

The importer entry now runs by itself and fails without returning ownership to the already successful plane callback.

ok
=1
length
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
ok
eq:queued
luvcraft::video-frame-importer-release-stateimporter
ok
=1
count'
:native-owner:texture0
coerceevents'list
:test#'equal
ok
=1
count'
:native:importernil
coerceevents'list
:test#'equal

Retrying the importer entry cannot revisit plane teardown or its owner.

ok
null
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
ok
eq:released
luvcraft::video-frame-importer-release-stateimporter
ok
=1
count'
:native-owner:texture0
coerceevents'list
:test#'equal
ok
=2
count'
:native:importernil
coerceevents'list
:test#'equal
deftestzero-plane-unwind-transfers-importer-before-local-ownership-drops
let*

Model failure before the first plane is adopted. The constructor's unwind requests release and then drops its only lexical importer owner.

ok
signals
flet
construct-and-fail-before-first-plane
let
importer
make-instance'video-interop-retirement-test-importer:devicedevice:eventsevents:native-state-failures1
unwind-protect
error"Injected zero-plane video construction failure."
construct-and-fail-before-first-plane
'error
ok
null
video-interop-retirement-test-device-resourcesdevice

Recover IMPORTER only through the durable ledger entry. Its immediate native close failed after transfer, so no vanished constructor local is needed to retry it.

let*
entries
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
importer
luv::gpu-retirement-entry-resource
firstentries
ok
=1
lengthentries
ok
zerop
luvcraft::video-frame-importer-native-owner-retainersimporter
ok
eq:queued
luvcraft::video-frame-importer-release-stateimporter
ok
signals'error
ok
=1
count'
:native:importernil
coerceevents'list
:test#'equal
ok
null
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
ok
eq:released
luvcraft::video-frame-importer-release-stateimporter
ok
=2
count'
:native:importernil
coerceevents'list
:test#'equal
deftestlater-view-construction-failure-retires-both-importer-owners
let*
device
make-instance'video-interop-retirement-test-device:eventsevents:view-fail-plane1
importer
make-instance'video-interop-retirement-test-importer:devicedevice:eventsevents
handler-bind
warning#'muffle-warning
ok
signals'error
ok
=2
luvcraft::video-frame-importer-native-owner-retainersimporter
ok
=1
length
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
ok
zerop
luvcraft::video-frame-importer-native-owner-retainersimporter
ok
eq:queued
luvcraft::video-frame-importer-release-stateimporter
ok
null
luv::gpu-retirement-ledger-entries
video-interop-retirement-test-device-ledgerdevice
ok
eq:released
luvcraft::video-frame-importer-release-stateimporter
ok
=1
count'
:native-owner:texture0
coerceevents'list
:test#'equal
ok
=1
count'
:native-owner:texture1
coerceevents'list
:test#'equal
ok
equal'
:native:importernil
arefevents
1-
lengthevents