From cca93a932398f935fd942ffbe1bfdbe9024fe4f2 Mon Sep 17 00:00:00 2001 From: Pavel Kotek <334189328+kotekompotek@users.noreply.github.com> Date: Tue, 24 Nov 2026 19:17:34 +0500 Subject: [PATCH] d3d12: support multi-viewport and multi-scissor up to 16 entries --- docs/d3d12_vulkan.md | 4 +- runtime/shims/d3d12_com.cpp | 61 +++++++++++++++++++-------- runtime/shims/d3d12_vulkan_device.cpp | 45 ++++++++++---------- runtime/src/command_list.h | 4 ++ runtime/src/vulkan_backend.h | 8 ++++ runtime/src/vulkan_replay.h | 43 +++++++++++++++---- runtime/test/d3d12_com_test.cpp | 8 ++++ runtime/test/vk_test_device.h | 1 + 8 files changed, 125 insertions(+), 49 deletions(-) diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 8bf2bd38ea..f4229871c0 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md @@ -950,7 +950,9 @@ The compute path, end to end: dynamic-rendering scope. Its layer count is the smallest layer count of the bound views. - **Viewport:** it is flipped (negative height), because translated vertex shaders write D3D clip coordinates; front-face winding then matches D3D12's. - - Only the first viewport and scissor are used, and primitive restart is not modelled yet. + - Up to 16 viewports and scissor rectangles are forwarded through `VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT` / + `VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT` when `VkPhysicalDeviceFeatures::multiViewport` is enabled (clamped to the + first entry with a `log_once` notice otherwise); primitive restart is not modelled yet. **Resources and heaps:** - A buffer of 0 bytes, or one whose size wraps when aligned, is `E_INVALIDARG`. One the arena cannot hold is diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp index 4f4904e965..d377e440a1 100644 --- a/runtime/shims/d3d12_com.cpp +++ b/runtime/shims/d3d12_com.cpp @@ -410,13 +410,17 @@ class GraphicsCommandList final void STDMETHODCALLTYPE RSSetViewports(UINT count, const D3D12_VIEWPORT* viewports) override { if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false); if (!count) { - viewport_ = {}; + viewports_.fill({}); + viewport_count_ = 0; + draw_views_stale_ = true; return; } if (!viewports || count > D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) return check(false); - if (count > 1) stub("ID3D12GraphicsCommandList::RSSetViewports (more than one viewport; the first is used)"); - const D3D12_VIEWPORT& v = viewports[0]; - viewport_ = {v.TopLeftX, v.TopLeftY, v.Width, v.Height, v.MinDepth, v.MaxDepth}; + for (UINT i = 0; i < count; ++i) + viewports_[i] = {viewports[i].TopLeftX, viewports[i].TopLeftY, viewports[i].Width, viewports[i].Height, + viewports[i].MinDepth, viewports[i].MaxDepth}; + viewport_count_ = count; + draw_views_stale_ = true; } void STDMETHODCALLTYPE RSSetScissorRects(UINT count, const D3D12_RECT* rects) override { @@ -424,12 +428,17 @@ class GraphicsCommandList final // A zero-count call disables all previously bound rectangles; it is not a no-op. // With no scissor bound, the rasterizer clips every fragment, as on native D3D12. if (!count) { - scissor_ = {}; + scissors_.fill({}); + scissor_count_ = 0; + draw_views_stale_ = true; return; } if (!rects) return; - if (count > 1) stub("ID3D12GraphicsCommandList::RSSetScissorRects (more than one rectangle; the first is used)"); - scissor_ = {rects[0].left, rects[0].top, rects[0].right, rects[0].bottom}; + if (count > D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) return check(false); + for (UINT i = 0; i < count; ++i) + scissors_[i] = {rects[i].left, rects[i].top, rects[i].right, rects[i].bottom}; + scissor_count_ = count; + draw_views_stale_ = true; } // D3D12 reads render-target and depth descriptors here, so their views are copied now. @@ -486,9 +495,9 @@ class GraphicsCommandList final d3d12_trace::record("ID3D12GraphicsCommandList6::DispatchMesh"); if (x > 65535 || y > 65535 || z > 65535 || std::uint64_t(x) * y * z > (1u << 22)) return check(false); if (!graphics_pipeline_ || !graphics_.layout) return check(false); - if (!(viewport_.width > 0) || !(viewport_.height > 0)) return; // as record_draw: nothing is rasterized - leonida::Draw draw{graphics_pipeline_, graphics_.data, draw_views(), depth_, {}, 0, viewport_, - scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, false, x, y, z, 0, 0}; + if (!has_nonempty_viewport()) return; // as record_draw: nothing is rasterized + leonida::Draw draw{graphics_pipeline_, graphics_.data, draw_views(), depth_, {}, 0, viewports_[0], + scissors_[0], blend_factor_, front_stencil_ref_, back_stencil_ref_, false, x, y, z, 0, 0}; draw.mesh = true; check(list_.draw(std::move(draw))); } @@ -1264,8 +1273,10 @@ class GraphicsCommandList final std::uint32_t topology_ = 0; // D3D_PRIMITIVE_TOPOLOGY_UNDEFINED std::array vertex_buffers_{}; leonida::IndexBufferView index_{}; - leonida::Viewport viewport_{}; - leonida::Rect scissor_{}; + std::array viewports_{}; + UINT viewport_count_ = 0; + std::array scissors_{}; + UINT scissor_count_ = 0; std::array render_targets_{}; UINT render_target_count_ = 0; // One block shared by every draw that keeps the same targets and buffers, rebuilt when either changes, so a @@ -1366,8 +1377,10 @@ class GraphicsCommandList final topology_ = 0; vertex_buffers_ = {}; index_ = {}; - viewport_ = {}; - scissor_ = {}; + viewports_.fill({}); + viewport_count_ = 0; + scissors_.fill({}); + scissor_count_ = 0; render_targets_.fill({}); render_target_count_ = 0; draw_views_stale_ = true; @@ -1395,13 +1408,25 @@ class GraphicsCommandList final check(list_.dispatch({compute_pipeline_, compute_.data, x, y, z})); } - // The views block a draw records. Rebuilt only when the render targets or the bound vertex buffers change. + bool has_nonempty_viewport() const { + for (UINT i = 0; i < viewport_count_; ++i) + if (viewports_[i].width > 0 && viewports_[i].height > 0) return true; + return false; + } + + // The views block a draw records. Rebuilt only when render targets, vertex buffers, or multi-viewport/scissor arrays change. const std::shared_ptr& draw_views() { if (draw_views_stale_ || !draw_views_) { auto views = std::make_shared(); views->render_targets = render_targets_; views->vertex_buffers = vertex_buffers_; views->render_target_count = render_target_count_; + if (viewport_count_ > 1 || scissor_count_ > 1) { + views->viewports = viewports_; + views->scissors = scissors_; + views->viewport_count = viewport_count_; + views->scissor_count = scissor_count_; + } draw_views_ = std::move(views); draw_views_stale_ = false; } @@ -1414,9 +1439,9 @@ class GraphicsCommandList final note_direct_heap_indexing(graphics_.layout); // No viewport (never set, or unbound with RSSetViewports(0)) or an empty one: D3D12 rasterizes nothing, // and Vulkan forbids a 0x0 viewport, so the draw is not recorded. - if (!(viewport_.width > 0) || !(viewport_.height > 0)) return; - leonida::Draw draw{graphics_pipeline_, graphics_.data, draw_views(), depth_, index_, topology_, viewport_, - scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, indexed, count, instances, + if (!has_nonempty_viewport()) return; + leonida::Draw draw{graphics_pipeline_, graphics_.data, draw_views(), depth_, index_, topology_, viewports_[0], + scissors_[0], blend_factor_, front_stencil_ref_, back_stencil_ref_, indexed, count, instances, first, base_vertex, first_instance}; check(list_.draw(std::move(draw))); } diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index 2445302ccb..ec3f8362c1 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -3936,7 +3936,9 @@ class PipelineState final // Kept for variants: a draw that leaves a slot unbound needs this pipeline with that format undefined. graphics_.mesh = mesh; + graphics_.dynamic_viewport_count = vk.vkCmdSetViewportWithCount && vk.vkCmdSetScissorWithCount; recipe_.mesh = mesh; + recipe_.dynamic_viewport_count = graphics_.dynamic_viewport_count; recipe_.stages = std::move(stage_infos); recipe_.attributes = std::move(attributes); recipe_.bindings = std::move(bindings); @@ -4085,6 +4087,7 @@ class PipelineState final // What a graphics pipeline is made from, so variants can be built at draw time. struct Recipe { bool mesh = false; // no vertex input or input assembly state, and no dynamic topology or strides + bool dynamic_viewport_count = false; std::vector stages; // One per entry of create_graphics's stage table (VS, GS, PS), static_assert there; what `stages` chain. VkPipelineShaderStageRequiredSubgroupSizeCreateInfo required_sizes[3]{}; @@ -4103,15 +4106,19 @@ class PipelineState final // The graphics pipeline with the formats of the `unbound` slots (leonida::GraphicsPipeline::variant) undefined. VkPipeline build(std::uint32_t unbound) const { - // The stride state is last: a pipeline without vertex bindings (a full-screen pass that builds its vertices - // from SV_VertexID) leaves it out, since no vkCmdBindVertexBuffers2 would ever set it - // (VUID-vkCmdDraw-pStrides-04913). - static constexpr VkDynamicState dynamic_states[] = { - VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR, - VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY, VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE, - VK_DYNAMIC_STATE_STENCIL_REFERENCE, VK_DYNAMIC_STATE_BLEND_CONSTANTS, - VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE}; const Recipe& r = recipe_; + VkDynamicState dynamic_states[8]{}; + std::uint32_t dynamic_count = 0; + const auto push_dyn = [&](VkDynamicState s) { dynamic_states[dynamic_count++] = s; }; + push_dyn(r.dynamic_viewport_count ? VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT : VK_DYNAMIC_STATE_VIEWPORT); + push_dyn(r.dynamic_viewport_count ? VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT : VK_DYNAMIC_STATE_SCISSOR); + if (!r.mesh) { + push_dyn(VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY); + push_dyn(VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE); + } + push_dyn(VK_DYNAMIC_STATE_STENCIL_REFERENCE); + push_dyn(VK_DYNAMIC_STATE_BLEND_CONSTANTS); + if (!r.mesh && !r.bindings.empty()) push_dyn(VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE); std::vector colors = graphics_.color_formats; for (std::size_t slot = 0; slot < colors.size(); ++slot) if (unbound & (1u << slot)) colors[slot] = VK_FORMAT_UNDEFINED; @@ -4137,8 +4144,8 @@ class PipelineState final vertex_input.vertexAttributeDescriptionCount = std::uint32_t(r.attributes.size()); vertex_input.pVertexAttributeDescriptions = r.attributes.data(); VkPipelineViewportStateCreateInfo viewport{VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO}; - viewport.viewportCount = 1; - viewport.scissorCount = 1; + viewport.viewportCount = r.dynamic_viewport_count ? 0u : 1u; + viewport.scissorCount = r.dynamic_viewport_count ? 0u : 1u; VkPipelineMultisampleStateCreateInfo multisample = r.multisample; VkPipelineRasterizationStateCreateInfo raster = r.raster; VkPipelineRasterizationConservativeStateCreateInfoEXT conservative{ @@ -4153,19 +4160,9 @@ class PipelineState final VkPipelineColorBlendStateCreateInfo blend = r.blend; blend.attachmentCount = std::uint32_t(r.blends.size()); blend.pAttachments = r.blends.data(); - // A mesh pipeline takes neither the topology nor the strides as dynamic state - // (VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-07065 and -07066). - static constexpr VkDynamicState mesh_dynamic_states[] = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR, - VK_DYNAMIC_STATE_STENCIL_REFERENCE, - VK_DYNAMIC_STATE_BLEND_CONSTANTS}; VkPipelineDynamicStateCreateInfo dynamic{VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO}; - if (r.mesh) { - dynamic.dynamicStateCount = std::uint32_t(std::size(mesh_dynamic_states)); - dynamic.pDynamicStates = mesh_dynamic_states; - } else { - dynamic.dynamicStateCount = std::uint32_t(std::size(dynamic_states)) - (r.bindings.empty() ? 1 : 0); - dynamic.pDynamicStates = dynamic_states; - } + dynamic.dynamicStateCount = dynamic_count; + dynamic.pDynamicStates = dynamic_states; VkGraphicsPipelineCreateInfo info{VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, &rendering}; info.stageCount = std::uint32_t(r.stages.size()); @@ -5461,6 +5458,9 @@ class Device final arena.log = getenv_s(&length, log, "LEONIDA_ARENA_LOG") == 0 && length > 1 && log[0] != '0'; state_.context->set_heap_base(arena.address); state_.context->set_zero_page(arena.buffer, 0, kArenaReserved); + state_.context->set_multi_viewport(state_.info.features.multiViewport == VK_TRUE); + if (state_.info.features.multiViewport != VK_TRUE) + log_once("multiViewport disabled; clamping viewports/scissors to", 1); return true; } @@ -9807,6 +9807,7 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin enable.dualSrcBlend = chosen_features.dualSrcBlend; enable.logicOp = chosen_features.logicOp; enable.depthClamp = chosen_features.depthClamp; + enable.multiViewport = chosen_features.multiViewport; enable.geometryShader = chosen_features.geometryShader; // translated geometry shaders (195 in the corpus) // What translated shaders declare (the index's `features`): 64-bit integers in most of the corpus (25,803 of // 26,503 entries), doubles, 16-bit integers, clip and cull distances in a few vertex shaders, image stores diff --git a/runtime/src/command_list.h b/runtime/src/command_list.h index 7c5c09e0ac..0fc35b8a8d 100644 --- a/runtime/src/command_list.h +++ b/runtime/src/command_list.h @@ -412,6 +412,10 @@ struct DrawViews { std::array render_targets{}; std::array vertex_buffers{}; // by input slot std::uint32_t render_target_count = 8; + std::array viewports{}; + std::array scissors{}; + std::uint32_t viewport_count = 0; // 0: single Draw::viewport; >0: all viewports_[0..count-1] + std::uint32_t scissor_count = 0; // 0: single Draw::scissor; >0: all scissors_[0..count-1] }; // DrawInstanced / DrawIndexedInstanced / DispatchMesh, with everything they use captured when they are recorded: diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h index f90dd6a3ff..28bab7c109 100644 --- a/runtime/src/vulkan_backend.h +++ b/runtime/src/vulkan_backend.h @@ -101,6 +101,7 @@ struct VulkanDeviceFunctions { X(vkCreateComputePipelines) X(vkDestroyPipeline) X(vkCmdBindPipeline) X(vkCmdBindDescriptorSets) \ X(vkCmdPushConstants) X(vkCmdDispatch) \ X(vkCmdBindVertexBuffers2) X(vkCmdBindIndexBuffer) X(vkCmdSetViewport) X(vkCmdSetScissor) \ + X(vkCmdSetViewportWithCount) X(vkCmdSetScissorWithCount) \ X(vkCmdSetPrimitiveTopology) X(vkCmdSetPrimitiveRestartEnable) X(vkCmdSetStencilReference) \ X(vkCmdSetBlendConstants) X(vkCmdDraw) \ X(vkCmdDrawIndexed) X(vkCreateGraphicsPipelines) X(vkQueueBindSparse) X(vkGetImageSparseMemoryRequirements) \ @@ -987,6 +988,8 @@ class VulkanContext { replay_.bind_index_buffer = vk.vkCmdBindIndexBuffer; replay_.set_viewport = vk.vkCmdSetViewport; replay_.set_scissor = vk.vkCmdSetScissor; + replay_.set_viewport_with_count = vk.vkCmdSetViewportWithCount; + replay_.set_scissor_with_count = vk.vkCmdSetScissorWithCount; replay_.set_primitive_topology = vk.vkCmdSetPrimitiveTopology; replay_.set_primitive_restart_enable = vk.vkCmdSetPrimitiveRestartEnable; replay_.set_stencil_reference = vk.vkCmdSetStencilReference; @@ -1277,6 +1280,11 @@ class VulkanContext { replay_.heap_base = heap_base; } + void set_multi_viewport(bool enabled) { + std::unique_lock lock(resource_mutex_); + replay_.multi_viewport = enabled; + } + // Zeroed memory for unbound vertex and index buffers to read (ReplayFunctions::zero_buffer). void set_zero_page(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size) { std::unique_lock lock(resource_mutex_); diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h index bda530a7a6..c9f608bf10 100644 --- a/runtime/src/vulkan_replay.h +++ b/runtime/src/vulkan_replay.h @@ -773,6 +773,7 @@ struct GraphicsPipeline { std::uint32_t zero_step_slots = 0; // per-instance slots with InstanceDataStepRate 0: stride 0 at draw time std::uint32_t strip_cut = 0; // D3D12_INDEX_BUFFER_STRIP_CUT_VALUE (0: off, 1: 0xFFFF, 2: 0xFFFFFFFF) bool mesh = false; // a mesh shader instead of a vertex shader: drawn by DispatchMesh only + bool dynamic_viewport_count = false; // VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT / SCISSOR_WITH_COUNT enabled // The same pipeline with some attachment formats VK_FORMAT_UNDEFINED, for a draw that leaves those slots // unbound (D3D12 allows it; dynamic rendering needs the formats to agree). Bit i: colour slot i, bit 8: depth // and stencil. Null when it cannot be built. @@ -854,6 +855,9 @@ struct ReplayFunctions { PFN_vkCmdBindIndexBuffer bind_index_buffer = nullptr; PFN_vkCmdSetViewport set_viewport = nullptr; PFN_vkCmdSetScissor set_scissor = nullptr; + PFN_vkCmdSetViewportWithCount set_viewport_with_count = nullptr; + PFN_vkCmdSetScissorWithCount set_scissor_with_count = nullptr; + bool multi_viewport = false; PFN_vkCmdSetPrimitiveTopology set_primitive_topology = nullptr; PFN_vkCmdSetPrimitiveRestartEnable set_primitive_restart_enable = nullptr; PFN_vkCmdSetStencilReference set_stencil_reference = nullptr; @@ -2111,6 +2115,8 @@ ReplayResult prepare_draw(const Draw& draw, Resolve&& resolve, const ReplayFunct const GraphicsPipeline* pipeline = vk.graphics_pipeline(draw.pipeline); if (!pipeline || !pipeline->pipeline) return ReplayResult::unresolved_resource; if (pipeline->mesh != draw.mesh) return ReplayResult::invalid_draw; + if (pipeline->dynamic_viewport_count && (!vk.set_viewport_with_count || !vk.set_scissor_with_count)) + return ReplayResult::unsupported; if (draw.mesh && !vk.draw_mesh_tasks) return ReplayResult::unsupported; if (pipeline->bindless_set && !vk.bind_descriptor_sets) return ReplayResult::unsupported; if (pipeline->color_formats.size() > max_render_targets) return ReplayResult::unsupported; @@ -4218,14 +4224,35 @@ inline void emit(const PreparedList& prepared, VkCommandBuffer command_buffer, c vk.push_constants(command_buffer, graphics.layout, graphics.push_stages, 0, sizeof(data), &data); // Translated vertex shaders write D3D clip coordinates (y up); a negative-height viewport keeps the // image upright, and winding as D3D12 sees it. - const Viewport& v = draw->viewport; - const VkViewport viewport{v.x, v.y + v.height, v.width, -v.height, v.min_depth, v.max_depth}; - vk.set_viewport(command_buffer, 0, 1, &viewport); - const Rect& s = draw->scissor; - const VkRect2D scissor{{std::max(0, s.left), std::max(0, s.top)}, - {std::uint32_t(std::max(0, s.right - std::max(0, s.left))), - std::uint32_t(std::max(0, s.bottom - std::max(0, s.top)))}}; - vk.set_scissor(command_buffer, 0, 1, &scissor); + const std::uint32_t raw_vp_count = + (draw->views && draw->views->viewport_count) ? std::min(draw->views->viewport_count, 16u) : 1u; + const std::uint32_t vp_count = + graphics.dynamic_viewport_count ? (vk.multi_viewport ? raw_vp_count : 1u) : 1u; + VkViewport viewports[16]{}; + for (std::uint32_t vi = 0; vi < vp_count; ++vi) { + const Viewport& v = (draw->views && draw->views->viewport_count) ? draw->views->viewports[vi] : draw->viewport; + viewports[vi] = {v.x, v.y + v.height, v.width, -v.height, v.min_depth, v.max_depth}; + } + const std::uint32_t raw_sc_count = + (draw->views && draw->views->scissor_count) ? std::min(draw->views->scissor_count, 16u) : 1u; + VkRect2D scissors[16]{}; + for (std::uint32_t si = 0; si < vp_count; ++si) { + if (si < raw_sc_count) { + const Rect& s = (draw->views && draw->views->scissor_count) ? draw->views->scissors[si] : draw->scissor; + scissors[si] = {{std::max(0, s.left), std::max(0, s.top)}, + {std::uint32_t(std::max(0, s.right - std::max(0, s.left))), + std::uint32_t(std::max(0, s.bottom - std::max(0, s.top)))}}; + } else { + scissors[si] = {{0, 0}, {0, 0}}; + } + } + if (graphics.dynamic_viewport_count && vk.set_viewport_with_count && vk.set_scissor_with_count) { + vk.set_viewport_with_count(command_buffer, vp_count, viewports); + vk.set_scissor_with_count(command_buffer, vp_count, scissors); + } else { + vk.set_viewport(command_buffer, 0, 1, viewports); + vk.set_scissor(command_buffer, 0, 1, scissors); + } // A mesh pipeline has no input assembly: its topology comes from the shader, and neither the topology // nor primitive restart is dynamic state there (VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-07065). if (!draw->mesh) { diff --git a/runtime/test/d3d12_com_test.cpp b/runtime/test/d3d12_com_test.cpp index d1d4bf3a61..789ba5257d 100644 --- a/runtime/test/d3d12_com_test.cpp +++ b/runtime/test/d3d12_com_test.cpp @@ -143,6 +143,14 @@ int main(int argc, char** argv) { EXPECT(rt::d3d12::front_back_stencil_ref(list8.p, front, back) && front == 7 && back == 9); list8->ExecuteBundle(bundle.p); // the same closed bundle can be executed repeatedly + // Multi-viewport and multi-scissor recording (up to 16) closes cleanly; > 16 fails at Close. + const D3D12_VIEWPORT vps[2] = {{0.f, 0.f, 64.f, 64.f, 0.f, 1.f}, {64.f, 0.f, 64.f, 64.f, 0.f, 1.f}}; + const D3D12_RECT scs[2] = {{0, 0, 64, 64}, {64, 0, 128, 64}}; + list8->RSSetViewports(2, vps); + list8->RSSetScissorRects(2, scs); + list8->RSSetViewports(0, nullptr); + list8->RSSetScissorRects(0, nullptr); + ID3D12CommandList* bundle_submission[] = {bundle.p}; queue->ExecuteCommandLists(1, bundle_submission); // bundles are executed only inside direct lists EXPECT(rt::d3d12::last_execute_result(queue.p) == ReplayResult::unsupported); diff --git a/runtime/test/vk_test_device.h b/runtime/test/vk_test_device.h index 678d369e28..dd8d18babd 100644 --- a/runtime/test/vk_test_device.h +++ b/runtime/test/vk_test_device.h @@ -434,6 +434,7 @@ class Device { enable.shaderSampledImageArrayDynamicIndexing = bindless; enable.shaderStorageImageArrayDynamicIndexing = bindless; enable.logicOp = features.features.logicOp; // d3d12_draw_test's logic-op draw, where available + enable.multiViewport = features.features.multiViewport; enable.geometryShader = features.features.geometryShader; // d3d12_geometry_test, where available enable.shaderInt64 = features.features.shaderInt64; // translated shaders declare Int64 for their addresses const char* conditional_extension = VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME;