Skip to content

Commit

Permalink
Windows changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bearoso committed Aug 25, 2023
1 parent e9b4f6d commit 744f69a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 28 deletions.
15 changes: 13 additions & 2 deletions fscompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
1 change: 1 addition & 0 deletions qt/src/Snes9xController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion vulkan/vulkan_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions vulkan/vulkan_shader_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 6 additions & 4 deletions vulkan/vulkan_simple_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions vulkan/vulkan_simple_output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
18 changes: 4 additions & 14 deletions vulkan/vulkan_swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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
5 changes: 1 addition & 4 deletions vulkan/vulkan_swapchain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 744f69a

Please sign in to comment.