diff --git a/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp b/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp index 35a7bf22e..4bc554be0 100644 --- a/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp +++ b/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp @@ -32,7 +32,8 @@ Registers& registersFor(QueueState& queue, std::uint32_t opcode) { } void writeRegister(QueueState& queue, std::uint32_t opcode, std::uint32_t offset, std::uint32_t value) { - if ((opcode == 0x69 || opcode == 0x9f) && (offset == 0x8e || offset == 0x8f || offset == 0x318 || offset == 0x31b || offset == 0x31c || offset == 0x31d || offset == 0x390 || offset == 0x3b0 || offset == 0x3b8)) APS5_LOG_OUT("CONTEXT WRITE opcode=0x%x offset=0x%x value=0x%x", opcode, offset, value); + if ((opcode == 0x69 || opcode == 0x9f) && (offset == 0x8e || offset == 0x8f || offset == 0x318 || offset == 0x31b || offset == 0x31c || offset == 0x31d || offset == 0x390 || offset == 0x3b0 || offset == 0x3b8)) + APS5_LOG_OUT_DEBUG("CONTEXT WRITE opcode=0x%x offset=0x%x value=0x%x", opcode, offset, value); registersFor(queue, opcode).insert_or_assign(offset, value); if ((opcode == 0x64 || opcode == 0x79 || opcode == 0x7a) && offset == 0x243) queue.indexType = value & 3u; } @@ -306,7 +307,7 @@ DrawParameters ResolveDraw(std::span packet, const QueueSta const auto bytes = static_cast(packet[3]) * indexSize; require(bytes <= std::numeric_limits::max(), "index range size overflow"); GuestMemory::CheckRange(reinterpret_cast(address), static_cast(bytes), indexSize); - APS5_LOG_OUT("ResolveDraw context targetMask=0x%x shaderMask=0x%x indexCount=%u indexType=%u instances=%u", queue.context.contains(0x8e) ? queue.context.at(0x8e) : 0u, queue.context.contains(0x8f) ? queue.context.at(0x8f) : 0u, packet[3], queue.indexType, queue.instanceCount); + APS5_LOG_OUT_DEBUG("ResolveDraw context targetMask=0x%x shaderMask=0x%x indexCount=%u indexType=%u instances=%u", queue.context.contains(0x8e) ? queue.context.at(0x8e) : 0u, queue.context.contains(0x8f) ? queue.context.at(0x8f) : 0u, packet[3], queue.indexType, queue.instanceCount); return {address, packet[3], indexSize, queue.instanceCount, packet[4]}; } @@ -323,7 +324,7 @@ void Execute(std::span packet, QueueState& queue) { queue.markers.pop_back(); return; case 0x1a: - APS5_LOG_OUT("CONTEXT_STATE operation=%u targetMaskBefore=0x%x shaderMaskBefore=0x%x", packet[1], queue.context.contains(0x8e) ? queue.context.at(0x8e) : 0u, queue.context.contains(0x8f) ? queue.context.at(0x8f) : 0u); + APS5_LOG_OUT_DEBUG("CONTEXT_STATE operation=%u targetMaskBefore=0x%x shaderMaskBefore=0x%x", packet[1], queue.context.contains(0x8e) ? queue.context.at(0x8e) : 0u, queue.context.contains(0x8f) ? queue.context.at(0x8f) : 0u); switch (packet[1]) { case 0: queue.ClearContext(); break; case 1: case 3: @@ -337,7 +338,7 @@ void Execute(std::span packet, QueueState& queue) { queue.savedContext.reset(); break; } - APS5_LOG_OUT("CONTEXT_STATE done operation=%u targetMaskAfter=0x%x shaderMaskAfter=0x%x", packet[1], queue.context.contains(0x8e) ? queue.context.at(0x8e) : 0u, queue.context.contains(0x8f) ? queue.context.at(0x8f) : 0u); + APS5_LOG_OUT_DEBUG("CONTEXT_STATE done operation=%u targetMaskAfter=0x%x shaderMaskAfter=0x%x", packet[1], queue.context.contains(0x8e) ? queue.context.at(0x8e) : 0u, queue.context.contains(0x8f) ? queue.context.at(0x8f) : 0u); return; default: throw std::runtime_error("custom packet requires driver execution"); } @@ -345,7 +346,7 @@ void Execute(std::span packet, QueueState& queue) { ((packet[0] & 2u) == 0 ? queue.drawIndirectBase : queue.dispatchIndirectBase) = address(packet[2], packet[3]); return; case 0x12: - APS5_LOG_OUT("CLEAR_STATE targetMaskBefore=0x%x shaderMaskBefore=0x%x", queue.context.contains(0x8e) ? queue.context.at(0x8e) : 0u, queue.context.contains(0x8f) ? queue.context.at(0x8f) : 0u); + APS5_LOG_OUT_DEBUG("CLEAR_STATE targetMaskBefore=0x%x shaderMaskBefore=0x%x", queue.context.contains(0x8e) ? queue.context.at(0x8e) : 0u, queue.context.contains(0x8f) ? queue.context.at(0x8f) : 0u); queue.ClearContext(); return; case 0x13: queue.indexBufferSize = packet[1]; return; case 0x26: queue.indexBase = address(packet[1], packet[2]); return; diff --git a/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp b/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp index 159cadf67..76ace65cc 100644 --- a/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp +++ b/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp @@ -465,9 +465,9 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window) : state(std::make_u VulkanDevice::~VulkanDevice() = default; void VulkanDevice::WaitIdle() { - APS5_LOG_CHARS_OUT("VulkanDevice::WaitIdle begin"); + APS5_LOG_CHARS_OUT_DEBUG("VulkanDevice::WaitIdle begin"); check(state->DeviceFunction("vkDeviceWaitIdle")(state->device), "vkDeviceWaitIdle"); - APS5_LOG_CHARS_OUT("VulkanDevice::WaitIdle complete"); + APS5_LOG_CHARS_OUT_DEBUG("VulkanDevice::WaitIdle complete"); } void* VulkanDevice::Window() const { @@ -475,7 +475,7 @@ void* VulkanDevice::Window() const { } void VulkanDevice::Resize(std::uint32_t width, std::uint32_t height) { - APS5_LOG_OUT("Resize requested=%ux%u current=%ux%u", width, height, state->extent.width, state->extent.height); + APS5_LOG_OUT_DEBUG("Resize requested=%ux%u current=%ux%u", width, height, state->extent.width, state->extent.height); require(state->swapchain != VK_NULL_HANDLE, "cannot resize an unavailable swapchain"); if (width == 0 || height == 0) { state->extent = {0, 0}; @@ -514,7 +514,7 @@ void VulkanDevice::Resize(std::uint32_t width, std::uint32_t height) { check(getImages(state->device, replacement, &count, state->images.data()), "vkGetSwapchainImagesKHR resize"); state->images.resize(count); state->rendered.assign(count, VK_NULL_HANDLE); - APS5_LOG_OUT("Resize complete swapchain=%p extent=%ux%u images=%u", reinterpret_cast(state->swapchain), state->extent.width, state->extent.height, count); + APS5_LOG_OUT_DEBUG("Resize complete swapchain=%p extent=%ux%u images=%u", reinterpret_cast(state->swapchain), state->extent.width, state->extent.height, count); } bool VulkanDevice::Presentable() const { @@ -522,7 +522,7 @@ bool VulkanDevice::Presentable() const { } void VulkanDevice::PresentClear(std::uint32_t width, std::uint32_t height, bool opaque) { - APS5_LOG_OUT("PresentClear width=%u height=%u opaque=%u", width, height, static_cast(opaque)); + APS5_LOG_OUT_DEBUG("PresentClear width=%u height=%u opaque=%u", width, height, static_cast(opaque)); present(width, height, opaque, {}); } @@ -534,21 +534,21 @@ void VulkanDevice::PresentPixels(std::uint32_t width, std::uint32_t height, std: } void VulkanDevice::present(std::uint32_t width, std::uint32_t height, bool opaque, std::span pixels) { - APS5_LOG_OUT("present begin width=%u height=%u opaque=%u pixels=%zu", width, height, static_cast(opaque), pixels.size()); + APS5_LOG_OUT_DEBUG("present begin width=%u height=%u opaque=%u pixels=%zu", width, height, static_cast(opaque), pixels.size()); require(state->swapchain != VK_NULL_HANDLE, "device has no swapchain"); require(state->extent.width != 0 && state->extent.height != 0, "output window is minimized"); if (!pixels.empty()) state->Upload(pixels); - APS5_LOG_OUT("present source=%s bytes=%zu", pixels.empty() ? "clear" : "pixels", pixels.size()); + APS5_LOG_OUT_DEBUG("present source=%s bytes=%zu", pixels.empty() ? "clear" : "pixels", pixels.size()); auto wait = state->DeviceFunction("vkWaitForFences"); auto reset = state->DeviceFunction("vkResetFences"); const std::array fences{state->acquireFence, state->renderFence}; check(reset(state->device, static_cast(fences.size()), fences.data()), "vkResetFences"); - APS5_LOG_CHARS_OUT("present fences reset"); + APS5_LOG_CHARS_OUT_DEBUG("present fences reset"); std::uint32_t index = 0; check(state->DeviceFunction("vkAcquireNextImageKHR")(state->device, state->swapchain, 5'000'000'000ULL, VK_NULL_HANDLE, state->acquireFence, &index), "vkAcquireNextImageKHR"); - APS5_LOG_OUT("vkAcquireNextImageKHR index=%u imageCount=%zu", index, state->images.size()); + APS5_LOG_OUT_DEBUG("vkAcquireNextImageKHR index=%u imageCount=%zu", index, state->images.size()); check(wait(state->device, 1, &state->acquireFence, VK_TRUE, std::numeric_limits::max()), "vkWaitForFences acquire"); - APS5_LOG_OUT("Acquire fence complete index=%u", index); + APS5_LOG_OUT_DEBUG("Acquire fence complete index=%u", index); require(index < state->images.size() && index < state->rendered.size(), "acquired image index is out of range"); auto& rendered = state->rendered[index]; if (rendered != VK_NULL_HANDLE) { @@ -562,7 +562,7 @@ void VulkanDevice::present(std::uint32_t width, std::uint32_t height, bool opaqu VkCommandBufferBeginInfo begin{VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO}; begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; check(state->DeviceFunction("vkBeginCommandBuffer")(commands, &begin), "vkBeginCommandBuffer"); - APS5_LOG_OUT("Presentation command buffer begin commands=%p image=%p", reinterpret_cast(commands), reinterpret_cast(state->images[index])); + APS5_LOG_OUT_DEBUG("Presentation command buffer begin commands=%p image=%p", reinterpret_cast(commands), reinterpret_cast(state->images[index])); VkImageMemoryBarrier barrier{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; @@ -574,12 +574,12 @@ void VulkanDevice::present(std::uint32_t width, std::uint32_t height, bool opaqu auto pipelineBarrier = state->DeviceFunction("vkCmdPipelineBarrier"); pipelineBarrier(commands, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier); if (pixels.empty()) { - APS5_LOG_OUT("Recording swapchain clear opaque=%u image=%p", static_cast(opaque), reinterpret_cast(barrier.image)); + APS5_LOG_OUT_DEBUG("Recording swapchain clear opaque=%u image=%p", static_cast(opaque), reinterpret_cast(barrier.image)); VkClearColorValue clear{}; clear.float32[3] = opaque ? 1.0f : 0.0f; state->DeviceFunction("vkCmdClearColorImage")(commands, barrier.image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear, 1, &barrier.subresourceRange); } else { - APS5_LOG_OUT("Recording swapchain scaled blit width=%u height=%u bytes=%zu buffer=%p image=%p", width, height, pixels.size(), reinterpret_cast(state->uploadBuffer), reinterpret_cast(barrier.image)); + APS5_LOG_OUT_DEBUG("Recording swapchain scaled blit width=%u height=%u bytes=%zu buffer=%p image=%p", width, height, pixels.size(), reinterpret_cast(state->uploadBuffer), reinterpret_cast(barrier.image)); require(state->scaler != nullptr, "presentation scaler is unavailable"); state->scaler->EnsureSourceImage(width, height); state->scaler->RecordUpload(commands, state->uploadBuffer); @@ -604,16 +604,16 @@ void VulkanDevice::present(std::uint32_t width, std::uint32_t height, bool opaqu barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; pipelineBarrier(commands, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier); check(state->DeviceFunction("vkEndCommandBuffer")(commands), "vkEndCommandBuffer"); - APS5_LOG_CHARS_OUT("Presentation command buffer recorded"); + APS5_LOG_CHARS_OUT_DEBUG("Presentation command buffer recorded"); VkSubmitInfo submit{VK_STRUCTURE_TYPE_SUBMIT_INFO}; submit.commandBufferCount = 1; submit.pCommandBuffers = &commands; submit.signalSemaphoreCount = 1; submit.pSignalSemaphores = &rendered; check(state->DeviceFunction("vkQueueSubmit")(state->queue, 1, &submit, state->renderFence), "vkQueueSubmit clear"); - APS5_LOG_CHARS_OUT("Presentation vkQueueSubmit OK"); + APS5_LOG_CHARS_OUT_DEBUG("Presentation vkQueueSubmit OK"); check(wait(state->device, 1, &state->renderFence, VK_TRUE, std::numeric_limits::max()), "vkWaitForFences clear"); - APS5_LOG_CHARS_OUT("Presentation render fence complete"); + APS5_LOG_CHARS_OUT_DEBUG("Presentation render fence complete"); VkPresentInfoKHR present{VK_STRUCTURE_TYPE_PRESENT_INFO_KHR}; present.waitSemaphoreCount = 1; present.pWaitSemaphores = &rendered; @@ -621,7 +621,7 @@ void VulkanDevice::present(std::uint32_t width, std::uint32_t height, bool opaqu present.pSwapchains = &state->swapchain; present.pImageIndices = &index; check(state->DeviceFunction("vkQueuePresentKHR")(state->queue, &present), "vkQueuePresentKHR"); - APS5_LOG_OUT("vkQueuePresentKHR queued imageIndex=%u", index); + APS5_LOG_OUT_DEBUG("vkQueuePresentKHR queued imageIndex=%u", index); } ShaderRecompiler::SpirvTarget VulkanDevice::Target() const { @@ -668,7 +668,7 @@ void VulkanDevice::Draw(const Graphics::State& graphics, const Pm4::DrawParamete } void VulkanDevice::Dispatch(const ShaderRecompiler::RecompileResult& shader, std::uint32_t x, std::uint32_t y, std::uint32_t z, std::span snapshots) { - APS5_LOG_OUT("Dispatch groups=%ux%ux%u spirvWords=%zu bindings=%zu pushConstants=%zu", x, y, z, shader.spirv.size(), shader.bindings.size(), shader.pushConstants.size()); + APS5_LOG_OUT_DEBUG("Dispatch groups=%ux%ux%u spirvWords=%zu bindings=%zu pushConstants=%zu", x, y, z, shader.spirv.size(), shader.bindings.size(), shader.pushConstants.size()); if (shader.spirv.size() < 5 || shader.spirv[0] != 0x07230203u) { throw std::runtime_error("Vulkan dispatch: invalid SPIR-V"); } @@ -752,7 +752,7 @@ void VulkanDevice::Dispatch(const ShaderRecompiler::RecompileResult& shader, std submission.commandBufferCount = 1; submission.pCommandBuffers = &commands; check(submit(state->queue, 1, &submission, fence), "vkQueueSubmit"); - APS5_LOG_OUT("Dispatch submitted groups=%ux%ux%u", x, y, z); + APS5_LOG_OUT_DEBUG("Dispatch submitted groups=%ux%ux%u", x, y, z); const auto result = wait(state->device, 1, &fence, VK_TRUE, std::numeric_limits::max()); if (result != VK_SUCCESS && result != VK_ERROR_DEVICE_LOST) { const auto idle = state->DeviceFunction("vkDeviceWaitIdle")(state->device); @@ -760,7 +760,7 @@ void VulkanDevice::Dispatch(const ShaderRecompiler::RecompileResult& shader, std } check(result, "vkWaitForFences"); resources.WriteBack(); - APS5_LOG_OUT("Dispatch complete groups=%ux%ux%u", x, y, z); + APS5_LOG_OUT_DEBUG("Dispatch complete groups=%ux%ux%u", x, y, z); } catch (...) { cleanup(); throw; diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp index f58522949..5a6b6c98e 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp @@ -27,9 +27,9 @@ void imageBarrier(const Context& context, VkCommandBuffer commands, VkImage imag void Draw(const Context& context, const State& state, const Pm4::DrawParameters& draw, std::span shaders, std::span snapshots) { APS5_LOG_OUT("Draw indices=%u instances=%u indexSize=%u flags=%u indexAddress=0x%llx", draw.indexCount, draw.instanceCount, draw.indexSize, draw.flags, static_cast(draw.indexAddress)); - APS5_LOG_OUT("State colorTarget=%u render=%ux%u colorAddress=0x%llx colorBytes=%llu colorExtent=%ux%u", state.hasColorTarget ? 1u : 0u, state.renderExtent.width, state.renderExtent.height, static_cast(state.color.address), static_cast(state.color.bytes), state.color.extent.width, state.color.extent.height); - APS5_LOG_OUT("Viewport x=%f y=%f w=%f h=%f minDepth=%f maxDepth=%f", state.viewport.x, state.viewport.y, state.viewport.width, state.viewport.height, state.viewport.minDepth, state.viewport.maxDepth); - APS5_LOG_OUT("Scissor x=%d y=%d w=%u h=%u topology=%u cullMode=0x%x frontFace=%u", state.scissor.offset.x, state.scissor.offset.y, state.scissor.extent.width, state.scissor.extent.height, static_cast(state.topology), static_cast(state.cullMode), static_cast(state.frontFace)); + APS5_LOG_OUT_DEBUG("State colorTarget=%u render=%ux%u colorAddress=0x%llx colorBytes=%llu colorExtent=%ux%u", state.hasColorTarget ? 1u : 0u, state.renderExtent.width, state.renderExtent.height, static_cast(state.color.address), static_cast(state.color.bytes), state.color.extent.width, state.color.extent.height); + APS5_LOG_OUT_DEBUG("Viewport x=%f y=%f w=%f h=%f minDepth=%f maxDepth=%f", state.viewport.x, state.viewport.y, state.viewport.width, state.viewport.height, state.viewport.minDepth, state.viewport.maxDepth); + APS5_LOG_OUT_DEBUG("Scissor x=%d y=%d w=%u h=%u topology=%u cullMode=0x%x frontFace=%u", state.scissor.offset.x, state.scissor.offset.y, state.scissor.extent.width, state.scissor.extent.height, static_cast(state.topology), static_cast(state.cullMode), static_cast(state.frontFace)); Require(draw.indexed ? draw.flags == 0 : (draw.flags & ~0x20u) == 0, "draw modifiers are unsupported"); if (draw.indexed) { Require(draw.indexSize == 2 || draw.indexSize == 4, "only uint16 and uint32 index buffers are supported"); @@ -42,21 +42,21 @@ void Draw(const Context& context, const State& state, const Pm4::DrawParameters& } Require(draw.indexCount != 0 && draw.instanceCount != 0, "zero-count indexed draws are unsupported"); const auto indexBytes = static_cast(draw.indexCount) * draw.indexSize; - APS5_LOG_OUT("Index buffer bytes=%llu", static_cast(indexBytes)); + APS5_LOG_OUT_DEBUG("Index buffer bytes=%llu", static_cast(indexBytes)); Require(indexBytes <= std::numeric_limits::max(), "index buffer size overflow"); if (draw.indexed) GuestMemory::CheckRange(reinterpret_cast(draw.indexAddress), static_cast(indexBytes), draw.indexSize); - APS5_LOG_CHARS_OUT("Index buffer range OK"); + APS5_LOG_CHARS_OUT_DEBUG("Index buffer range OK"); Require(!draw.indexed || !state.hasColorTarget || draw.indexAddress + indexBytes <= state.color.address || state.color.address + state.color.bytes <= draw.indexAddress, "index buffer aliases the render target"); if (state.rectList) Require(draw.indexCount % 3 == 0, "incomplete rect-list primitive"); - APS5_LOG_CHARS_OUT("ValidateShaders"); + APS5_LOG_CHARS_OUT_DEBUG("ValidateShaders"); ValidateShaders(shaders, state, context.subgroup, context.fragmentShaderBarycentric); - APS5_LOG_CHARS_OUT("ValidateShaders OK"); + APS5_LOG_CHARS_OUT_DEBUG("ValidateShaders OK"); const auto shaderStages = PipelineStages(shaders); - APS5_LOG_OUT("PipelineStages=0x%x", static_cast(shaderStages)); + APS5_LOG_OUT_DEBUG("PipelineStages=0x%x", static_cast(shaderStages)); std::uint32_t meshGroups = 0; if (state.stages.mesh) { Require(draw.firstVertex == 0 && draw.firstInstance == 0, "mesh draw offsets are unsupported"); - APS5_LOG_CHARS_OUT("Mesh path"); + APS5_LOG_CHARS_OUT_DEBUG("Mesh path"); Require(context.meshShader, "device does not support mesh shaders"); const auto& mesh = *state.stages.mesh; const auto inputSize = mesh.inputPrimitive == 1 ? 1u : mesh.inputPrimitive == 2 ? 2u : 3u; @@ -64,7 +64,7 @@ void Draw(const Context& context, const State& state, const Pm4::DrawParameters& const auto step = mesh.inputPrimitive == 6 ? 1u : inputSize; const auto primitives = (draw.indexCount - inputSize) / step + 1u; meshGroups = (primitives - 1u) / mesh.primitivesPerGroup + 1u; - APS5_LOG_OUT("Mesh primitives=%u groups=%u", primitives, meshGroups); + APS5_LOG_OUT_DEBUG("Mesh primitives=%u groups=%u", primitives, meshGroups); Require(meshGroups <= context.meshLimits.maxMeshWorkGroupCount[0] && draw.instanceCount <= context.meshLimits.maxMeshWorkGroupCount[1] && static_cast(meshGroups) * draw.instanceCount <= context.meshLimits.maxMeshWorkGroupTotalCount, "mesh draw exceeds workgroup count limits"); } if (state.stages.tessellation) Require(draw.indexCount % state.stages.tessellation->inputControlPoints == 0, "incomplete tessellation patch"); @@ -86,7 +86,7 @@ void Draw(const Context& context, const State& state, const Pm4::DrawParameters& maxIndex = std::max(maxIndex, index); } } - APS5_LOG_CHARS_OUT("Index validation OK"); + APS5_LOG_CHARS_OUT_DEBUG("Index validation OK"); const auto& attributes = shaders.front().program->vertexAttributes; static_cast(BuildVertexInputLayout(context, attributes)); std::vector> vertexBuffers; @@ -106,50 +106,50 @@ void Draw(const Context& context, const State& state, const Pm4::DrawParameters& std::unique_ptr transfer; std::unique_ptr target; if (state.hasColorTarget) { - APS5_LOG_OUT("Creating color target address=0x%llx bytes=%llu extent=%ux%u", static_cast(state.color.address), static_cast(state.color.bytes), state.color.extent.width, state.color.extent.height); + APS5_LOG_OUT_DEBUG("Creating color target address=0x%llx bytes=%llu extent=%ux%u", static_cast(state.color.address), static_cast(state.color.bytes), state.color.extent.width, state.color.extent.height); const ColorTargetLayout colorLayout(state.color.extent.width, state.color.extent.height, state.color.tileMode); transfer = std::make_unique(context, colorLayout.LinearBytes(), VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT); - APS5_LOG_CHARS_OUT("Transfer buffer created"); + APS5_LOG_CHARS_OUT_DEBUG("Transfer buffer created"); ReadColorTarget(state.color, transfer->Bytes()); - APS5_LOG_CHARS_OUT("Color target read from guest memory"); + APS5_LOG_CHARS_OUT_DEBUG("Color target read from guest memory"); target = std::make_unique(context, state.color, state.blend.blendEnable != 0); - APS5_LOG_CHARS_OUT("RenderTarget created"); + APS5_LOG_CHARS_OUT_DEBUG("RenderTarget created"); } - APS5_LOG_OUT("Color target object=%u", target ? 1u : 0u); - APS5_LOG_CHARS_OUT("Creating ShaderResources"); + APS5_LOG_OUT_DEBUG("Color target object=%u", target ? 1u : 0u); + APS5_LOG_CHARS_OUT_DEBUG("Creating ShaderResources"); ShaderResources resources(context, shaders, state.color, draw.indexAddress, static_cast(indexBytes), snapshots); - APS5_LOG_CHARS_OUT("ShaderResources created"); - APS5_LOG_CHARS_OUT("Creating Pipeline"); + APS5_LOG_CHARS_OUT_DEBUG("ShaderResources created"); + APS5_LOG_CHARS_OUT_DEBUG("Creating Pipeline"); Pipeline pipeline(context, state, target.get(), resources, shaders); - APS5_LOG_CHARS_OUT("Pipeline created"); - APS5_LOG_CHARS_OUT("Creating CommandBatch"); + APS5_LOG_CHARS_OUT_DEBUG("Pipeline created"); + APS5_LOG_CHARS_OUT_DEBUG("Creating CommandBatch"); CommandBatch batch(context); const auto commands = batch.Handle(); - APS5_LOG_CHARS_OUT("CommandBatch created"); + APS5_LOG_CHARS_OUT_DEBUG("CommandBatch created"); VkMemoryBarrier upload{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; upload.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; upload.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; context.Function("vkCmdPipelineBarrier")(commands, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | shaderStages, 0, 1, &upload, 0, nullptr, 0, nullptr); - APS5_LOG_CHARS_OUT("Upload barrier recorded"); + APS5_LOG_CHARS_OUT_DEBUG("Upload barrier recorded"); VkBufferImageCopy copy{}; copy.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; copy.imageExtent = {state.color.extent.width, state.color.extent.height, 1}; if (state.hasColorTarget) { - APS5_LOG_CHARS_OUT("Copying guest color target to Vulkan image"); + APS5_LOG_CHARS_OUT_DEBUG("Copying guest color target to Vulkan image"); imageBarrier(context, commands, target->Image(), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, VK_ACCESS_TRANSFER_WRITE_BIT); context.Function("vkCmdCopyBufferToImage")(commands, transfer->Handle(), target->Image(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ©); imageBarrier(context, commands, target->Image(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT); - APS5_LOG_CHARS_OUT("Guest color target upload recorded"); + APS5_LOG_CHARS_OUT_DEBUG("Guest color target upload recorded"); } - APS5_LOG_OUT("Beginning pipeline renderExtent=%ux%u", state.renderExtent.width, state.renderExtent.height); + APS5_LOG_OUT_DEBUG("Beginning pipeline renderExtent=%ux%u", state.renderExtent.width, state.renderExtent.height); pipeline.Begin(commands, state.renderExtent); - APS5_LOG_CHARS_OUT("Pipeline Begin OK"); + APS5_LOG_CHARS_OUT_DEBUG("Pipeline Begin OK"); resources.Bind(commands, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.Layout()); - APS5_LOG_CHARS_OUT("Resources bound"); + APS5_LOG_CHARS_OUT_DEBUG("Resources bound"); pipeline.PushConstants(commands, shaders); - APS5_LOG_CHARS_OUT("Push constants recorded"); + APS5_LOG_CHARS_OUT_DEBUG("Push constants recorded"); if (state.stages.mesh) { - APS5_LOG_OUT("vkCmdDrawMeshTasksEXT groups=%u instances=%u", meshGroups, draw.instanceCount); + APS5_LOG_OUT_DEBUG("vkCmdDrawMeshTasksEXT groups=%u instances=%u", meshGroups, draw.instanceCount); context.Function("vkCmdDrawMeshTasksEXT")(commands, meshGroups, draw.instanceCount, 1); } else { if (!vertexHandles.empty()) context.Function("vkCmdBindVertexBuffers")(commands, 0, static_cast(vertexHandles.size()), vertexHandles.data(), vertexOffsets.data()); @@ -160,11 +160,11 @@ void Draw(const Context& context, const State& state, const Pm4::DrawParameters& context.Function("vkCmdDraw")(commands, draw.indexCount, draw.instanceCount, draw.firstVertex, draw.firstInstance); } } - APS5_LOG_CHARS_OUT("Draw recorded"); + APS5_LOG_CHARS_OUT_DEBUG("Draw recorded"); context.Function("vkCmdEndRenderPass")(commands); - APS5_LOG_CHARS_OUT("Render pass ended"); + APS5_LOG_CHARS_OUT_DEBUG("Render pass ended"); if (state.hasColorTarget) { - APS5_LOG_CHARS_OUT("Copying Vulkan image back to guest color target"); + APS5_LOG_CHARS_OUT_DEBUG("Copying Vulkan image back to guest color target"); imageBarrier(context, commands, target->Image(), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT); VkBufferMemoryBarrier reuse{VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER}; reuse.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; @@ -175,23 +175,23 @@ void Draw(const Context& context, const State& state, const Pm4::DrawParameters& reuse.size = transfer->Bytes().size(); context.Function("vkCmdPipelineBarrier")(commands, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 1, &reuse, 0, nullptr); context.Function("vkCmdCopyImageToBuffer")(commands, target->Image(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, transfer->Handle(), 1, ©); - APS5_LOG_CHARS_OUT("Color target copy-back recorded"); + APS5_LOG_CHARS_OUT_DEBUG("Color target copy-back recorded"); } VkMemoryBarrier download{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; download.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BIT; download.dstAccessMask = VK_ACCESS_HOST_READ_BIT; context.Function("vkCmdPipelineBarrier")(commands, VK_PIPELINE_STAGE_TRANSFER_BIT | shaderStages, VK_PIPELINE_STAGE_HOST_BIT, 0, 1, &download, 0, nullptr, 0, nullptr); - APS5_LOG_CHARS_OUT("Download barrier recorded"); - APS5_LOG_CHARS_OUT("SubmitAndWait"); + APS5_LOG_CHARS_OUT_DEBUG("Download barrier recorded"); + APS5_LOG_CHARS_OUT_DEBUG("SubmitAndWait"); batch.SubmitAndWait(); - APS5_LOG_CHARS_OUT("SubmitAndWait OK"); + APS5_LOG_CHARS_OUT_DEBUG("SubmitAndWait OK"); if (state.hasColorTarget) GuestMemory::CheckRange(reinterpret_cast(state.color.address), state.color.bytes, 256, true); - if (state.hasColorTarget) APS5_LOG_CHARS_OUT("Color target guest range OK"); - APS5_LOG_CHARS_OUT("Shader resources WriteBack"); + if (state.hasColorTarget) APS5_LOG_CHARS_OUT_DEBUG("Color target guest range OK"); + APS5_LOG_CHARS_OUT_DEBUG("Shader resources WriteBack"); resources.WriteBack(); - APS5_LOG_CHARS_OUT("Shader resources WriteBack OK"); + APS5_LOG_CHARS_OUT_DEBUG("Shader resources WriteBack OK"); if (state.hasColorTarget) WriteColorTarget(state.color, transfer->Bytes()); - if (state.hasColorTarget) APS5_LOG_OUT("Color target written to guest address=0x%llx bytes=%llu", static_cast(state.color.address), static_cast(state.color.bytes)); + if (state.hasColorTarget) APS5_LOG_OUT_DEBUG("Color target written to guest address=0x%llx bytes=%llu", static_cast(state.color.address), static_cast(state.color.bytes)); APS5_LOG_CHARS_OUT("Draw finished"); } diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp index f89986ad7..b823d276d 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp @@ -133,6 +133,13 @@ Module Inspect(const CompiledShader& compiled, const State& state, const VkPhysi const bool mesh = stage == Stage::Mesh; const bool control = stage == Stage::TessellationControl; const bool evaluation = stage == Stage::TessellationEvaluation; + const bool rectListControl = state.rectList && control; + if (rectListControl) { + Require(shader.bdaAbiVersion == ShaderRecompiler::BdaAbi::Version, "incompatible rect-list fault ABI version"); + Require(shader.bindings.size() == 1, "rect-list control shader must declare exactly one fault buffer"); + const auto& binding = shader.bindings.front(); + Require(binding.role == ShaderRecompiler::DescriptorRole::FaultBuffer && binding.kind == ShaderRecompiler::DescriptorKind::StorageBuffer && binding.descriptorSet == 0 && binding.count == 1 && binding.guestDescriptor.empty() && !binding.readOnly, "invalid rect-list fault buffer contract"); + } const auto model = mesh ? spv::ExecutionModelMeshEXT : control ? spv::ExecutionModelTessellationControl : evaluation ? spv::ExecutionModelTessellationEvaluation : vertex ? spv::ExecutionModelVertex : spv::ExecutionModelFragment; const auto& words = shader.spirv; Require(words.size() >= 5 && words[0] == spv::MagicNumber && words[1] >= 0x10000u && words[1] <= 0x10400u && words[3] != 0 && words[4] == 0, "invalid or unsupported SPIR-V header"); @@ -225,10 +232,16 @@ Module Inspect(const CompiledShader& compiled, const State& state, const VkPhysi case spv::OpSpecConstantComposite: case spv::OpSpecConstantOp: throw std::runtime_error("AGC graphics: unsupported SPIR-V extension, grouped decoration or specialization constant"); - case spv::OpMemoryModel: - Require(count == 3 && instruction[1] == (shader.bdaAbiVersion == ShaderRecompiler::BdaAbi::Version ? spv::AddressingModelPhysicalStorageBuffer64 : spv::AddressingModelLogical) && instruction[2] == spv::MemoryModelGLSL450, "unsupported SPIR-V memory model"); + case spv::OpMemoryModel: { + const auto addressingModel = shader.bdaAbiVersion == ShaderRecompiler::BdaAbi::Version && !rectListControl + ? spv::AddressingModelPhysicalStorageBuffer64 + : spv::AddressingModelLogical; + Require(count == 3, "invalid SPIR-V OpMemoryModel word count: " + std::to_string(count)); + Require(instruction[1] == addressingModel, "unsupported SPIR-V addressing model: " + std::to_string(instruction[1])); + Require(instruction[2] == spv::MemoryModelGLSL450, "unsupported SPIR-V memory model: " + std::to_string(instruction[2])); ++memoryModels; break; + } case spv::OpEntryPoint: Require(count >= 5 && instruction[1] == model && instruction[3] == 0x6e69616du && instruction[4] == 0, "expected a main entry point for the assigned graphics stage"); entryPoint = instruction[2]; diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp index 5934b47bc..4f6a7aecc 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp @@ -95,7 +95,7 @@ ShaderStages DecodeShaderStages(const QueueState& queue) { validate(!tessellation || !geometry, "combined tessellation and geometry is unsupported by the reference path"); const auto path = tessellation ? ShaderPath::Tessellation : geometry ? ShaderPath::Geometry : ShaderPath::Vertex; ShaderStages result{path, value, (value & 0x00400000u) != 0 ? 32u : 64u, (read(queue.context, 0x1b6) & 0x8000u) != 0 ? 32u : 64u, {}, {}}; - APS5_LOG_OUT("DecodeShaderStages value=0x%x primitive=%u path=%u vertexWave=%u", value, primitive, static_cast(result.path), result.vertexWaveSize); + APS5_LOG_OUT_DEBUG("DecodeShaderStages value=0x%x primitive=%u path=%u vertexWave=%u", value, primitive, static_cast(result.path), result.vertexWaveSize); if (path == ShaderPath::Vertex) { validate((value & 0x2000u) != 0, "legacy vertex routing without PRIMGEN_EN is unsupported"); validate((value & ~0x02402010u) == 0, "unsupported vertex routing, scheduling or wave-ID state"); @@ -133,7 +133,7 @@ State DecodeState(const QueueState& queue) { State result{}; result.stages = DecodeShaderStages(queue); const auto primitive = read(queue.userConfig, 0x242, "user-config"); - APS5_LOG_OUT("DecodeState primitive=%u path=%u vertexWave=%u", primitive, static_cast(result.stages.path), result.stages.vertexWaveSize); + APS5_LOG_OUT_DEBUG("DecodeState primitive=%u path=%u vertexWave=%u", primitive, static_cast(result.stages.path), result.stages.vertexWaveSize); switch (primitive) { case 1: Require(result.stages.mesh.has_value(), "point-list vertex rendering requires point-size output support"); result.topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; break; case 2: result.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; break; @@ -149,7 +149,7 @@ State DecodeState(const QueueState& queue) { case 6: result.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; break; default: throw std::runtime_error("AGC graphics: unsupported primitive type " + std::to_string(primitive)); } - APS5_LOG_OUT("Topology=%u", static_cast(result.topology)); + APS5_LOG_OUT_DEBUG("Topology=%u", static_cast(result.topology)); zero(queue.userConfig, 0x24b, ~0u, "primitive restart (GE_MULTI_PRIM_IB_RESET_EN)", "user-config"); zero(cx, 0x207, ~0u, "clip distances, layer, viewport or auxiliary vertex exports"); zero(cx, 0x200, ~0x007007f0u, "depth, stencil or conditional color writes"); @@ -193,11 +193,11 @@ State DecodeState(const QueueState& queue) { Require(read(cx, 0x202) == 0xcc0010u, "only normal color rendering with copy ROP is supported"); zero(cx, 0x1c4, ~0u, "depth or sample-mask export"); const auto exportFormat = read(cx, 0x1c5); - APS5_LOG_OUT("Export format=%u", exportFormat); + APS5_LOG_OUT_DEBUG("Export format=%u", exportFormat); Require(exportFormat == 4 || exportFormat == 9, "only FP16_ABGR or 32_ABGR color export is supported"); Require(read(cx, 0x1c3) == 4, "additional position exports are unsupported"); if (result.hasColorTarget) { - APS5_LOG_CHARS_OUT("Decoding color target"); + APS5_LOG_CHARS_OUT_DEBUG("Decoding color target"); const auto info = read(cx, 0x31c); const auto number = (info >> 8u) & 7u; const auto swap = (info >> 11u) & 3u; @@ -212,25 +212,25 @@ State DecodeState(const QueueState& queue) { const auto attrib3 = read(cx, 0x3b8); result.color.tileMode = DecodeColorTileMode(attrib3); result.color.extent = {((attrib2 >> 14u) & 0x3fffu) + 1u, (attrib2 & 0x3fffu) + 1u}; - APS5_LOG_OUT("Color extent=%ux%u attrib2=0x%x attrib3=0x%x", result.color.extent.width, result.color.extent.height, attrib2, attrib3); + APS5_LOG_OUT_DEBUG("Color extent=%ux%u attrib2=0x%x attrib3=0x%x", result.color.extent.width, result.color.extent.height, attrib2, attrib3); const ColorTargetLayout colorLayout(result.color.extent.width, result.color.extent.height, result.color.tileMode); const auto high = read(cx, 0x390); Require((high & ~0xffu) == 0, "invalid color address extension"); result.color.address = (static_cast(high) << 40u) | (static_cast(read(cx, 0x318)) << 8u); - APS5_LOG_OUT("Color address=0x%llx high=0x%x low=0x%x", static_cast(result.color.address), high, read(cx, 0x318)); + APS5_LOG_OUT_DEBUG("Color address=0x%llx high=0x%x low=0x%x", static_cast(result.color.address), high, read(cx, 0x318)); result.color.bytes = colorLayout.Bytes(); - APS5_LOG_OUT("Color bytes=%llu", static_cast(result.color.bytes)); + APS5_LOG_OUT_DEBUG("Color bytes=%llu", static_cast(result.color.bytes)); GuestMemory::CheckRange(reinterpret_cast(result.color.address), result.color.bytes, colorLayout.Alignment(), true); result.color.format = swap == 0 ? (number == 0 ? VK_FORMAT_R8G8B8A8_UNORM : VK_FORMAT_R8G8B8A8_SRGB) : (number == 0 ? VK_FORMAT_B8G8R8A8_UNORM : VK_FORMAT_B8G8R8A8_SRGB); result.color.componentMapping = 0xe4u; - APS5_LOG_OUT("Color VkFormat=%u", static_cast(result.color.format)); + APS5_LOG_OUT_DEBUG("Color VkFormat=%u", static_cast(result.color.format)); result.renderExtent = result.color.extent; - APS5_LOG_OUT("Render extent from color target=%ux%u", result.renderExtent.width, result.renderExtent.height); + APS5_LOG_OUT_DEBUG("Render extent from color target=%ux%u", result.renderExtent.width, result.renderExtent.height); } else { const auto screenBottomRight = read(cx, 0xd); APS5_LOG_OUT("No color target, screen BR register=0x%x", screenBottomRight); result.renderExtent = {screenBottomRight & 0xffffu, screenBottomRight >> 16u}; - APS5_LOG_OUT("Render extent from screen=%ux%u", result.renderExtent.width, result.renderExtent.height); + APS5_LOG_OUT_DEBUG("Render extent from screen=%ux%u", result.renderExtent.width, result.renderExtent.height); Require(result.renderExtent.width != 0 && result.renderExtent.height != 0, "empty framebuffer extent for a draw without color writes"); } const auto xs = readFloat(cx, 0x10f); @@ -241,7 +241,7 @@ State DecodeState(const QueueState& queue) { const auto zo = readFloat(cx, 0x114); const auto minDepth = result.negativeOneToOne ? zo - zs : zo; const auto maxDepth = zo + zs; - APS5_LOG_OUT("Viewport transform scale=(%f,%f,%f) offset=(%f,%f,%f) depth=(%f,%f)", xs, ys, zs, xo, yo, zo, minDepth, maxDepth); + APS5_LOG_OUT_DEBUG("Viewport transform scale=(%f,%f,%f) offset=(%f,%f,%f) depth=(%f,%f)", xs, ys, zs, xo, yo, zo, minDepth, maxDepth); if (!(xs > 0 && ys != 0 && std::isfinite(minDepth) && std::isfinite(maxDepth))) { std::ostringstream message; message << "AGC graphics: unsupported viewport transform: scale=(" << xs << ", " << ys << ", " << zs << "), offset=(" << xo << ", " << yo << ", " << zo << "), depth=(" << minDepth << ", " << maxDepth << "), negativeOneToOne=" << result.negativeOneToOne; @@ -249,20 +249,20 @@ State DecodeState(const QueueState& queue) { } Require(readFloat(cx, 0xb4) <= readFloat(cx, 0xb5), "inverted viewport depth clamp bounds"); result.viewport = {xo - xs, yo - ys, 2 * xs, 2 * ys, minDepth, maxDepth}; - APS5_LOG_OUT("Viewport x=%f y=%f w=%f h=%f minDepth=%f maxDepth=%f", result.viewport.x, result.viewport.y, result.viewport.width, result.viewport.height, result.viewport.minDepth, result.viewport.maxDepth); + APS5_LOG_OUT_DEBUG("Viewport x=%f y=%f w=%f h=%f minDepth=%f maxDepth=%f", result.viewport.x, result.viewport.y, result.viewport.width, result.viewport.height, result.viewport.minDepth, result.viewport.maxDepth); result.scissor = {{0, 0}, result.renderExtent}; intersect(result.scissor, cx, 0xc, true); intersect(result.scissor, cx, 0x81, false); intersect(result.scissor, cx, 0x90, false); if ((read(cx, 0x292) & 2u) != 0) intersect(result.scissor, cx, 0x94, false); - APS5_LOG_OUT("Scissor offset=(%d,%d) extent=%ux%u", result.scissor.offset.x, result.scissor.offset.y, result.scissor.extent.width, result.scissor.extent.height); + APS5_LOG_OUT_DEBUG("Scissor offset=(%d,%d) extent=%ux%u", result.scissor.offset.x, result.scissor.offset.y, result.scissor.extent.width, result.scissor.extent.height); if (result.hasColorTarget) { const auto blend = read(cx, 0x1e0); - APS5_LOG_OUT("Blend control=0x%x", blend); + APS5_LOG_OUT_DEBUG("Blend control=0x%x", blend); Require((blend & 0x0000e000u) == 0, "reserved blend control bits"); result.blend.colorWriteMask = targetMask; result.blend.blendEnable = (blend >> 30u) & 1u; - APS5_LOG_OUT("Blend enable=%u colorWriteMask=0x%x", result.blend.blendEnable ? 1u : 0u, result.blend.colorWriteMask); + APS5_LOG_OUT_DEBUG("Blend enable=%u colorWriteMask=0x%x", result.blend.blendEnable ? 1u : 0u, result.blend.colorWriteMask); if (result.blend.blendEnable) { Require((read(cx, 0x31c) & 0x10000u) == 0, "blend bypass conflicts with enabled blending"); result.blend.srcColorBlendFactor = blendFactor(blend & 0x1fu); @@ -275,7 +275,7 @@ State DecodeState(const QueueState& queue) { for (std::uint32_t i = 0; i < 4; ++i) result.blendConstants[i] = readFloat(cx, 0x105 + i); } } - APS5_LOG_OUT("DecodeState done colorTarget=%u render=%ux%u topology=%u", result.hasColorTarget ? 1u : 0u, result.renderExtent.width, result.renderExtent.height, static_cast(result.topology)); + APS5_LOG_OUT_DEBUG("DecodeState done colorTarget=%u render=%ux%u topology=%u", result.hasColorTarget ? 1u : 0u, result.renderExtent.width, result.renderExtent.height, static_cast(result.topology)); return result; } diff --git a/core/libs/prx/libc/include/general/LogMacros.hpp b/core/libs/prx/libc/include/general/LogMacros.hpp index c4eda2da1..213789e1f 100644 --- a/core/libs/prx/libc/include/general/LogMacros.hpp +++ b/core/libs/prx/libc/include/general/LogMacros.hpp @@ -56,4 +56,12 @@ _APS5_LOG_IMPL_NF(stdout, fmt); \ } \ } while (0) +#ifdef APS5_DEBUG_LOG +#define APS5_LOG_DEBUG(fmt, ...) _APS5_LOG_IMPL(stdout, fmt, __VA_ARGS__) +#define APS5_LOG_CHARS_OUT_DEBUG(fmt) _APS5_LOG_IMPL_NF(stdout, fmt) +#else +#define APS5_LOG_OUT_DEBUG(fmt, ...) ((void)0) +#define APS5_LOG_CHARS_OUT_DEBUG(fmt) ((void)0) +#endif + #endif diff --git a/core/shader/recompiler/Recompiler.cpp b/core/shader/recompiler/Recompiler.cpp index b7aaf010e..36084c196 100644 --- a/core/shader/recompiler/Recompiler.cpp +++ b/core/shader/recompiler/Recompiler.cpp @@ -20,6 +20,7 @@ #include "SpirvBackend/SpirvMemory/SpirvInputOutput.hpp" #include "Translation/include/Translation/InstructionTranslator.hpp" #include "Translation/include/Translation/ShaderInputInfoBuilder.hpp" +#include #include #include #include @@ -121,6 +122,8 @@ IrProgram PrepareResourceProgram(const RecompileRequest& request) { namespace { RecompileResult RecompileImpl(const RecompileRequest& request) { + const auto recompileStart = std::chrono::steady_clock::now(); + auto program = PrepareResourceProgram(request); const auto inputInfo = BuildShaderStageInputInfo(toShaderStageKind(request.shader.stage), request.context); constexpr DeadCodeEliminator deadCodeEliminator; @@ -160,7 +163,11 @@ RecompileResult RecompileImpl(const RecompileRequest& request) { const auto spirv = spirvEmitter.Emit(program, inputInfo, bindings, targetOptions); RecompileResult result; + + const auto validationStart = std::chrono::steady_clock::now(); result.spirv = ValidateAndOptimizeSpirv(spirv, request.target.vulkanVersion, request.target.spirvVersion); + const auto validationEnd = std::chrono::steady_clock::now(); + result.bdaAbiVersion = program.Info().usesDma ? request.target.bdaAbiVersion : 0u; result.bindings = bindings.bindings; result.pushConstants = bindings.pushConstants; @@ -179,7 +186,11 @@ RecompileResult RecompileImpl(const RecompileRequest& request) { } } - std::fprintf(stdout, "[RecompileImpl] shader recompiled\n"); + const auto recompileEnd = std::chrono::steady_clock::now(); + const auto recompileTime = std::chrono::duration(recompileEnd - recompileStart).count(); + const auto validationTime = std::chrono::duration(validationEnd - validationStart).count(); + + std::fprintf(stdout, "[RecompileImpl] shader recompiled in %.3f ms, ValidateAndOptimizeSpirv %.3f ms\n", recompileTime, validationTime); std::fflush(stdout); return result; }