mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-06 02:33:44 -04:00
added uniforms for vulkan
This commit is contained in:
parent
2dfab0ac69
commit
e489fac61b
7 changed files with 43 additions and 12 deletions
|
|
@ -12,6 +12,8 @@ layout (push_constant, std140) uniform DrawInfo {
|
|||
mat4 modelview_matrix;
|
||||
vec4 i_resolution;
|
||||
vec4 o_resolution;
|
||||
vec2 cursor_pos;
|
||||
int cursor_enable;
|
||||
int screen_id_l;
|
||||
int screen_id_r;
|
||||
int layer;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ layout (push_constant, std140) uniform DrawInfo {
|
|||
mat4 modelview_matrix;
|
||||
vec4 i_resolution;
|
||||
vec4 o_resolution;
|
||||
vec2 cursor_pos;
|
||||
int cursor_enable;
|
||||
int screen_id_l;
|
||||
int screen_id_r;
|
||||
int layer;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ layout (push_constant, std140) uniform DrawInfo {
|
|||
mat4 modelview_matrix;
|
||||
vec4 i_resolution;
|
||||
vec4 o_resolution;
|
||||
vec2 cursor_pos;
|
||||
int cursor_enable;
|
||||
int screen_id_l;
|
||||
int screen_id_r;
|
||||
int layer;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ layout (push_constant, std140) uniform DrawInfo {
|
|||
mat4 modelview_matrix;
|
||||
vec4 i_resolution;
|
||||
vec4 o_resolution;
|
||||
vec2 cursor_pos;
|
||||
int cursor_enable;
|
||||
int screen_id_l;
|
||||
int screen_id_r;
|
||||
int layer;
|
||||
|
|
|
|||
|
|
@ -640,6 +640,12 @@ void RendererOpenGL::DrawSingleScreenStereo(const ScreenInfo& screen_info_l,
|
|||
1.0f / static_cast<float>(screen_info_l.texture.height * scale_factor),
|
||||
1.0f / static_cast<float>(screen_info_l.texture.width * scale_factor));
|
||||
glUniform4f(uniform_o_resolution, w, h, 1.0f / w, 1.0f / h);
|
||||
if (currScreenDraw == 1){
|
||||
glUniform1i(uniform_cursor_enable, 1);
|
||||
} else {
|
||||
glUniform1i(uniform_cursor_enable, 0);
|
||||
}
|
||||
glUniform2f(uniform_cursor_pos, cursor_pos[0]/320.0f, cursor_pos[1]/240.0f);
|
||||
state.texture_units[0].texture_2d = screen_info_l.display_texture;
|
||||
state.texture_units[1].texture_2d = screen_info_r.display_texture;
|
||||
state.texture_units[0].sampler = sampler;
|
||||
|
|
|
|||
|
|
@ -783,11 +783,17 @@ void RendererVulkan::DrawSingleScreen(u32 screen_id, float x, float y, float w,
|
|||
|
||||
const u32 scale_factor = GetResolutionScaleFactor();
|
||||
draw_info.i_resolution =
|
||||
Common::MakeVec(static_cast<f32>(screen_info.texture.width * scale_factor),
|
||||
static_cast<f32>(screen_info.texture.height * scale_factor),
|
||||
1.0f / static_cast<f32>(screen_info.texture.width * scale_factor),
|
||||
1.0f / static_cast<f32>(screen_info.texture.height * scale_factor));
|
||||
draw_info.o_resolution = Common::MakeVec(h, w, 1.0f / h, 1.0f / w);
|
||||
Common::MakeVec(static_cast<f32>(screen_info.texture.height * scale_factor),
|
||||
static_cast<f32>(screen_info.texture.width * scale_factor),
|
||||
1.0f / static_cast<f32>(screen_info.texture.height * scale_factor),
|
||||
1.0f / static_cast<f32>(screen_info.texture.width * scale_factor));
|
||||
draw_info.o_resolution = Common::MakeVec(w, h, 1.0f / w, 1.0f / h);
|
||||
if (currScreenDraw == 1){
|
||||
draw_info.cursor_enable = 1;
|
||||
} else {
|
||||
draw_info.cursor_enable = 0;
|
||||
}
|
||||
draw_info.cursor_pos = Common::MakeVec(cursor_pos[0]/320.0f, cursor_pos[1]/240.0f);
|
||||
draw_info.screen_id_l = screen_id;
|
||||
|
||||
scheduler.Record([this, offset = offset, info = draw_info](vk::CommandBuffer cmdbuf) {
|
||||
|
|
@ -855,11 +861,17 @@ void RendererVulkan::DrawSingleScreenStereo(u32 screen_id_l, u32 screen_id_r, fl
|
|||
|
||||
const u32 scale_factor = GetResolutionScaleFactor();
|
||||
draw_info.i_resolution =
|
||||
Common::MakeVec(static_cast<f32>(screen_info_l.texture.width * scale_factor),
|
||||
static_cast<f32>(screen_info_l.texture.height * scale_factor),
|
||||
1.0f / static_cast<f32>(screen_info_l.texture.width * scale_factor),
|
||||
1.0f / static_cast<f32>(screen_info_l.texture.height * scale_factor));
|
||||
draw_info.o_resolution = Common::MakeVec(h, w, 1.0f / h, 1.0f / w);
|
||||
Common::MakeVec(static_cast<f32>(screen_info_l.texture.height * scale_factor),
|
||||
static_cast<f32>(screen_info_l.texture.width * scale_factor),
|
||||
1.0f / static_cast<f32>(screen_info_l.texture.height * scale_factor),
|
||||
1.0f / static_cast<f32>(screen_info_l.texture.width * scale_factor));
|
||||
draw_info.o_resolution = Common::MakeVec(w, h, 1.0f / w, 1.0f / h);
|
||||
if (currScreenDraw == 1){
|
||||
draw_info.cursor_enable = 1;
|
||||
} else {
|
||||
draw_info.cursor_enable = 0;
|
||||
}
|
||||
draw_info.cursor_pos = Common::MakeVec(cursor_pos[0]/320.0f, cursor_pos[1]/240.0f);
|
||||
draw_info.screen_id_l = screen_id_l;
|
||||
draw_info.screen_id_r = screen_id_r;
|
||||
|
||||
|
|
@ -886,6 +898,7 @@ void RendererVulkan::DrawTopScreen(const Layout::FramebufferLayout& layout,
|
|||
if (!layout.top_screen_enabled) {
|
||||
return;
|
||||
}
|
||||
currScreenDraw = 0;
|
||||
int leftside, rightside;
|
||||
leftside = Settings::values.swap_eyes_3d.GetValue() ? 1 : 0;
|
||||
rightside = Settings::values.swap_eyes_3d.GetValue() ? 0 : 1;
|
||||
|
|
@ -944,7 +957,7 @@ void RendererVulkan::DrawBottomScreen(const Layout::FramebufferLayout& layout,
|
|||
if (!layout.bottom_screen_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
currScreenDraw = 1;
|
||||
const float bottom_screen_left = static_cast<float>(bottom_screen.left);
|
||||
const float bottom_screen_top = static_cast<float>(bottom_screen.top);
|
||||
const float bottom_screen_width = static_cast<float>(bottom_screen.GetWidth());
|
||||
|
|
|
|||
|
|
@ -58,12 +58,14 @@ struct PresentUniformData {
|
|||
std::array<f32, 4 * 4> modelview;
|
||||
Common::Vec4f i_resolution;
|
||||
Common::Vec4f o_resolution;
|
||||
Common::Vec2f cursor_pos;
|
||||
int cursor_enable = 0;
|
||||
int screen_id_l = 0;
|
||||
int screen_id_r = 0;
|
||||
int layer = 0;
|
||||
int reverse_interlaced = 0;
|
||||
};
|
||||
static_assert(sizeof(PresentUniformData) == 112,
|
||||
static_assert(sizeof(PresentUniformData) == 124,
|
||||
"PresentUniformData does not structure in shader!");
|
||||
|
||||
class RendererVulkan : public VideoCore::RendererBase {
|
||||
|
|
@ -151,6 +153,8 @@ private:
|
|||
vk::ShaderModule cursor_fragment_shader{};
|
||||
vk::Pipeline cursor_pipeline{};
|
||||
vk::UniquePipelineLayout cursor_pipeline_layout{};
|
||||
int currScreenDraw; // 0 is Top, 1 is Bottom
|
||||
std::array<int, 2> cursor_pos = {0,0};
|
||||
};
|
||||
|
||||
} // namespace Vulkan
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue