Bug 13767

Summary: [i965 FBO] glDrawBuffer and glReadBuffer doesn't work with max supported color attachments
Product: Mesa Reporter: Shuang He <shuang.he>
Component: Drivers/DRI/i965Assignee: Eric Anholt <eric>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: medium CC: dri-devel
Version: unspecified   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: test case

Description Shuang He 2007-12-21 00:46:38 UTC
System Environment:
--------------------------
--Platform: FC6
--Xf86_video_intel:d9df93578b74785c08ba860b4c9aa23b0c89c91c
--Mesa:e54329233522591bbe8aad8a3fd6bcdc1e430f03 
--DRM:2db6400396ea5c8a5ce54fe9e211b9d01a11d506
--Kernel:2.6.22

Bug detailed description:
--------------------------
this issue doesn't happen on i915
queried max supported color attachments, it return 8
but only color attachment 0~3 can be used with glDrawBuffer/glReadBuffer

Reproduce steps:
----------------
start X
compile and run the attached test case


Current result:
----------------
glDrawBuffer/glReadBuffer will report "invalid enumerant" with GL_COLOR_ATTACHMENT4_EXT~GL_COLOR_ATTACHMENT7_EXT


Expected result:
----------------
glDrawBuffer/glReadBuffer should not has this issue
Comment 1 Shuang He 2007-12-21 00:48:03 UTC
Created attachment 13277 [details]
test case
Comment 2 Shuang He 2007-12-21 00:58:32 UTC
seems following patch can fix this:

--- a/src/mesa/main/buffers.c     2007-12-21 10:59:20.000000000 +0800
+++ b/src/mesa/main/buffers.c     2007-12-21 16:55:55.000000000 +0800
@@ -320,6 +320,14 @@
          return BUFFER_COLOR2;
       case GL_COLOR_ATTACHMENT3_EXT:
          return BUFFER_COLOR3;
+      case GL_COLOR_ATTACHMENT4_EXT:
+         return BUFFER_COLOR4;
+      case GL_COLOR_ATTACHMENT5_EXT:
+         return BUFFER_COLOR5;
+      case GL_COLOR_ATTACHMENT6_EXT:
+         return BUFFER_COLOR6;
+      case GL_COLOR_ATTACHMENT7_EXT:
+         return BUFFER_COLOR7;
       default:
          /* error */
          return -1;
Comment 3 Brian Paul 2008-01-01 09:10:57 UTC
committed to git.
Comment 4 Shuang He 2008-01-01 19:55:37 UTC
verified. thanks
Comment 5 Shuang He 2008-01-01 21:28:22 UTC
sorry, I forgot this part. the previous one is just making glFramebufferEXT work with max supported color attachment. following is needed to make this work with glDrawBuffer and glReadBuffer

--- a/src/mesa/main/buffers.c      2008-01-02 13:25:29.000000000 +0800
+++ b/src/mesa/main/buffers.c      2008-01-02 13:25:01.000000000 +0800
@@ -275,6 +275,14 @@
          return BUFFER_BIT_COLOR2;
       case GL_COLOR_ATTACHMENT3_EXT:
          return BUFFER_BIT_COLOR3;
+      case GL_COLOR_ATTACHMENT4_EXT:
+         return BUFFER_BIT_COLOR4;
+      case GL_COLOR_ATTACHMENT5_EXT:
+         return BUFFER_BIT_COLOR5;
+      case GL_COLOR_ATTACHMENT6_EXT:
+         return BUFFER_BIT_COLOR6;
+      case GL_COLOR_ATTACHMENT7_EXT:
+         return BUFFER_BIT_COLOR7;
   default:
          /* error */
          return BAD_MASK;
Comment 6 Brian Paul 2008-01-02 06:19:16 UTC
OK, additional cases commited.
Comment 7 Shuang He 2008-01-03 17:52:34 UTC
thanks

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.