2016-02-16 19:24:00 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2016 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2017-12-12 07:55:31 +00:00
|
|
|
*
|
2016-02-16 19:24:00 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SHADER_VULKAN_H
|
|
|
|
#define SHADER_VULKAN_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
2016-03-01 01:47:16 +00:00
|
|
|
|
2016-02-29 22:31:51 +00:00
|
|
|
#include <boolean.h>
|
2016-06-03 06:06:49 +00:00
|
|
|
#include <retro_common_api.h>
|
2016-02-16 19:24:00 +00:00
|
|
|
|
2016-06-03 06:06:49 +00:00
|
|
|
#include "../common/vulkan_common.h"
|
|
|
|
|
|
|
|
RETRO_BEGIN_DECLS
|
2016-02-16 19:24:00 +00:00
|
|
|
|
|
|
|
typedef struct vulkan_filter_chain vulkan_filter_chain_t;
|
|
|
|
|
|
|
|
enum vulkan_filter_chain_filter
|
|
|
|
{
|
2016-02-20 15:37:59 +00:00
|
|
|
VULKAN_FILTER_CHAIN_LINEAR = 0,
|
2016-07-31 13:42:57 +00:00
|
|
|
VULKAN_FILTER_CHAIN_NEAREST = 1,
|
|
|
|
VULKAN_FILTER_CHAIN_COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vulkan_filter_chain_address
|
|
|
|
{
|
2017-05-10 04:40:21 +00:00
|
|
|
VULKAN_FILTER_CHAIN_ADDRESS_REPEAT = 0,
|
|
|
|
VULKAN_FILTER_CHAIN_ADDRESS_MIRRORED_REPEAT = 1,
|
|
|
|
VULKAN_FILTER_CHAIN_ADDRESS_CLAMP_TO_EDGE = 2,
|
|
|
|
VULKAN_FILTER_CHAIN_ADDRESS_CLAMP_TO_BORDER = 3,
|
2016-07-31 13:42:57 +00:00
|
|
|
VULKAN_FILTER_CHAIN_ADDRESS_MIRROR_CLAMP_TO_EDGE = 4,
|
|
|
|
VULKAN_FILTER_CHAIN_ADDRESS_COUNT
|
2016-02-16 19:24:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct vulkan_filter_chain_texture
|
|
|
|
{
|
2016-03-25 13:51:37 +00:00
|
|
|
VkImage image;
|
2016-02-16 19:24:00 +00:00
|
|
|
VkImageView view;
|
|
|
|
VkImageLayout layout;
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum vulkan_filter_chain_scale
|
|
|
|
{
|
|
|
|
VULKAN_FILTER_CHAIN_SCALE_ORIGINAL,
|
|
|
|
VULKAN_FILTER_CHAIN_SCALE_SOURCE,
|
|
|
|
VULKAN_FILTER_CHAIN_SCALE_VIEWPORT,
|
|
|
|
VULKAN_FILTER_CHAIN_SCALE_ABSOLUTE
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vulkan_filter_chain_pass_info
|
|
|
|
{
|
2017-12-12 07:55:31 +00:00
|
|
|
/* For the last pass, make sure VIEWPORT scale
|
2016-02-20 15:37:59 +00:00
|
|
|
* with scale factors of 1 are used. */
|
2016-02-16 19:24:00 +00:00
|
|
|
enum vulkan_filter_chain_scale scale_type_x;
|
|
|
|
enum vulkan_filter_chain_scale scale_type_y;
|
|
|
|
float scale_x;
|
|
|
|
float scale_y;
|
|
|
|
|
|
|
|
/* Ignored for the last pass, swapchain info will be used instead. */
|
|
|
|
VkFormat rt_format;
|
|
|
|
|
|
|
|
/* The filter to use for source in this pass. */
|
|
|
|
enum vulkan_filter_chain_filter source_filter;
|
2016-07-31 13:42:57 +00:00
|
|
|
enum vulkan_filter_chain_filter mip_filter;
|
|
|
|
enum vulkan_filter_chain_address address;
|
2016-07-31 17:52:15 +00:00
|
|
|
|
|
|
|
/* Maximum number of mip-levels to use. */
|
|
|
|
unsigned max_levels;
|
2016-02-16 19:24:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct vulkan_filter_chain_swapchain_info
|
|
|
|
{
|
|
|
|
VkViewport viewport;
|
|
|
|
VkFormat format;
|
|
|
|
VkRenderPass render_pass;
|
|
|
|
unsigned num_indices;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vulkan_filter_chain_create_info
|
|
|
|
{
|
|
|
|
VkDevice device;
|
2016-03-26 18:38:44 +00:00
|
|
|
VkPhysicalDevice gpu;
|
2016-02-16 19:24:00 +00:00
|
|
|
const VkPhysicalDeviceMemoryProperties *memory_properties;
|
|
|
|
VkPipelineCache pipeline_cache;
|
2016-07-31 10:26:14 +00:00
|
|
|
VkQueue queue;
|
|
|
|
VkCommandPool command_pool;
|
2016-02-16 19:24:00 +00:00
|
|
|
unsigned num_passes;
|
|
|
|
|
2016-03-25 13:51:37 +00:00
|
|
|
VkFormat original_format;
|
2016-02-16 19:24:00 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned width, height;
|
|
|
|
} max_input_size;
|
|
|
|
struct vulkan_filter_chain_swapchain_info swapchain;
|
|
|
|
};
|
|
|
|
|
|
|
|
vulkan_filter_chain_t *vulkan_filter_chain_new(
|
|
|
|
const struct vulkan_filter_chain_create_info *info);
|
|
|
|
void vulkan_filter_chain_free(vulkan_filter_chain_t *chain);
|
|
|
|
|
|
|
|
void vulkan_filter_chain_set_shader(vulkan_filter_chain_t *chain,
|
|
|
|
unsigned pass,
|
|
|
|
VkShaderStageFlags stage,
|
|
|
|
const uint32_t *spirv,
|
|
|
|
size_t spirv_words);
|
|
|
|
|
|
|
|
void vulkan_filter_chain_set_pass_info(vulkan_filter_chain_t *chain,
|
|
|
|
unsigned pass,
|
|
|
|
const struct vulkan_filter_chain_pass_info *info);
|
|
|
|
|
|
|
|
bool vulkan_filter_chain_update_swapchain_info(vulkan_filter_chain_t *chain,
|
|
|
|
const struct vulkan_filter_chain_swapchain_info *info);
|
|
|
|
|
|
|
|
void vulkan_filter_chain_notify_sync_index(vulkan_filter_chain_t *chain,
|
|
|
|
unsigned index);
|
|
|
|
|
|
|
|
bool vulkan_filter_chain_init(vulkan_filter_chain_t *chain);
|
|
|
|
|
|
|
|
void vulkan_filter_chain_set_input_texture(vulkan_filter_chain_t *chain,
|
|
|
|
const struct vulkan_filter_chain_texture *texture);
|
|
|
|
|
2016-03-25 21:06:31 +00:00
|
|
|
void vulkan_filter_chain_set_frame_count(vulkan_filter_chain_t *chain,
|
|
|
|
uint64_t count);
|
|
|
|
|
|
|
|
void vulkan_filter_chain_set_frame_count_period(vulkan_filter_chain_t *chain,
|
|
|
|
unsigned pass,
|
|
|
|
unsigned period);
|
|
|
|
|
2016-03-26 16:59:50 +00:00
|
|
|
void vulkan_filter_chain_set_pass_name(vulkan_filter_chain_t *chain,
|
|
|
|
unsigned pass,
|
|
|
|
const char *name);
|
|
|
|
|
2016-02-16 19:24:00 +00:00
|
|
|
void vulkan_filter_chain_build_offscreen_passes(vulkan_filter_chain_t *chain,
|
|
|
|
VkCommandBuffer cmd, const VkViewport *vp);
|
|
|
|
void vulkan_filter_chain_build_viewport_pass(vulkan_filter_chain_t *chain,
|
|
|
|
VkCommandBuffer cmd, const VkViewport *vp, const float *mvp);
|
2016-08-06 23:09:15 +00:00
|
|
|
void vulkan_filter_chain_end_frame(vulkan_filter_chain_t *chain,
|
|
|
|
VkCommandBuffer cmd);
|
2016-02-16 19:24:00 +00:00
|
|
|
|
2016-02-20 15:37:59 +00:00
|
|
|
vulkan_filter_chain_t *vulkan_filter_chain_create_default(
|
|
|
|
const struct vulkan_filter_chain_create_info *info,
|
2016-02-16 19:24:00 +00:00
|
|
|
enum vulkan_filter_chain_filter filter);
|
|
|
|
|
2016-02-20 15:37:59 +00:00
|
|
|
vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset(
|
|
|
|
const struct vulkan_filter_chain_create_info *info,
|
2016-02-16 19:24:00 +00:00
|
|
|
const char *path, enum vulkan_filter_chain_filter filter);
|
|
|
|
|
2016-02-20 15:37:59 +00:00
|
|
|
struct video_shader *vulkan_filter_chain_get_preset(
|
|
|
|
vulkan_filter_chain_t *chain);
|
2016-02-16 19:24:00 +00:00
|
|
|
|
2016-06-03 06:06:49 +00:00
|
|
|
RETRO_END_DECLS
|
2016-02-16 19:24:00 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|