diff options
Diffstat (limited to '')
-rw-r--r-- | src/audio_core/cubeb_sink.cpp | 3 | ||||
-rw-r--r-- | src/video_core/engines/maxwell_3d.h | 10 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 8 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 3 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 4 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 62 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 15 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_state.h | 5 |
8 files changed, 106 insertions, 4 deletions
diff --git a/src/audio_core/cubeb_sink.cpp b/src/audio_core/cubeb_sink.cpp index 392039688..d31a1c844 100644 --- a/src/audio_core/cubeb_sink.cpp +++ b/src/audio_core/cubeb_sink.cpp @@ -121,7 +121,8 @@ CubebSink::CubebSink(std::string target_device_name) { const auto collection_end{collection.device + collection.count}; const auto device{ std::find_if(collection.device, collection_end, [&](const cubeb_device_info& info) { - return target_device_name == info.friendly_name; + return info.friendly_name != nullptr && + target_device_name == info.friendly_name; })}; if (device != collection_end) { output_device = device->devid; diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 754a149fa..d6978162a 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -751,7 +751,14 @@ public: }; } draw; - INSERT_PADDING_WORDS(0x6B); + INSERT_PADDING_WORDS(0xA); + + struct { + u32 enabled; + u32 index; + } primitive_restart; + + INSERT_PADDING_WORDS(0x5F); struct { u32 start_addr_high; @@ -1082,6 +1089,7 @@ ASSERT_REG_POSITION(stencil_back_func_func, 0x569); ASSERT_REG_POSITION(point_coord_replace, 0x581); ASSERT_REG_POSITION(code_address, 0x582); ASSERT_REG_POSITION(draw, 0x585); +ASSERT_REG_POSITION(primitive_restart, 0x591); ASSERT_REG_POSITION(index_array, 0x5F2); ASSERT_REG_POSITION(instanced_arrays, 0x620); ASSERT_REG_POSITION(cull, 0x646); diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index b472f421f..cd4216c4e 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -570,6 +570,7 @@ void RasterizerOpenGL::DrawArrays() { SyncBlendState(); SyncLogicOpState(); SyncCullMode(); + SyncPrimitiveRestart(); SyncDepthRange(); SyncScissorTest(); // Alpha Testing is synced on shaders. @@ -924,6 +925,13 @@ void RasterizerOpenGL::SyncCullMode() { } } +void RasterizerOpenGL::SyncPrimitiveRestart() { + const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; + + state.primitive_restart.enabled = regs.primitive_restart.enabled; + state.primitive_restart.index = regs.primitive_restart.index; +} + void RasterizerOpenGL::SyncDepthRange() { const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 731a336d5..5020a5392 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -144,6 +144,9 @@ private: /// Syncs the cull mode to match the guest state void SyncCullMode(); + /// Syncs the primitve restart to match the guest state + void SyncPrimitiveRestart(); + /// Syncs the depth range to match the guest state void SyncDepthRange(); diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 591ec7998..04a024137 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -960,8 +960,8 @@ void CachedSurface::FlushGLBuffer() { glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(params.width)); ASSERT(!tuple.compressed); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); - glGetTextureImage(texture.handle, 0, tuple.format, tuple.type, gl_buffer.size(), - gl_buffer.data()); + glGetTextureImage(texture.handle, 0, tuple.format, tuple.type, + static_cast<GLsizei>(gl_buffer.size()), gl_buffer.data()); glPixelStorei(GL_PACK_ROW_LENGTH, 0); ConvertFormatAsNeeded_FlushGLBuffer(gl_buffer, params.pixel_format, params.width, params.height); diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 50a7ab47d..181acfc68 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -255,6 +255,68 @@ struct SurfaceParams { return compression_factor_table[static_cast<std::size_t>(format)]; } + static constexpr u32 GetDefaultBlockHeight(PixelFormat format) { + if (format == PixelFormat::Invalid) + return 0; + constexpr std::array<u32, MaxPixelFormat> block_height_table = {{ + 1, // ABGR8U + 1, // ABGR8S + 1, // ABGR8UI + 1, // B5G6R5U + 1, // A2B10G10R10U + 1, // A1B5G5R5U + 1, // R8U + 1, // R8UI + 1, // RGBA16F + 1, // RGBA16U + 1, // RGBA16UI + 1, // R11FG11FB10F + 1, // RGBA32UI + 4, // DXT1 + 4, // DXT23 + 4, // DXT45 + 4, // DXN1 + 4, // DXN2UNORM + 4, // DXN2SNORM + 4, // BC7U + 4, // BC6H_UF16 + 4, // BC6H_SF16 + 4, // ASTC_2D_4X4 + 1, // G8R8U + 1, // G8R8S + 1, // BGRA8 + 1, // RGBA32F + 1, // RG32F + 1, // R32F + 1, // R16F + 1, // R16U + 1, // R16S + 1, // R16UI + 1, // R16I + 1, // RG16 + 1, // RG16F + 1, // RG16UI + 1, // RG16I + 1, // RG16S + 1, // RGB32F + 1, // SRGBA8 + 1, // RG8U + 1, // RG8S + 1, // RG32UI + 1, // R32UI + 8, // ASTC_2D_8X8 + 5, // ASTC_2D_8X5 + 4, // ASTC_2D_5X4 + 1, // Z32F + 1, // Z16 + 1, // Z24S8 + 1, // S8Z24 + 1, // Z32FS8 + }}; + ASSERT(static_cast<std::size_t>(format) < block_height_table.size()); + return block_height_table[static_cast<std::size_t>(format)]; + } + static constexpr u32 GetFormatBpp(PixelFormat format) { if (format == PixelFormat::Invalid) return 0; diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index ba6c6919a..f9d41ca24 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -24,6 +24,9 @@ OpenGLState::OpenGLState() { depth.depth_range_near = 0.0f; depth.depth_range_far = 1.0f; + primitive_restart.enabled = false; + primitive_restart.index = 0; + color_mask.red_enabled = GL_TRUE; color_mask.green_enabled = GL_TRUE; color_mask.blue_enabled = GL_TRUE; @@ -127,6 +130,18 @@ void OpenGLState::Apply() const { glDepthRange(depth.depth_range_near, depth.depth_range_far); } + // Primitive restart + if (primitive_restart.enabled != cur_state.primitive_restart.enabled) { + if (primitive_restart.enabled) { + glEnable(GL_PRIMITIVE_RESTART); + } else { + glDisable(GL_PRIMITIVE_RESTART); + } + } + if (primitive_restart.index != cur_state.primitive_restart.index) { + glPrimitiveRestartIndex(primitive_restart.index); + } + // Color mask if (color_mask.red_enabled != cur_state.color_mask.red_enabled || color_mask.green_enabled != cur_state.color_mask.green_enabled || diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index daf7eb533..4334b0d35 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h @@ -50,6 +50,11 @@ public: } depth; struct { + bool enabled; + GLuint index; + } primitive_restart; // GL_PRIMITIVE_RESTART + + struct { GLboolean red_enabled; GLboolean green_enabled; GLboolean blue_enabled; |