[M108 Aura Migration][NaCl][PPAPI] Antialiasing for NaCl Graphics 3D 49/290149/2
authorXiaoshu Wei <xiaoshu.wei@samsung.com>
Tue, 21 Mar 2023 01:37:47 +0000 (09:37 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 21 Mar 2023 04:31:32 +0000 (04:31 +0000)
Ported patches from tizen_7.0:
  https://review.tizen.org/gerrit/#/c/280801/

Change-Id: I3713a56fabe70624ada8fff8f9e428dd18defe33
Signed-off-by: Xiaoshu Wei <xiaoshu.wei@samsung.com>
content/renderer/pepper/ppb_graphics_3d_impl.cc
gpu/command_buffer/build_gles2_cmd_buffer.py
gpu/command_buffer/service/gles2_cmd_decoder.cc
ppapi/api/ppb_opengles2.idl
ppapi/c/ppb_opengles2.h
ppapi/lib/gl/gles2/gles2.c
ppapi/lib/gl/include/GLES2/gl2ext.h
ppapi/shared_impl/ppb_opengles2_shared.cc

index 06c41e9951f2b4329ba5d873a9129f6ca66bbcd1..bc189c9bd2fd8e4e4aed839efdaf97e7827ddcb0 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "content/renderer/pepper/ppb_graphics_3d_impl.h"
 
+#include <algorithm>
+
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/feature_list.h"
@@ -43,6 +45,14 @@ using blink::WebString;
 
 namespace content {
 
+namespace {
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+const int32_t kMaxTextureSamples = 4;
+#endif
+
+}  // namespace
+
 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance)
     : PPB_Graphics3D_Shared(instance),
       bound_to_instance_(false),
@@ -246,6 +256,11 @@ bool PPB_Graphics3D_Impl::InitRaw(
   attrib_helper.should_use_native_gmb_for_backbuffer = use_image_chromium_;
   attrib_helper.context_type = gpu::CONTEXT_TYPE_OPENGLES2;
 
+#if defined(OS_TIZEN_TV_PRODUCT)
+  if (attrib_helper.samples > 1 && attrib_helper.sample_buffers > 1) {
+    attrib_helper.samples = std::min(attrib_helper.samples, kMaxTextureSamples);
+  }
+#endif
   gpu::CommandBufferProxyImpl* share_buffer = nullptr;
   UMA_HISTOGRAM_BOOLEAN("Pepper.Graphics3DHasShareGroup", !!share_context);
   if (share_context) {
index 849dc9b328b876240ff0ceb629dfa70b3aeeb425..3683fe6df9aebbf5622517c2421814c539c8b10f 100755 (executable)
@@ -2245,6 +2245,8 @@ _FUNCTION_INFO = {
     'unit_test': False,
     'extension': 'EXT_multisampled_render_to_texture',
     'extension_flag': 'multisampled_render_to_texture',
+    'pepper_interface': 'FramebufferMultisample',
+    'pepper_name': 'FramebufferTexture2DMultisampleEXT',
     'trace_level': 1,
   },
   'FramebufferTextureLayer': {
@@ -3110,7 +3112,7 @@ _FUNCTION_INFO = {
     'extension': 'chromium_framebuffer_multisample',
     'extension_flag': 'chromium_framebuffer_multisample',
     'pepper_interface': 'FramebufferMultisample',
-    'pepper_name': 'RenderbufferStorageMultisampleEXT',
+    'pepper_name': 'RenderbufferStorageMultisampleCHROMIUM',
     'trace_level': 1,
   },
   'RenderbufferStorageMultisampleAdvancedAMD': {
@@ -3131,6 +3133,8 @@ _FUNCTION_INFO = {
     'unit_test': False,
     'extension': 'EXT_multisampled_render_to_texture',
     'extension_flag': 'multisampled_render_to_texture',
+    'pepper_interface': 'FramebufferMultisample',
+    'pepper_name': 'RenderbufferStorageMultisampleEXT',
     'trace_level': 1,
   },
   'ReadBuffer': {
index 43e00a8d70e0893aee2b82dd1f5f7b6a7f70d9af..649de43a590a3818e2a15f2406d1f5351f608a52 100644 (file)
@@ -550,8 +550,15 @@ class BackFramebuffer {
 
   gl::GLApi* api() const;
 
+#if defined(OS_TIZEN_TV_PRODUCT)
+  void SetTextureSamples(GLsizei samples) { texture_samples_ = samples; }
+#endif
+
  private:
   raw_ptr<GLES2DecoderImpl> decoder_;
+#if defined(OS_TIZEN_TV_PRODUCT)
+  GLsizei texture_samples_;
+#endif
   GLuint id_;
 };
 
@@ -2591,6 +2598,9 @@ class GLES2DecoderImpl : public GLES2Decoder,
   GLenum offscreen_target_depth_format_;
   GLenum offscreen_target_stencil_format_;
   GLsizei offscreen_target_samples_;
+#if defined(OS_TIZEN_TV_PRODUCT)
+  GLsizei offscreen_texture_samples_;
+#endif
   GLboolean offscreen_target_buffer_preserved_;
 
   GLint max_offscreen_framebuffer_size_;
@@ -3353,6 +3363,9 @@ void BackRenderbuffer::Invalidate() {
 
 BackFramebuffer::BackFramebuffer(GLES2DecoderImpl* decoder)
     : decoder_(decoder),
+#if defined(OS_TIZEN_TV_PRODUCT)
+      texture_samples_(0),
+#endif
       id_(0) {
 }
 
@@ -3380,6 +3393,15 @@ void BackFramebuffer::AttachRenderTexture(BackTexture* texture) {
                                      decoder_->error_state_.get());
   ScopedFramebufferBinder binder(decoder_, id_);
   GLuint attach_id = texture ? texture->id() : 0;
+#if defined(OS_TIZEN_TV_PRODUCT)
+  if (texture_samples_ > 1) {
+    glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+                                         GL_TEXTURE_2D, attach_id, 0,
+                                         texture_samples_);
+
+    return;
+  }
+#endif
   api()->glFramebufferTexture2DEXTFn(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                                      texture->Target(), attach_id, 0);
 }
@@ -3451,6 +3473,9 @@ GLES2DecoderImpl::GLES2DecoderImpl(
       offscreen_target_depth_format_(0),
       offscreen_target_stencil_format_(0),
       offscreen_target_samples_(0),
+#if defined(OS_TIZEN_TV_PRODUCT)
+      offscreen_texture_samples_(0),
+#endif
       offscreen_target_buffer_preserved_(true),
       max_offscreen_framebuffer_size_(0),
       offscreen_single_buffer_(false),
@@ -3795,6 +3820,9 @@ gpu::ContextResult GLES2DecoderImpl::Initialize(
       // ANGLE only supports packed depth/stencil formats, so use it if it is
       // available.
       const bool depth24_stencil8_supported =
+#if defined(OS_TIZEN_TV_PRODUCT)
+          offscreen_texture_samples_ <= 1 &&
+#endif
           feature_info_->feature_flags().packed_depth24_stencil8;
       VLOG(1) << "GL_OES_packed_depth_stencil "
               << (depth24_stencil8_supported ? "" : "not ") << "supported.";
@@ -3964,6 +3992,10 @@ gpu::ContextResult GLES2DecoderImpl::Initialize(
     // Create the target frame buffer. This is the one that the client renders
     // directly to.
     offscreen_target_frame_buffer_ = std::make_unique<BackFramebuffer>(this);
+#if defined(OS_TIZEN_TV_PRODUCT)
+    offscreen_target_frame_buffer_->SetTextureSamples(
+        offscreen_texture_samples_);
+#endif
     offscreen_target_frame_buffer_->Create();
     // Due to GLES2 format limitations, either the color texture (for
     // non-multisampling) or the color render buffer (for multisampling) will be
@@ -3988,6 +4020,10 @@ gpu::ContextResult GLES2DecoderImpl::Initialize(
       // Create the saved offscreen texture. The target frame buffer is copied
       // here when SwapBuffers is called.
       offscreen_saved_frame_buffer_ = std::make_unique<BackFramebuffer>(this);
+#if defined(OS_TIZEN_TV_PRODUCT)
+      offscreen_saved_frame_buffer_->SetTextureSamples(
+          offscreen_texture_samples_);
+#endif
       offscreen_saved_frame_buffer_->Create();
       offscreen_saved_color_texture_ = std::make_unique<BackTexture>(this);
       offscreen_saved_color_texture_->Create();
@@ -5765,18 +5801,21 @@ bool GLES2DecoderImpl::ResizeOffscreenFramebuffer(const gfx::Size& size) {
       return false;
     }
   }
+  int32_t target_samples = offscreen_target_samples_;
+#if defined(OS_TIZEN_TV_PRODUCT)
+  if (target_samples == 1 && offscreen_texture_samples_ > 1)
+    target_samples = offscreen_texture_samples_;
+#endif
   if (offscreen_target_depth_format_ &&
       !offscreen_target_depth_render_buffer_->AllocateStorage(
-          offscreen_size_, offscreen_target_depth_format_,
-          offscreen_target_samples_)) {
+          offscreen_size_, offscreen_target_depth_format_, target_samples)) {
     LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed "
                << "to allocate storage for offscreen target depth buffer.";
     return false;
   }
   if (offscreen_target_stencil_format_ &&
       !offscreen_target_stencil_render_buffer_->AllocateStorage(
-          offscreen_size_, offscreen_target_stencil_format_,
-          offscreen_target_samples_)) {
+          offscreen_size_, offscreen_target_stencil_format_, target_samples)) {
     LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed "
                << "to allocate storage for offscreen target stencil buffer.";
     return false;
index 46a58d4333a82fe0c0e00bb5d8036cca6fd0f208..35957d10dc8e2fcf88c63da54d565b1f56690865 100644 (file)
@@ -659,12 +659,25 @@ interface PPB_OpenGLES2FramebufferBlit {
 
 [macro="PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE", force_struct_namespace]
 interface PPB_OpenGLES2FramebufferMultisample {
+  void RenderbufferStorageMultisampleCHROMIUM([in] PP_Resource context,
+                                              [in] GLenum target,
+                                              [in] GLsizei samples,
+                                              [in] GLenum internalformat,
+                                              [in] GLsizei width,
+                                              [in] GLsizei height);
   void RenderbufferStorageMultisampleEXT([in] PP_Resource context,
                                          [in] GLenum target,
                                          [in] GLsizei samples,
                                          [in] GLenum internalformat,
                                          [in] GLsizei width,
                                          [in] GLsizei height);
+  void FramebufferTexture2DMultisampleEXT([in] PP_Resource context,
+                                          [in] GLenum target,
+                                          [in] GLenum attachment,
+                                          [in] GLenum textarget,
+                                          [in] GLuint texture,
+                                          [in] GLint level,
+                                          [in] GLsizei samples);
 };
 
 
index e05d4e58b0cb66919879e3fac3aa583ff236620a..b3c8d3242434be1c4bbb290e40dcf4fa5204b011 100644 (file)
@@ -1069,21 +1069,47 @@ struct PPB_OpenGLES2FramebufferBlit {
 };
 
 struct PPB_OpenGLES2FramebufferMultisample_1_0 {
+  void (*RenderbufferStorageMultisampleCHROMIUM)(PP_Resource context,
+                                                 GLenum target,
+                                                 GLsizei samples,
+                                                 GLenum internalformat,
+                                                 GLsizei width,
+                                                 GLsizei height);
   void (*RenderbufferStorageMultisampleEXT)(PP_Resource context,
                                             GLenum target,
                                             GLsizei samples,
                                             GLenum internalformat,
                                             GLsizei width,
                                             GLsizei height);
+  void (*FramebufferTexture2DMultisampleEXT)(PP_Resource context,
+                                             GLenum target,
+                                             GLenum attachment,
+                                             GLenum textarget,
+                                             GLuint texture,
+                                             GLint level,
+                                             GLsizei samples);
 };
 
 struct PPB_OpenGLES2FramebufferMultisample {
+  void (*RenderbufferStorageMultisampleCHROMIUM)(PP_Resource context,
+                                                 GLenum target,
+                                                 GLsizei samples,
+                                                 GLenum internalformat,
+                                                 GLsizei width,
+                                                 GLsizei height);
   void (*RenderbufferStorageMultisampleEXT)(PP_Resource context,
                                             GLenum target,
                                             GLsizei samples,
                                             GLenum internalformat,
                                             GLsizei width,
                                             GLsizei height);
+  void (*FramebufferTexture2DMultisampleEXT)(PP_Resource context,
+                                             GLenum target,
+                                             GLenum attachment,
+                                             GLenum textarget,
+                                             GLuint texture,
+                                             GLint level,
+                                             GLsizei samples);
 };
 
 struct PPB_OpenGLES2ChromiumEnableFeature_1_0 {
index e6268af04fc9179c91389f3f0b8ad312d2baf363..05c46b137e3604b5d88f1e524d24f4d5f40338d4 100644 (file)
@@ -871,6 +871,19 @@ void GL_APIENTRY glBlitFramebufferEXT(GLint srcX0,
                             srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
 }
 
+void GL_APIENTRY glRenderbufferStorageMultisampleCHROMIUM(GLenum target,
+                                                          GLsizei samples,
+                                                          GLenum internalformat,
+                                                          GLsizei width,
+                                                          GLsizei height) {
+  const struct PPB_OpenGLES2FramebufferMultisample* ext =
+      glGetFramebufferMultisampleInterfacePPAPI();
+  if (ext)
+    ext->RenderbufferStorageMultisampleCHROMIUM(glGetCurrentContextPPAPI(),
+                                                target, samples, internalformat,
+                                                width, height);
+}
+
 void GL_APIENTRY glRenderbufferStorageMultisampleEXT(GLenum target,
                                                      GLsizei samples,
                                                      GLenum internalformat,
@@ -884,6 +897,20 @@ void GL_APIENTRY glRenderbufferStorageMultisampleEXT(GLenum target,
                                            height);
 }
 
+void GL_APIENTRY glFramebufferTexture2DMultisampleEXT(GLenum target,
+                                                      GLenum attachment,
+                                                      GLenum textarget,
+                                                      GLuint texture,
+                                                      GLint level,
+                                                      GLsizei samples) {
+  const struct PPB_OpenGLES2FramebufferMultisample* ext =
+      glGetFramebufferMultisampleInterfacePPAPI();
+  if (ext)
+    ext->FramebufferTexture2DMultisampleEXT(glGetCurrentContextPPAPI(), target,
+                                            attachment, textarget, texture,
+                                            level, samples);
+}
+
 void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* queries) {
   const struct PPB_OpenGLES2Query* ext = glGetQueryInterfacePPAPI();
   if (ext)
index fdd9742082108e98f3694c5989757bb3f546c2e3..e2edf2da8a111c9d166440e57083d5ac758bf10a 100644 (file)
@@ -1693,15 +1693,24 @@ typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
 #endif
 
-#if 0  // Defined in GL_EXT_multisampled_render_to_texture
 #ifdef GL_GLEXT_PROTOTYPES
-#define glRenderbufferStorageMultisampleEXT GLES2_GET_FUN(RenderbufferStorageMultisampleEXT)
+#define glRenderbufferStorageMultisampleCHROMIUM \
+  GLES2_GET_FUN(RenderbufferStorageMultisampleCHROMIUM)
 #if !defined(GLES2_USE_CPP_BINDINGS)
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY
+glRenderbufferStorageMultisampleCHROMIUM(GLenum target,
+                                         GLsizei samples,
+                                         GLenum internalformat,
+                                         GLsizei width,
+                                         GLsizei height);
 #endif
 #endif /* GL_GLEXT_PROTOTYPES */
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif
+typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECHROMIUMPROC)(
+    GLenum target,
+    GLsizei samples,
+    GLenum internalformat,
+    GLsizei width,
+    GLsizei height);
 #endif
 
 #ifndef GL_EXT_framebuffer_blit
index 9e1d3632f016926716eca0d0867b4c0903370e5f..5aaab84dba59a5aaa3a92511ce80f0769d268603 100644 (file)
@@ -1391,6 +1391,19 @@ void BlitFramebufferEXT(PP_Resource context_id,
   }
 }
 
+void RenderbufferStorageMultisampleCHROMIUM(PP_Resource context_id,
+                                            GLenum target,
+                                            GLsizei samples,
+                                            GLenum internalformat,
+                                            GLsizei width,
+                                            GLsizei height) {
+  Enter3D enter(context_id, true);
+  if (enter.succeeded()) {
+    ToGles2Impl(&enter)->RenderbufferStorageMultisampleCHROMIUM(
+        target, samples, internalformat, width, height);
+  }
+}
+
 void RenderbufferStorageMultisampleEXT(PP_Resource context_id,
                                        GLenum target,
                                        GLsizei samples,
@@ -1399,11 +1412,25 @@ void RenderbufferStorageMultisampleEXT(PP_Resource context_id,
                                        GLsizei height) {
   Enter3D enter(context_id, true);
   if (enter.succeeded()) {
-    ToGles2Impl(&enter)->RenderbufferStorageMultisampleCHROMIUM(
+    ToGles2Impl(&enter)->RenderbufferStorageMultisampleEXT(
         target, samples, internalformat, width, height);
   }
 }
 
+void FramebufferTexture2DMultisampleEXT(PP_Resource context_id,
+                                        GLenum target,
+                                        GLenum attachment,
+                                        GLenum textarget,
+                                        GLuint texture,
+                                        GLint level,
+                                        GLsizei samples) {
+  Enter3D enter(context_id, true);
+  if (enter.succeeded()) {
+    ToGles2Impl(&enter)->FramebufferTexture2DMultisampleEXT(
+        target, attachment, textarget, texture, level, samples);
+  }
+}
+
 void GenQueriesEXT(PP_Resource context_id, GLsizei n, GLuint* queries) {
   Enter3D enter(context_id, true);
   if (enter.succeeded()) {
@@ -1755,7 +1782,8 @@ PPB_OpenGLES2_Shared::GetFramebufferBlitInterface() {
 const PPB_OpenGLES2FramebufferMultisample*
 PPB_OpenGLES2_Shared::GetFramebufferMultisampleInterface() {
   static const struct PPB_OpenGLES2FramebufferMultisample ppb_opengles2 = {
-      &RenderbufferStorageMultisampleEXT};
+      &RenderbufferStorageMultisampleCHROMIUM,
+      &RenderbufferStorageMultisampleEXT, &FramebufferTexture2DMultisampleEXT};
   return &ppb_opengles2;
 }
 const PPB_OpenGLES2ChromiumEnableFeature*