diff --git a/guest/bundle/src/RgfxVideoDriver.cpp b/guest/bundle/src/RgfxVideoDriver.cpp index 4614cffda..4aa260e6b 100644 --- a/guest/bundle/src/RgfxVideoDriver.cpp +++ b/guest/bundle/src/RgfxVideoDriver.cpp @@ -1450,18 +1450,19 @@ uint64_t answer(int entry, uint64_t a0, uint64_t a1, uint64_t a2) std::lock_guard hold(g_sessionLock); g_sessions.push_back(context); } else if (codec != 0) { - // An H.264 stream of a coded size the host does not decode is refused here, where + // A stream of a coded size the host does not decode is refused here, where // VideoToolbox hears of it and turns to its software decoder: AppleGVA's H.264 - // decoder hears of no failure later (RgfxVideoStatus.hpp). - if (codec == RGFX_VIDEO_CODEC_H264 && - !rgfx::video::sizeTaken(rgfx::video::hostCodec(codec, RGFX_VIDEO_DECODE), + // decoder hears of no failure later, and its HEVC decoder hears of one only as + // a failed frame and every frame after it (RgfxVideoStatus.hpp). + if (!rgfx::video::sizeTaken(rgfx::video::hostCodec(codec, RGFX_VIDEO_DECODE), fi->width, fi->height)) { - static std::atomic said; - if (!said.exchange(true)) + static std::atomic said[2]; + const bool hevc = codec == RGFX_VIDEO_CODEC_HEVC; + if (!said[hevc].exchange(true)) os_log_error(rgfxLog(), - "RGFX: video: an H.264 decode of %ux%u refused at its create: " + "RGFX: video: an %s decode of %ux%u refused at its create: " "the host decodes no picture of its coded size", - fi->width, fi->height); + hevc ? "HEVC" : "H.264", fi->width, fi->height); } else { context->session = rgfx::video::openSession(codec, RGFX_VIDEO_DECODE); } diff --git a/guest/bundle/src/RgfxVideoStatus.hpp b/guest/bundle/src/RgfxVideoStatus.hpp index 8a2e2b95f..43676a0e3 100644 --- a/guest/bundle/src/RgfxVideoStatus.hpp +++ b/guest/bundle/src/RgfxVideoStatus.hpp @@ -23,9 +23,12 @@ * host, 2026-11-07, every picture failed on the host). Its pipelines schedule their commands one * at a time and keep no decode's result (read from AppleGVA's code on macOS 26.7.1). So an H.264 * schedule does not wait for the host, as waiting would only cost: its frames reach the guest as - * decoded, as AppleGVA leaves no way to say otherwise. What the driver can tell before the first - * picture, a coded size the host does not decode (sizeTaken), it refuses at the context's create, - * which fails the client's session create, so VideoToolbox decodes the stream in software. + * decoded, as AppleGVA leaves no way to say otherwise. + * + * What the driver can tell before the first picture, a coded size the host does not decode + * (sizeTaken), it refuses at the context's create, for both codecs: that fails the client's + * session create, so VideoToolbox decodes the stream in software for a client that allows it, + * where an HEVC picture refused at its schedule would end the session's frames in -12911. */ #ifndef RGFX_VIDEO_STATUS_HPP_ diff --git a/guest/bundle/tests/video_driver_tests.cpp b/guest/bundle/tests/video_driver_tests.cpp index c1df6671b..9769a4868 100644 --- a/guest/bundle/tests/video_driver_tests.cpp +++ b/guest/bundle/tests/video_driver_tests.cpp @@ -563,52 +563,59 @@ void checkFailedCreate() CHECK(g_opened[0]->forgotten == 0, "the closed session's outputs forgotten"); } -// An H.264 decode of a coded size outside the host's (144 to 8192 samples a side here) is refused -// at its create, with no session opened, as are the contexts made before it in the same create; -// one of the host's least and largest sizes is made. An HEVC decode of any size is made: its -// pictures are held to the host's sizes as they are scheduled, which AppleGVA reports. -void checkH264SizeAtCreate() +// A decode of a coded size outside the host's (144 to 8192 samples a side here) is refused at its +// create, H.264's and HEVC's alike, with no session opened, as are the contexts made before it in +// the same create; one of the host's least and largest sizes is made. HEVC's is refused there +// too, where a picture refused at its schedule would end the session's frames in -12911 and leave +// VideoToolbox no software decode to turn to. +void checkDecodeSizeAtCreate() { const struct { uint32_t width, height; uint64_t want; } cases[] = { {8193, 720, kUnsupported}, {1280, 8208, kUnsupported}, {128, 720, kUnsupported}, - {1280, 128, kUnsupported}, {144, 144, kOk}, {8192, 8192, kOk}, + {1280, 128, kUnsupported}, {64, 64, kUnsupported}, {144, 144, kOk}, + {8192, 8192, kOk}, }; - for (const auto &c : cases) { - g_opened.clear(); - std::vector contexts; - CHECK(makeContexts(1, contexts, kCodecH264, c.width, c.height) == c.want, - "an H.264 create of %ux%u", c.width, c.height); - CHECK(g_opened.size() == (c.want == kOk ? 1u : 0u), "%zu sessions opened for %ux%u", - g_opened.size(), c.width, c.height); - CHECK((contexts[0] != nullptr) == (c.want == kOk), "the context of %ux%u", c.width, c.height); - if (contexts[0]) { - ContextDelete del = {1, 0, &contexts[0]}; - CHECK(call(kDeleteContexts, &del) == kOk, "DeleteContexts"); + const struct { + uint64_t sub; + const char *name; + } codecs[] = {{kCodecH264, "H.264"}, {kCodecHevc, "HEVC"}}; + for (const auto &codec : codecs) + for (const auto &c : cases) { + g_opened.clear(); + std::vector contexts; + CHECK(makeContexts(1, contexts, codec.sub, c.width, c.height) == c.want, + "an %s create of %ux%u", codec.name, c.width, c.height); + CHECK(g_opened.size() == (c.want == kOk ? 1u : 0u), "%zu %s sessions opened for %ux%u", + g_opened.size(), codec.name, c.width, c.height); + CHECK((contexts[0] != nullptr) == (c.want == kOk), "the %s context of %ux%u", codec.name, + c.width, c.height); + if (contexts[0]) { + ContextDelete del = {1, 0, &contexts[0]}; + CHECK(call(kDeleteContexts, &del) == kOk, "DeleteContexts"); + } } - } - // A create of two H.264 decodes whose second is of a size the host does not decode: the - // first's session goes with it. - { + // A create of two decodes whose second is of a size the host does not decode: the first's + // session goes with it. + for (const auto &codec : codecs) { static FunctionInfo infos[2]; infos[0] = infos[1] = decodeH264(); + infos[0].sub_id = infos[1].sub_id = codec.sub; infos[1].width = 8193; const FunctionInfo *list[2] = {&infos[0], &infos[1]}; void *contexts[2] = {}; ContextInfo info = {2, 0, list, contexts}; ContextInit init = {&info, nullptr}; g_opened.clear(); - CHECK(call(kCreateContexts, &init) == kUnsupported, "a create whose second decode is too wide"); - CHECK(g_opened.size() == 1 && g_opened[0]->closed, "the first decode's session left open"); - CHECK(contexts[0] == nullptr && contexts[1] == nullptr, "a context handed back"); + CHECK(call(kCreateContexts, &init) == kUnsupported, + "an %s create whose second decode is too wide", codec.name); + CHECK(g_opened.size() == 1 && g_opened[0]->closed, "the first %s decode's session left open", + codec.name); + CHECK(contexts[0] == nullptr && contexts[1] == nullptr, "an %s context handed back", + codec.name); } - g_opened.clear(); - std::vector contexts; - CHECK(makeContexts(1, contexts, kCodecHevc, 8193, 720) == kOk, "an HEVC create of 8193x720"); - ContextDelete del = {1, 0, &contexts[0]}; - CHECK(call(kDeleteContexts, &del) == kOk, "DeleteContexts"); } // DeleteContexts closes each context's session, which a later FreePixelBufferPool no longer @@ -2017,7 +2024,7 @@ int main(int argc, char **argv) g_driver = createDriver(); RUN(checkPoolsPerDriver); RUN(checkFailedCreate); - RUN(checkH264SizeAtCreate); + RUN(checkDecodeSizeAtCreate); RUN(checkDelete); RUN(checkUnsentDecode); RUN(checkTileLanding);