forked from MoonsideGames/Refresh
Compare commits
No commits in common. "2b773101c822fbad217b5df478011c5c9284f32d" and "903192cb4c886920186f078bc1638a6a0d1e8c88" have entirely different histories.
2b773101c8
...
903192cb4c
|
@ -1168,9 +1168,15 @@ REFRESHAPI Refresh_TextureFormat Refresh_GetSwapchainFormat(
|
|||
* A command buffer may only be used on the thread that
|
||||
* it was acquired on. Using it on any other thread is an error.
|
||||
*
|
||||
* fixed:
|
||||
* If a command buffer is designated as fixed, it can be
|
||||
* acquired once, have commands recorded into it, and
|
||||
* be re-submitted indefinitely.
|
||||
*
|
||||
*/
|
||||
REFRESHAPI Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
|
||||
Refresh_Device *device
|
||||
Refresh_Device *device,
|
||||
uint8_t fixed
|
||||
);
|
||||
|
||||
/* Acquires a texture to use for presentation.
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
partial class Program
|
||||
{
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
if (args.Length < 2)
|
||||
{
|
||||
Console.WriteLine("Usage: refreshc <path-to-glsl> <output-directory>");
|
||||
return 1;
|
||||
}
|
||||
|
||||
string glslPath = args[0];
|
||||
string outputDir = args[1];
|
||||
|
||||
if (!ValidateArgs(glslPath, outputDir))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
string shaderName = Path.GetFileNameWithoutExtension(glslPath);
|
||||
string shaderType = Path.GetExtension(glslPath);
|
||||
string spirvPath = Path.Combine(outputDir, $"{shaderName}.spv");
|
||||
|
||||
if (CompileGlslToSpirv(glslPath, shaderName, spirvPath) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
string hlslPath = Path.Combine(outputDir, $"{shaderName}.hlsl");
|
||||
if (TranslateSpirvToHlsl(spirvPath, hlslPath) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// FIXME: Is there a cross-platform way to compile HLSL to DXBC?
|
||||
|
||||
#if PS5
|
||||
if (TranslateHlslToPS5(hlslPath, shaderName, shaderType, outputDir) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool ValidateArgs(string glslPath, string outputDir)
|
||||
{
|
||||
if (!File.Exists(glslPath))
|
||||
{
|
||||
Console.WriteLine($"refreshc: glsl source file ({glslPath}) does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
string ext = Path.GetExtension(glslPath);
|
||||
if (ext != ".vert" && ext != ".frag" && ext != ".comp")
|
||||
{
|
||||
Console.WriteLine("refreshc: Expected glsl source file with extension '.vert', '.frag', or '.comp'");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(outputDir))
|
||||
{
|
||||
Console.WriteLine($"refreshc: Output directory ({outputDir}) does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int CompileGlslToSpirv(string glslPath, string shaderName, string outputPath)
|
||||
{
|
||||
Process glslc = Process.Start(
|
||||
"glslc",
|
||||
$"{glslPath} -o {outputPath}"
|
||||
);
|
||||
glslc.WaitForExit();
|
||||
if (glslc.ExitCode != 0)
|
||||
{
|
||||
Console.WriteLine($"refreshc: Could not compile GLSL code");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int TranslateSpirvToHlsl(string spirvPath, string outputPath)
|
||||
{
|
||||
Process spirvcross = Process.Start(
|
||||
"spirv-cross",
|
||||
$"{spirvPath} --hlsl --shader-model 50 --output {outputPath}"
|
||||
);
|
||||
spirvcross.WaitForExit();
|
||||
if (spirvcross.ExitCode != 0)
|
||||
{
|
||||
Console.WriteLine($"refreshc: Could not translate SPIR-V to HLSL");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetName>refreshc</TargetName>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -789,11 +789,13 @@ void Refresh_UnclaimWindow(
|
|||
}
|
||||
|
||||
Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
|
||||
Refresh_Device *device
|
||||
Refresh_Device *device,
|
||||
uint8_t fixed
|
||||
) {
|
||||
NULL_RETURN_NULL(device);
|
||||
return device->AcquireCommandBuffer(
|
||||
device->driverData
|
||||
device->driverData,
|
||||
fixed
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -470,7 +470,8 @@ struct Refresh_Device
|
|||
);
|
||||
|
||||
Refresh_CommandBuffer* (*AcquireCommandBuffer)(
|
||||
Refresh_Renderer *driverData
|
||||
Refresh_Renderer *driverData,
|
||||
uint8_t fixed
|
||||
);
|
||||
|
||||
Refresh_Texture* (*AcquireSwapchainTexture)(
|
||||
|
|
|
@ -1500,6 +1500,10 @@ typedef struct VulkanCommandPool VulkanCommandPool;
|
|||
typedef struct VulkanCommandBuffer
|
||||
{
|
||||
VkCommandBuffer commandBuffer;
|
||||
uint8_t fixed;
|
||||
uint8_t submitted;
|
||||
uint8_t renderPassInProgress;
|
||||
|
||||
VulkanCommandPool *commandPool;
|
||||
|
||||
VulkanPresentData *presentDatas;
|
||||
|
@ -4658,7 +4662,11 @@ static void VULKAN_INTERNAL_BeginCommandBuffer(
|
|||
beginInfo.pNext = NULL;
|
||||
beginInfo.flags = 0;
|
||||
beginInfo.pInheritanceInfo = NULL;
|
||||
|
||||
if (!commandBuffer->fixed)
|
||||
{
|
||||
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
|
||||
}
|
||||
|
||||
result = renderer->vkBeginCommandBuffer(
|
||||
commandBuffer->commandBuffer,
|
||||
|
@ -8476,6 +8484,8 @@ static void VULKAN_BeginRenderPass(
|
|||
VK_SUBPASS_CONTENTS_INLINE
|
||||
);
|
||||
|
||||
vulkanCommandBuffer->renderPassInProgress = 1;
|
||||
|
||||
SDL_stack_free(clearValues);
|
||||
|
||||
for (i = 0; i < colorAttachmentCount; i += 1)
|
||||
|
@ -8612,6 +8622,7 @@ static void VULKAN_EndRenderPass(
|
|||
vulkanCommandBuffer->renderPassDepthTexture = NULL;
|
||||
|
||||
vulkanCommandBuffer->currentGraphicsPipeline = NULL;
|
||||
vulkanCommandBuffer->renderPassInProgress = 0;
|
||||
}
|
||||
|
||||
static void VULKAN_BindGraphicsPipeline(
|
||||
|
@ -9186,7 +9197,8 @@ static VulkanCommandBuffer* VULKAN_INTERNAL_GetInactiveCommandBufferFromPool(
|
|||
}
|
||||
|
||||
static Refresh_CommandBuffer* VULKAN_AcquireCommandBuffer(
|
||||
Refresh_Renderer *driverData
|
||||
Refresh_Renderer *driverData,
|
||||
uint8_t fixed
|
||||
) {
|
||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||
VkResult result;
|
||||
|
@ -9209,6 +9221,10 @@ static Refresh_CommandBuffer* VULKAN_AcquireCommandBuffer(
|
|||
commandBuffer->fragmentUniformBuffer = NULL;
|
||||
commandBuffer->computeUniformBuffer = NULL;
|
||||
|
||||
commandBuffer->fixed = fixed;
|
||||
commandBuffer->submitted = 0;
|
||||
|
||||
commandBuffer->renderPassInProgress = 0;
|
||||
commandBuffer->renderPassColorTargetCount = 0;
|
||||
|
||||
VULKAN_INTERNAL_BeginCommandBuffer(renderer, commandBuffer);
|
||||
|
@ -9904,6 +9920,7 @@ static void VULKAN_Submit(
|
|||
);
|
||||
}
|
||||
|
||||
((VulkanCommandBuffer*)pCommandBuffers[i])->submitted = 1;
|
||||
renderer->submittedCommandBuffers[renderer->submittedCommandBufferCount] = (VulkanCommandBuffer*) pCommandBuffers[i];
|
||||
renderer->submittedCommandBufferCount += 1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue