]> git.sesse.net Git - nageru/commitdiff
Always require GL_EXT_texture_sRGB_decode.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 19 May 2019 08:34:24 +0000 (10:34 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 22 May 2019 22:43:56 +0000 (00:43 +0200)
Keeping the pure OpenGL path does not seem to actually buy us any
compatibility, so we simplify things a bit for an upcoming fix.
Strangely enough, this does not seem to be in any OpenGL standard.
Sampler objects, which we also require, is, though.

nageru/flags.h
nageru/mixer.cpp
nageru/pbo_frame_allocator.cpp
nageru/theme.cpp
nageru/tweaked_inputs.h

index a401dbf53a3e875572d48a9dbf1862935f60bc2f..caad05a5088e4402081cbc14d2cad3414a5412c8 100644 (file)
@@ -66,7 +66,6 @@ struct Flags {
        bool enable_audio = true;  // Kaeru only. If false, then transcode_audio is also false.
        int x264_bit_depth = 8;  // Not user-settable.
        bool use_zerocopy = false;  // Not user-settable.
-       bool can_disable_srgb_decoder = false;  // Not user-settable.
        bool fullscreen = false;
        std::map<unsigned, unsigned> card_to_mjpeg_stream_export;  // If a card is not in the map, it is not exported.
 };
index 83d6eada183d8f0f787c1f9703211915db790917..91c82d4ca6378ffe20054429610ca0429f5070f0 100644 (file)
@@ -153,11 +153,8 @@ void ensure_texture_resolution(PBOFrameAllocator::Userdata *userdata, unsigned f
                case PixelFormat_8BitBGRA:
                        glBindTexture(GL_TEXTURE_2D, userdata->tex_rgba[field]);
                        check_error();
-                       if (global_flags.can_disable_srgb_decoder) {  // See the comments in tweaked_inputs.h.
-                               glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
-                       } else {
-                               glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
-                       }
+                       // NOTE: sRGB may be disabled by sRGBSwitchingFlatInput.
+                       glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
                        check_error();
                        break;
                default:
@@ -314,10 +311,11 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
        CHECK(init_movit(MOVIT_SHADER_DIR, MOVIT_DEBUG_OFF));
        check_error();
 
-       // This nearly always should be true.
-       global_flags.can_disable_srgb_decoder =
-               epoxy_has_gl_extension("GL_EXT_texture_sRGB_decode") &&
-               epoxy_has_gl_extension("GL_ARB_sampler_objects");
+       if (!epoxy_has_gl_extension("GL_EXT_texture_sRGB_decode") ||
+           !epoxy_has_gl_extension("GL_ARB_sampler_objects")) {
+               fprintf(stderr, "Nageru requires GL_EXT_texture_sRGB_decode and GL_ARB_sampler_objects to run.\n");
+               exit(1);
+       }
 
        // Since we allow non-bouncing 4:2:2 YCbCrInputs, effective subpixel precision
        // will be halved when sampling them, and we need to compensate here.
index 7fb06f849b1bff09c78be68ad9b388ff1cd8c7e9..4640d355e25e96a60db88fddc3963419577cd636 100644 (file)
@@ -166,11 +166,7 @@ void PBOFrameAllocator::init_frame(size_t frame_idx, size_t frame_size, GLuint w
                        check_error();
                        set_clamp_to_edge();
                        if (field == 0) {
-                               if (global_flags.can_disable_srgb_decoder) {  // See the comments in tweaked_inputs.h.
-                                       glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
-                               } else {
-                                       glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
-                               }
+                               glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
                                check_error();
                        }
                        break;
index 7226e82d55e50b6a7cd4dde12ed1a71ed84a5321..33fa114538d046cf5049c1cbf4b8fdba1d9b909b 100644 (file)
@@ -905,11 +905,7 @@ LiveInputWrapper::LiveInputWrapper(
                for (unsigned i = 0; i < num_inputs; ++i) {
                        // We upload our textures ourselves, and Movit swaps
                        // R and B in the shader if we specify BGRA, so lie and say RGBA.
-                       if (global_flags.can_disable_srgb_decoder) {
-                               rgba_inputs.push_back(new sRGBSwitchingFlatInput(inout_format, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, GL_UNSIGNED_BYTE, global_flags.width, global_flags.height));
-                       } else {
-                               rgba_inputs.push_back(new NonsRGBCapableFlatInput(inout_format, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, GL_UNSIGNED_BYTE, global_flags.width, global_flags.height));
-                       }
+                       rgba_inputs.push_back(new sRGBSwitchingFlatInput(inout_format, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, GL_UNSIGNED_BYTE, global_flags.width, global_flags.height));
                        chain->add_input(rgba_inputs.back());
                }
 
index 0ca13ced94877a3084fec7609bdc0cdd93a39f8b..3b70a13cbd691f70f83e78f15064af7a3c83353f 100644 (file)
@@ -3,6 +3,7 @@
 
 // Some tweaked variations of Movit inputs.
 
+#include <movit/flat_input.h>
 #include <movit/ycbcr_input.h>
 
 namespace movit {
@@ -26,21 +27,9 @@ public:
 // or not. (FlatInput deals with this if you give it pixels, but we give it
 // already uploaded textures.)
 //
-// If we have GL_EXT_texture_sRGB_decode (very common, as far as I can tell),
-// we can just always upload with the sRGB flag turned on, and then turn it off
-// if not requested; that's sRGBSwitchingFlatInput. If not, we just need to
-// turn off the functionality altogether, which is NonsRGBCapableFlatInput.
-//
-// If you're using NonsRGBCapableFlatInput, upload with GL_RGBA8.
-// If using sRGBSwitchingFlatInput, upload with GL_SRGB8_ALPHA8.
-
-class NonsRGBCapableFlatInput : public movit::FlatInput {
-public:
-       NonsRGBCapableFlatInput(movit::ImageFormat format, movit::MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height)
-           : movit::FlatInput(format, pixel_format, type, width, height) {}
-
-       bool can_output_linear_gamma() const override { return false; }
-};
+// Since we require GL_EXT_texture_sRGB_decode (very common, as far as I can tell),
+// we can just always upload with the sRGB flag turned on (upload your texture with
+// GL_SRGB8_ALPHA8), and then sRGBSwitchingFlatInput will turn it off if not requested.
 
 class sRGBSwitchingFlatInput : public movit::FlatInput {
 public:
@@ -69,5 +58,4 @@ private:
        GLuint texture_unit;
 };
 
-
 #endif  // !defined(_TWEAKED_INPUTS_H)