Windows changes.

This commit is contained in:
BearOso 2023-07-03 17:19:54 -05:00
parent e9b4f6d7fe
commit 744f69a264
9 changed files with 31 additions and 28 deletions

View file

@ -108,8 +108,19 @@ SplitPath splitpath(string path)
path = path.substr(2);
}
#endif
auto slash = path.rfind(SLASH_CHAR);
auto dot = path.rfind('.');
auto backslash = path.rfind('\\');
auto slash = path.rfind('/');
if (backslash != npos)
{
if (slash == npos || backslash > slash)
slash = backslash;
}
else if (slash != npos)
{
if (backslash != npos && backslash > slash)
slash = backslash;
}
auto dot = path.rfind('.');
if (dot != npos && slash != npos && dot < slash)
{

View file

@ -84,7 +84,7 @@ list(APPEND LIBS Qt6::Widgets Qt6::Gui ${SDL_LIBRARIES} ${ZLIB_LIBRARIES})
list(APPEND INCLUDES ${SDL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}${Qt6Gui_PRIVATE_INCLUDE_DIRS})
list(APPEND FLAGS ${SDL_COMPILE_FLAGS} ${ZLIB_COMPILE_FLAGS})
pkg_check_modules(PULSEAUDIO REQUIRED libpulse)
pkg_check_modules(PULSEAUDIO libpulse)
if(PULSEAUDIO_FOUND)
list(APPEND LIBS ${PULSEAUDIO_LIBRARIES})
list(APPEND INCLUDES ${PULSEAUDIO_INCLUDE_DIRS})

View file

@ -582,6 +582,7 @@ void S9xCloseSnapshotFile(STREAM file)
void S9xAutoSaveSRAM()
{
printf("%s\n", S9xGetFilename(".srm", SRAM_DIR).c_str());
Memory.SaveSRAM(S9xGetFilename(".srm", SRAM_DIR).c_str());
S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR).c_str());
}

View file

@ -256,7 +256,7 @@ bool Context::create_swapchain(int width, int height)
{
wait_idle();
swapchain = std::make_unique<Swapchain>(device, physical_device, queue, surface.get(), command_pool.get());
return swapchain->create(3, width, height);
return swapchain->create(2, width, height);
}
bool Context::recreate_swapchain(int width, int height)

View file

@ -402,8 +402,6 @@ bool ShaderChain::do_frame_without_swap(uint8_t *data, int width, int height, in
if (!context->swapchain->begin_frame())
return false;
current_frame_index = context->swapchain->get_current_frame();
auto cmd = context->swapchain->get_cmd();
update_and_propagate_sizes(width, height, viewport_width, viewport_height);
@ -519,6 +517,7 @@ bool ShaderChain::do_frame_without_swap(uint8_t *data, int width, int height, in
context->swapchain->end_frame_without_swap();
last_frame_index = current_frame_index;
current_frame_index = (current_frame_index + 1) % queue_size;
frame_count++;
return true;
}

View file

@ -55,7 +55,7 @@ SimpleOutput::~SimpleOutput()
void SimpleOutput::create_objects()
{
descriptors.clear();
for (size_t i = 0; i < swapchain->get_num_frames(); i++)
for (size_t i = 0; i < queue_size; i++)
{
vk::DescriptorSetAllocateInfo dsai{};
dsai
@ -67,7 +67,7 @@ void SimpleOutput::create_objects()
}
textures.clear();
textures.resize(swapchain->get_num_frames());
textures.resize(queue_size);
for (auto &t : textures)
{
t.init(context);
@ -223,10 +223,10 @@ bool SimpleOutput::do_frame_without_swap(uint8_t *buffer, int width, int height,
if (!swapchain->begin_frame())
return false;
auto &tex = textures[swapchain->get_current_frame()];
auto &tex = textures[current_frame];
auto &cmd = swapchain->get_cmd();
auto extents = swapchain->get_extents();
auto &dstset = descriptors[swapchain->get_current_frame()].get();
auto &dstset = descriptors[current_frame].get();
tex.from_buffer(cmd, (uint8_t *)buffer, width, height, byte_stride);
@ -254,6 +254,8 @@ bool SimpleOutput::do_frame_without_swap(uint8_t *buffer, int width, int height,
swapchain->end_render_pass();
swapchain->end_frame_without_swap();
current_frame = (current_frame + 1) % queue_size;
return true;
}

View file

@ -15,6 +15,9 @@ class SimpleOutput
void set_filter(bool on);
private:
const int queue_size = 3;
int current_frame = 0;
void create_pipeline();
void create_objects();

View file

@ -144,18 +144,18 @@ bool Swapchain::create(unsigned int desired_num_swapchain_images, int new_width,
return false;
auto swapchain_images = device.getSwapchainImagesKHR(swapchain_object.get());
vk::CommandBufferAllocateInfo command_buffer_allocate_info(command_pool, vk::CommandBufferLevel::ePrimary, max_latency);
vk::CommandBufferAllocateInfo command_buffer_allocate_info(command_pool, vk::CommandBufferLevel::ePrimary, swapchain_images.size());
auto command_buffers = device.allocateCommandBuffersUnique(command_buffer_allocate_info);
if (imageviewfbs.size() > num_swapchain_images)
num_swapchain_images = imageviewfbs.size();
frames.resize(max_latency);
frames.resize(num_swapchain_images);
imageviewfbs.resize(num_swapchain_images);
vk::FenceCreateInfo fence_create_info(vk::FenceCreateFlagBits::eSignaled);
for (int i = 0; i < max_latency; i++)
for (int i = 0; i < num_swapchain_images; i++)
{
// Create frame queue resources
auto &frame = frames[i];
@ -267,7 +267,7 @@ bool Swapchain::swap()
auto result = queue.presentKHR(present_info);
current_frame = (current_frame + 1) % max_latency;
current_frame = (current_frame + 1) % num_swapchain_images;
if (result != vk::Result::eSuccess)
return false;
@ -316,11 +316,6 @@ void Swapchain::end_render_pass()
get_cmd().endRenderPass();
}
unsigned int Swapchain::get_current_frame()
{
return current_frame;
}
bool Swapchain::wait_on_frame(int frame_num)
{
auto result = device.waitForFences(frames[frame_num].fence.get(), true, 33000000);
@ -337,9 +332,4 @@ vk::RenderPass &Swapchain::get_render_pass()
return render_pass.get();
}
unsigned int Swapchain::get_num_frames()
{
return max_latency;
}
} // namespace Vulkan

View file

@ -11,8 +11,6 @@ namespace Vulkan
class Swapchain
{
public:
const int max_latency = 3;
Swapchain(vk::Device device,
vk::PhysicalDevice physical_device,
vk::Queue queue,
@ -31,14 +29,13 @@ class Swapchain
// Returns true if vsync setting was changed, false if it was the same
bool set_vsync(bool on);
void on_render_pass_end(std::function<void()> function);
int get_num_frames() { return num_swapchain_images; }
vk::Image get_image();
vk::Framebuffer get_framebuffer();
vk::CommandBuffer &get_cmd();
unsigned int get_current_frame();
vk::Extent2D get_extents();
vk::RenderPass &get_render_pass();
unsigned int get_num_frames();
private:
std::function<void()> end_render_pass_function;