OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa
_intel.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa
_intel.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "gpu/command_buffer/service/framebuffer_manager.h" | 8 #include "gpu/command_buffer/service/framebuffer_manager.h" |
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
10 #include "ui/gl/gl_context.h" | 10 #include "ui/gl/gl_context.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 textures_initialized_(false), | 22 textures_initialized_(false), |
23 is_in_gamma_correct_mode_(false), | 23 is_in_gamma_correct_mode_(false), |
24 supports_usampler_(true), | 24 supports_usampler_(true), |
25 supports_r8_image_(true), | 25 supports_r8_image_(true), |
26 supports_r8_read_format_(true), | 26 supports_r8_read_format_(true), |
27 is_gles31_compatible_(false), | 27 is_gles31_compatible_(false), |
28 frame_id_(0), | 28 frame_id_(0), |
29 width_(0), | 29 width_(0), |
30 height_(0), | 30 height_(0), |
31 copy_to_framebuffer_shader_(0), | 31 copy_to_framebuffer_shader_(0), |
32 copy_to_image_shader_(0), | |
33 edges0_shader_(0), | 32 edges0_shader_(0), |
34 edges1_shader_(0), | 33 edges1_shader_(0), |
35 edges_combine_shader_(0), | 34 edges_combine_shader_(0), |
36 process_and_apply_shader_(0), | 35 process_and_apply_shader_(0), |
37 debug_display_edges_shader_(0), | 36 debug_display_edges_shader_(0), |
38 cmaa_framebuffer_(0), | 37 cmaa_framebuffer_(0), |
39 copy_framebuffer_(0), | 38 copy_framebuffer_(0), |
40 rgba8_texture_(0), | 39 rgba8_texture_(0), |
41 working_color_texture_(0), | 40 working_color_texture_(0), |
42 edges0_texture_(0), | 41 edges0_texture_(0), |
43 edges1_texture_(0), | 42 edges1_texture_(0), |
44 mini4_edge_texture_(0), | 43 mini4_edge_texture_(0), |
45 mini4_edge_depth_texture_(0), | 44 mini4_edge_depth_texture_(0), |
46 edges1_shader_result_texture_float4_slot1_(0), | 45 edges0_shader_result_rgba_texture_slot1_(0), |
47 edges1_shader_result_texture_(0), | 46 edges0_shader_target_texture_slot2_(0), |
48 edges_combine_shader_result_texture_float4_slot1_(0), | 47 edges1_shader_result_edge_texture_(0), |
49 process_and_apply_shader_result_texture_float4_slot1_(0), | 48 process_and_apply_shader_result_rgba_texture_slot1_(0), |
50 edges_combine_shader_result_texture_slot2_(0), | 49 edges_combine_shader_result_edge_texture_(0) {} |
51 copy_to_image_shader_outTexture_(0) {} | |
52 | 50 |
53 ApplyFramebufferAttachmentCMAAINTELResourceManager:: | 51 ApplyFramebufferAttachmentCMAAINTELResourceManager:: |
54 ~ApplyFramebufferAttachmentCMAAINTELResourceManager() { | 52 ~ApplyFramebufferAttachmentCMAAINTELResourceManager() { |
55 Destroy(); | 53 Destroy(); |
56 } | 54 } |
57 | 55 |
58 void ApplyFramebufferAttachmentCMAAINTELResourceManager::Initialize( | 56 void ApplyFramebufferAttachmentCMAAINTELResourceManager::Initialize( |
59 gles2::GLES2Decoder* decoder) { | 57 gles2::GLES2Decoder* decoder) { |
60 DCHECK(decoder); | 58 DCHECK(decoder); |
61 is_gles31_compatible_ = | 59 is_gles31_compatible_ = |
62 decoder->GetGLContext()->GetVersionInfo()->IsAtLeastGLES(3, 1); | 60 decoder->GetGLContext()->GetVersionInfo()->IsAtLeastGLES(3, 1); |
63 | 61 |
64 copy_to_image_shader_ = CreateProgram("", vert_str_, copy_frag_str_); | |
65 copy_to_framebuffer_shader_ = | 62 copy_to_framebuffer_shader_ = |
66 CreateProgram("#define OUT_FBO 1\n", vert_str_, copy_frag_str_); | 63 CreateProgram("", vert_str_, copy_frag_str_); |
67 | 64 |
68 // Check if RGBA8UI is supported as an FBO colour target with depth. | 65 // Check if RGBA8UI is supported as an FBO colour target with depth. |
69 // If not supported, GLSL needs to convert the data to/from float so there is | 66 // If not supported, GLSL needs to convert the data to/from float so there is |
70 // a small extra cost. | 67 // a small extra cost. |
71 { | 68 { |
72 GLuint rgba8ui_texture = 0, depth_texture = 0; | 69 GLuint rgba8ui_texture = 0, depth_texture = 0; |
73 glGenTextures(1, &rgba8ui_texture); | 70 glGenTextures(1, &rgba8ui_texture); |
74 glBindTexture(GL_TEXTURE_2D, rgba8ui_texture); | 71 glBindTexture(GL_TEXTURE_2D, rgba8ui_texture); |
75 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8UI, 4, 4); | 72 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8UI, 4, 4); |
76 | 73 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 CreateProgram(edge2.str().c_str(), vert_str_, cmaa_frag_c_str); | 170 CreateProgram(edge2.str().c_str(), vert_str_, cmaa_frag_c_str); |
174 | 171 |
175 combineEdges << defines.str() << "#define COMBINE_EDGES\n"; | 172 combineEdges << defines.str() << "#define COMBINE_EDGES\n"; |
176 edges_combine_shader_ = | 173 edges_combine_shader_ = |
177 CreateProgram(combineEdges.str().c_str(), vert_str_, cmaa_frag_c_str); | 174 CreateProgram(combineEdges.str().c_str(), vert_str_, cmaa_frag_c_str); |
178 | 175 |
179 blur << defines.str() << "#define BLUR_EDGES\n"; | 176 blur << defines.str() << "#define BLUR_EDGES\n"; |
180 process_and_apply_shader_ = | 177 process_and_apply_shader_ = |
181 CreateProgram(blur.str().c_str(), vert_str_, cmaa_frag_c_str); | 178 CreateProgram(blur.str().c_str(), vert_str_, cmaa_frag_c_str); |
182 | 179 |
183 edges1_shader_result_texture_float4_slot1_ = | 180 edges0_shader_result_rgba_texture_slot1_ = |
184 glGetUniformLocation(edges0_shader_, "g_resultTextureFlt4Slot1"); | 181 glGetUniformLocation(edges0_shader_, "g_resultRGBATextureSlot1"); |
185 edges1_shader_result_texture_ = | 182 edges0_shader_target_texture_slot2_ = |
186 glGetUniformLocation(edges1_shader_, "g_resultTexture"); | 183 glGetUniformLocation(edges0_shader_, "g_targetTextureSlot2"); |
187 edges_combine_shader_result_texture_float4_slot1_ = | 184 edges1_shader_result_edge_texture_ = |
188 glGetUniformLocation(edges_combine_shader_, "g_resultTextureFlt4Slot1"); | 185 glGetUniformLocation(edges1_shader_, "g_resultEdgeTexture"); |
189 edges_combine_shader_result_texture_slot2_ = | 186 edges_combine_shader_result_edge_texture_ = |
190 glGetUniformLocation(edges_combine_shader_, "g_resultTextureSlot2"); | 187 glGetUniformLocation(edges_combine_shader_, "g_resultEdgeTexture"); |
191 process_and_apply_shader_result_texture_float4_slot1_ = glGetUniformLocation( | 188 process_and_apply_shader_result_rgba_texture_slot1_ = glGetUniformLocation( |
192 process_and_apply_shader_, "g_resultTextureFlt4Slot1"); | 189 process_and_apply_shader_, "g_resultRGBATextureSlot1"); |
193 copy_to_image_shader_outTexture_ = | |
194 glGetUniformLocation(copy_to_image_shader_, "outTexture"); | |
195 | 190 |
196 initialized_ = true; | 191 initialized_ = true; |
197 } | 192 } |
198 | 193 |
199 void ApplyFramebufferAttachmentCMAAINTELResourceManager::Destroy() { | 194 void ApplyFramebufferAttachmentCMAAINTELResourceManager::Destroy() { |
200 if (!initialized_) | 195 if (!initialized_) |
201 return; | 196 return; |
202 | 197 |
203 ReleaseTextures(); | 198 ReleaseTextures(); |
204 | 199 |
205 glDeleteProgram(copy_to_image_shader_); | |
206 glDeleteProgram(copy_to_framebuffer_shader_); | 200 glDeleteProgram(copy_to_framebuffer_shader_); |
207 glDeleteProgram(process_and_apply_shader_); | 201 glDeleteProgram(process_and_apply_shader_); |
208 glDeleteProgram(edges_combine_shader_); | 202 glDeleteProgram(edges_combine_shader_); |
209 glDeleteProgram(edges1_shader_); | 203 glDeleteProgram(edges1_shader_); |
210 glDeleteProgram(edges0_shader_); | 204 glDeleteProgram(edges0_shader_); |
211 glDeleteProgram(debug_display_edges_shader_); | 205 glDeleteProgram(debug_display_edges_shader_); |
212 | 206 |
213 initialized_ = false; | 207 initialized_ = false; |
214 } | 208 } |
215 | 209 |
216 // Apply CMAA(Conservative Morphological Anti-Aliasing) algorithm to the | 210 // Apply CMAA(Conservative Morphological Anti-Aliasing) algorithm to the |
217 // color attachments of currently bound draw framebuffer. | 211 // color attachments of currently bound draw framebuffer. |
218 // Reference GL_INTEL_framebuffer_CMAA for details. | 212 // Reference GL_INTEL_framebuffer_CMAA for details. |
219 void ApplyFramebufferAttachmentCMAAINTELResourceManager:: | 213 void ApplyFramebufferAttachmentCMAAINTELResourceManager:: |
220 ApplyFramebufferAttachmentCMAAINTEL(gles2::GLES2Decoder* decoder, | 214 ApplyFramebufferAttachmentCMAAINTEL(gles2::GLES2Decoder* decoder, |
221 gles2::Framebuffer* framebuffer) { | 215 gles2::Framebuffer* framebuffer) { |
222 DCHECK(decoder); | 216 DCHECK(decoder); |
223 DCHECK(initialized_); | 217 DCHECK(initialized_); |
224 if (!framebuffer) | 218 if (!framebuffer) |
225 return; | 219 return; |
226 | 220 |
227 GLuint last_framebuffer = framebuffer->service_id(); | 221 glDisable(GL_SCISSOR_TEST); |
| 222 glDisable(GL_STENCIL_TEST); |
| 223 glDisable(GL_CULL_FACE); |
| 224 glDisable(GL_BLEND); |
228 | 225 |
229 // Process each color attachment of the current draw framebuffer. | 226 // Process each color attachment of the current draw framebuffer. |
230 uint32_t max_draw_buffers = decoder->GetContextGroup()->max_draw_buffers(); | 227 uint32_t max_draw_buffers = decoder->GetContextGroup()->max_draw_buffers(); |
231 for (uint32_t i = 0; i < max_draw_buffers; i++) { | 228 for (uint32_t i = 0; i < max_draw_buffers; i++) { |
232 const gles2::Framebuffer::Attachment* attachment = | 229 const gles2::Framebuffer::Attachment* attachment = |
233 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0 + i); | 230 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0 + i); |
234 if (attachment && attachment->IsTextureAttachment()) { | 231 if (attachment && attachment->IsTextureAttachment()) { |
235 // Get the texture info. | 232 // Get the texture info. |
236 GLuint source_texture_client_id = attachment->object_name(); | 233 GLuint source_texture_client_id = attachment->object_name(); |
237 GLuint source_texture = 0; | 234 GLuint source_texture = 0; |
238 if (!decoder->GetServiceTextureId(source_texture_client_id, | 235 if (!decoder->GetServiceTextureId(source_texture_client_id, |
239 &source_texture)) | 236 &source_texture)) |
240 continue; | 237 continue; |
241 GLsizei width = attachment->width(); | 238 GLsizei width = attachment->width(); |
242 GLsizei height = attachment->height(); | 239 GLsizei height = attachment->height(); |
243 GLenum internal_format = attachment->internal_format(); | 240 GLenum internal_format = attachment->internal_format(); |
244 | 241 |
245 // Resize internal structures - only if needed. | 242 // Resize internal structures - only if needed. |
246 OnSize(width, height); | 243 OnSize(width, height); |
247 | 244 |
248 // CMAA internally expects GL_RGBA8 textures. | 245 // CMAA internally expects GL_RGBA8 textures. |
249 // Process using a GL_RGBA8 copy if this is not the case. | 246 // Process using a GL_RGBA8 copy if this is not the case. |
250 bool do_copy = internal_format != GL_RGBA8; | 247 bool do_copy = internal_format != GL_RGBA8; |
251 | 248 |
252 // Copy source_texture to rgba8_texture_ | 249 // CMAA Effect |
253 if (do_copy) { | 250 if (do_copy) { |
254 CopyTexture(source_texture, rgba8_texture_, false); | 251 ApplyCMAAEffectTexture(source_texture, rgba8_texture_, do_copy); |
| 252 CopyTexture(rgba8_texture_, source_texture); |
| 253 } else { |
| 254 ApplyCMAAEffectTexture(source_texture, source_texture, do_copy); |
255 } | 255 } |
256 | 256 |
257 // CMAA Effect | 257 decoder->RestoreTextureState(source_texture); |
258 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, last_framebuffer); | |
259 if (do_copy) { | |
260 ApplyCMAAEffectTexture(rgba8_texture_, rgba8_texture_); | |
261 } else { | |
262 ApplyCMAAEffectTexture(source_texture, source_texture); | |
263 } | |
264 | |
265 // Copy rgba8_texture_ to source_texture | |
266 if (do_copy) { | |
267 // Move source_texture to the first color attachment of the copy fbo. | |
268 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, last_framebuffer); | |
269 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, | |
270 GL_TEXTURE_2D, 0, 0); | |
271 glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_); | |
272 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | |
273 GL_TEXTURE_2D, source_texture, 0); | |
274 | |
275 CopyTexture(rgba8_texture_, source_texture, true); | |
276 | |
277 // Restore color attachments | |
278 glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_); | |
279 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | |
280 GL_TEXTURE_2D, rgba8_texture_, 0); | |
281 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, last_framebuffer); | |
282 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, | |
283 GL_TEXTURE_2D, source_texture, 0); | |
284 } | |
285 } | 258 } |
286 } | 259 } |
287 | 260 |
288 // Restore state | 261 // Restore state |
289 decoder->RestoreAllAttributes(); | 262 decoder->RestoreAllAttributes(); |
290 decoder->RestoreTextureUnitBindings(0); | 263 decoder->RestoreTextureUnitBindings(0); |
291 decoder->RestoreTextureUnitBindings(1); | 264 decoder->RestoreTextureUnitBindings(1); |
292 decoder->RestoreActiveTexture(); | 265 decoder->RestoreActiveTexture(); |
293 decoder->RestoreProgramBindings(); | 266 decoder->RestoreProgramBindings(); |
294 decoder->RestoreBufferBindings(); | 267 decoder->RestoreBufferBindings(); |
295 decoder->RestoreFramebufferBindings(); | 268 decoder->RestoreFramebufferBindings(); |
296 decoder->RestoreGlobalState(); | 269 decoder->RestoreGlobalState(); |
297 } | 270 } |
298 | 271 |
299 void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( | 272 void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( |
300 GLuint source_texture, | 273 GLuint source_texture, |
301 GLuint dest_texture) { | 274 GLuint dest_texture, |
| 275 bool do_copy) { |
302 frame_id_++; | 276 frame_id_++; |
303 | 277 |
304 GLuint edge_texture_a; | 278 GLuint edge_texture_a; |
305 GLuint edge_texture_b; | 279 GLuint edge_texture_b; |
306 | 280 |
307 // Flip flop - One pass clears the texture that needs clearing for the other | 281 // Flip flop - One pass clears the texture that needs clearing for the other |
308 // one (actually it's only important that it clears the highest bit) | 282 // one (actually it's only important that it clears the highest bit) |
309 if ((frame_id_ % 2) == 0) { | 283 if ((frame_id_ % 2) == 0) { |
310 edge_texture_a = edges0_texture_; | 284 edge_texture_a = edges0_texture_; |
311 edge_texture_b = edges1_texture_; | 285 edge_texture_b = edges1_texture_; |
(...skipping 25 matching lines...) Expand all Loading... |
337 // Detect edges Pass 0 | 311 // Detect edges Pass 0 |
338 // - For every pixel detect edges to the right and down and output depth | 312 // - For every pixel detect edges to the right and down and output depth |
339 // mask where edges detected (1 - far, for detected, 0-near for empty | 313 // mask where edges detected (1 - far, for detected, 0-near for empty |
340 // pixels) | 314 // pixels) |
341 | 315 |
342 // Inputs | 316 // Inputs |
343 // g_screenTexture source_texture tex0 | 317 // g_screenTexture source_texture tex0 |
344 // Outputs | 318 // Outputs |
345 // gl_FragDepth mini4_edge_depth_texture_ fbo.depth | 319 // gl_FragDepth mini4_edge_depth_texture_ fbo.depth |
346 // out uvec4 outEdges mini4_edge_texture_ fbo.col | 320 // out uvec4 outEdges mini4_edge_texture_ fbo.col |
347 // image2D g_resultTextureFlt4Slot1 working_color_texture_ image1 | 321 // image2D g_resultRGBATextureSlot1 working_color_texture_ image1 |
348 GLenum edge_format = supports_r8_image_ ? GL_R8 : GL_R32F; | 322 GLenum edge_format = supports_r8_image_ ? GL_R8 : GL_R32F; |
349 | 323 |
350 { | 324 { |
351 glUseProgram(edges0_shader_); | 325 glUseProgram(edges0_shader_); |
352 glUniform2f(0, 1.0f / width_, 1.0f / height_); | 326 glUniform2f(0, 1.0f / width_, 1.0f / height_); |
353 glDepthMask(GL_TRUE); | 327 glDepthMask(GL_TRUE); |
354 glDepthFunc(GL_ALWAYS); | 328 glDepthFunc(GL_ALWAYS); |
355 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 329 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
356 | 330 |
357 if (!is_gles31_compatible_) { | 331 if (!is_gles31_compatible_) { |
358 glUniform1i(edges1_shader_result_texture_float4_slot1_, 1); | 332 glUniform1i(edges0_shader_result_rgba_texture_slot1_, 1); |
| 333 glUniform1i(edges0_shader_target_texture_slot2_, 2); |
359 } | 334 } |
360 glBindImageTextureEXT(1, working_color_texture_, 0, GL_FALSE, 0, | 335 glBindImageTextureEXT(1, working_color_texture_, 0, GL_FALSE, 0, |
361 GL_WRITE_ONLY, GL_RGBA8); | 336 GL_WRITE_ONLY, GL_RGBA8); |
| 337 if (do_copy) { |
| 338 glUniform1i(2, GL_TRUE); |
| 339 glBindImageTextureEXT(2, dest_texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, |
| 340 GL_RGBA8); |
| 341 } else { |
| 342 glUniform1i(2, GL_FALSE); |
| 343 } |
362 | 344 |
363 glActiveTexture(GL_TEXTURE0); | 345 glActiveTexture(GL_TEXTURE0); |
364 glBindTexture(GL_TEXTURE_2D, source_texture); | 346 glBindTexture(GL_TEXTURE_2D, source_texture); |
365 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 347 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
366 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 348 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
367 | 349 |
368 glDrawArrays(GL_TRIANGLES, 0, 3); | 350 glDrawArrays(GL_TRIANGLES, 0, 3); |
369 } | 351 } |
370 | 352 |
371 // Detect edges Pass 1 (finish the previous pass edge processing). | 353 // Detect edges Pass 1 (finish the previous pass edge processing). |
372 // Do the culling of non-dominant local edges (leave mainly locally dominant | 354 // Do the culling of non-dominant local edges (leave mainly locally dominant |
373 // edges) and merge Right and Bottom edges into TopRightBottomLeft | 355 // edges) and merge Right and Bottom edges into TopRightBottomLeft |
374 | 356 |
375 // Inputs | 357 // Inputs |
376 // g_src0Texture4Uint mini4_edge_texture_ tex1 | 358 // g_src0Texture4Uint mini4_edge_texture_ tex1 |
377 // Outputs | 359 // Outputs |
378 // image2D g_resultTexture edge_texture_b image0 | 360 // image2D g_resultEdgeTexture edge_texture_b image0 |
379 { | 361 { |
380 glUseProgram(edges1_shader_); | 362 glUseProgram(edges1_shader_); |
381 glUniform2f(0, 1.0f / width_, 1.0f / height_); | 363 glUniform2f(0, 1.0f / width_, 1.0f / height_); |
382 glDepthMask(GL_FALSE); | 364 glDepthMask(GL_FALSE); |
383 glDepthFunc(GL_LESS); | 365 glDepthFunc(GL_LESS); |
384 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); | 366 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
385 | 367 |
386 if (!is_gles31_compatible_) { | 368 if (!is_gles31_compatible_) { |
387 glUniform1i(edges1_shader_result_texture_, 0); | 369 glUniform1i(edges1_shader_result_edge_texture_, 0); |
388 } | 370 } |
389 glBindImageTextureEXT(0, edge_texture_b, 0, GL_FALSE, 0, GL_WRITE_ONLY, | 371 glBindImageTextureEXT(0, edge_texture_b, 0, GL_FALSE, 0, GL_WRITE_ONLY, |
390 edge_format); | 372 edge_format); |
391 | 373 |
392 glActiveTexture(GL_TEXTURE1); | 374 glActiveTexture(GL_TEXTURE1); |
393 glBindTexture(GL_TEXTURE_2D, mini4_edge_texture_); | 375 glBindTexture(GL_TEXTURE_2D, mini4_edge_texture_); |
394 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 376 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
395 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 377 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
396 | 378 |
397 glDrawArrays(GL_TRIANGLES, 0, 3); | 379 glDrawArrays(GL_TRIANGLES, 0, 3); |
398 } | 380 } |
399 | 381 |
400 // - Combine RightBottom (.xy) edges from previous pass into | 382 // - Combine RightBottom (.xy) edges from previous pass into |
401 // RightBottomLeftTop (.xyzw) edges and output it into the mask. | 383 // RightBottomLeftTop (.xyzw) edges and output it into the mask. |
402 // - On all pixels with any edge, input buffer into a temporary color buffer | 384 // - On all pixels with any edge, input buffer into a temporary color buffer |
403 // needed for correct blending in the next pass (other pixels not needed | 385 // needed for correct blending in the next pass (other pixels not needed |
404 // so not copied to avoid bandwidth use). | 386 // so not copied to avoid bandwidth use). |
405 // - On all pixels with 2 or more edges output positive depth mask for the | 387 // - On all pixels with 2 or more edges output positive depth mask for the |
406 // next pass. | 388 // next pass. |
407 | 389 |
408 // Inputs | 390 // Inputs |
409 // g_src0TextureFlt edge_texture_b tex1 //ps | 391 // g_src0TextureFlt edge_texture_b tex1 //ps |
410 // Outputs | 392 // Outputs |
411 // image2D g_resultTextureSlot2 edge_texture_a image2 | 393 // image2D g_resultEdgeTexture edge_texture_a image2 |
412 // gl_FragDepth mini4_edge_texture_ fbo.depth | 394 // gl_FragDepth mini4_edge_texture_ fbo.depth |
413 { | 395 { |
414 // Combine edges: each pixel will now contain info on all (top, right, | 396 // Combine edges: each pixel will now contain info on all (top, right, |
415 // bottom, left) edges; also mark depth 1 value on all pixels with any edge | 397 // bottom, left) edges; also mark depth 1 value on all pixels with any edge |
416 // and also copy source color data but only on edge pixels | 398 // and also copy source color data but only on edge pixels |
417 glUseProgram(edges_combine_shader_); | 399 glUseProgram(edges_combine_shader_); |
418 glUniform2f(0, 1.0f / width_, 1.0f / height_); | 400 glUniform2f(0, 1.0f / width_, 1.0f / height_); |
419 glDepthMask(GL_TRUE); | 401 glDepthMask(GL_TRUE); |
420 glDepthFunc(GL_LESS); | 402 glDepthFunc(GL_LESS); |
421 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); | 403 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
422 | 404 |
423 if (!is_gles31_compatible_) { | 405 if (!is_gles31_compatible_) { |
424 glUniform1i(edges_combine_shader_result_texture_slot2_, 2); | 406 glUniform1i(edges_combine_shader_result_edge_texture_, 0); |
425 } | 407 } |
426 glBindImageTextureEXT(2, edge_texture_a, 0, GL_FALSE, 0, GL_WRITE_ONLY, | 408 glBindImageTextureEXT(0, edge_texture_a, 0, GL_FALSE, 0, GL_WRITE_ONLY, |
427 edge_format); | 409 edge_format); |
428 | 410 |
429 glActiveTexture(GL_TEXTURE1); | 411 glActiveTexture(GL_TEXTURE1); |
430 glBindTexture(GL_TEXTURE_2D, edge_texture_b); | 412 glBindTexture(GL_TEXTURE_2D, edge_texture_b); |
431 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 413 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
432 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 414 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
433 | 415 |
434 glDrawArrays(GL_TRIANGLES, 0, 3); | 416 glDrawArrays(GL_TRIANGLES, 0, 3); |
435 } | 417 } |
436 | 418 |
437 // Using depth mask and [earlydepthstencil] to work on pixels with 2, 3, 4 | 419 // Using depth mask and [earlydepthstencil] to work on pixels with 2, 3, 4 |
438 // edges: | 420 // edges: |
439 // - First blend simple blur map for 2,3,4 edge pixels | 421 // - First blend simple blur map for 2,3,4 edge pixels |
440 // - Then do the lines (line length counter -should- guarantee no overlap | 422 // - Then do the lines (line length counter -should- guarantee no overlap |
441 // with other pixels - pixels with 1 edge are excluded in the previous | 423 // with other pixels - pixels with 1 edge are excluded in the previous |
442 // pass and the pixels with 2 parallel edges are excluded in the simple | 424 // pass and the pixels with 2 parallel edges are excluded in the simple |
443 // blur) | 425 // blur) |
444 | 426 |
445 // Inputs | 427 // Inputs |
446 // g_screenTexture working_color_texture_ tex0 | 428 // g_screenTexture working_color_texture_ tex0 |
447 // g_src0TextureFlt edge_texture_a tex1 //ps | 429 // g_src0TextureFlt edge_texture_a tex1 //ps |
448 // sampled | 430 // sampled |
449 // Outputs | 431 // Outputs |
450 // g_resultTextureFlt4Slot1 dest_texture image1 | 432 // g_resultRGBATextureSlot1 dest_texture image1 |
451 // gl_FragDepth mini4_edge_texture_ fbo.depth | 433 // gl_FragDepth mini4_edge_texture_ fbo.depth |
452 { | 434 { |
453 glUseProgram(process_and_apply_shader_); | 435 glUseProgram(process_and_apply_shader_); |
454 glUniform2f(0, 1.0f / width_, 1.0f / height_); | 436 glUniform2f(0, 1.0f / width_, 1.0f / height_); |
455 glDepthMask(GL_FALSE); | 437 glDepthMask(GL_FALSE); |
456 glDepthFunc(GL_LESS); | 438 glDepthFunc(GL_LESS); |
457 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); | 439 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
458 | 440 |
459 if (!is_gles31_compatible_) { | 441 if (!is_gles31_compatible_) { |
460 glUniform1i(process_and_apply_shader_result_texture_float4_slot1_, 1); | 442 glUniform1i(process_and_apply_shader_result_rgba_texture_slot1_, 1); |
461 } | 443 } |
462 glBindImageTextureEXT(1, dest_texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, | 444 glBindImageTextureEXT(1, dest_texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, |
463 GL_RGBA8); | 445 GL_RGBA8); |
464 | 446 |
465 glActiveTexture(GL_TEXTURE0); | 447 glActiveTexture(GL_TEXTURE0); |
466 glBindTexture(GL_TEXTURE_2D, working_color_texture_); | 448 glBindTexture(GL_TEXTURE_2D, working_color_texture_); |
467 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 449 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
468 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 450 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
469 | 451 |
470 glActiveTexture(GL_TEXTURE1); | 452 glActiveTexture(GL_TEXTURE1); |
(...skipping 17 matching lines...) Expand all Loading... |
488 | 470 |
489 ReleaseTextures(); | 471 ReleaseTextures(); |
490 | 472 |
491 height_ = height; | 473 height_ = height; |
492 width_ = width; | 474 width_ = width; |
493 | 475 |
494 glGenFramebuffersEXT(1, ©_framebuffer_); | 476 glGenFramebuffersEXT(1, ©_framebuffer_); |
495 glGenTextures(1, &rgba8_texture_); | 477 glGenTextures(1, &rgba8_texture_); |
496 glBindTexture(GL_TEXTURE_2D, rgba8_texture_); | 478 glBindTexture(GL_TEXTURE_2D, rgba8_texture_); |
497 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8, width, height); | 479 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8, width, height); |
| 480 glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_); |
| 481 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 482 rgba8_texture_, 0); |
498 | 483 |
499 // Edges texture - R8 | 484 // Edges texture - R8 |
500 // OpenGLES has no single component 8/16-bit image support, so needs to be R32 | 485 // OpenGLES has no single component 8/16-bit image support, so needs to be R32 |
501 // Although CHT does support R8. | 486 // Although CHT does support R8. |
502 GLenum edge_format = supports_r8_image_ ? GL_R8 : GL_R32F; | 487 GLenum edge_format = supports_r8_image_ ? GL_R8 : GL_R32F; |
503 glGenTextures(1, &edges0_texture_); | 488 glGenTextures(1, &edges0_texture_); |
504 glBindTexture(GL_TEXTURE_2D, edges0_texture_); | 489 glBindTexture(GL_TEXTURE_2D, edges0_texture_); |
505 glTexStorage2DEXT(GL_TEXTURE_2D, 1, edge_format, width, height); | 490 glTexStorage2DEXT(GL_TEXTURE_2D, 1, edge_format, width, height); |
506 | 491 |
507 glGenTextures(1, &edges1_texture_); | 492 glGenTextures(1, &edges1_texture_); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 glDeleteTextures(1, &rgba8_texture_); | 542 glDeleteTextures(1, &rgba8_texture_); |
558 glDeleteTextures(1, &edges0_texture_); | 543 glDeleteTextures(1, &edges0_texture_); |
559 glDeleteTextures(1, &edges1_texture_); | 544 glDeleteTextures(1, &edges1_texture_); |
560 glDeleteTextures(1, &mini4_edge_texture_); | 545 glDeleteTextures(1, &mini4_edge_texture_); |
561 glDeleteTextures(1, &mini4_edge_depth_texture_); | 546 glDeleteTextures(1, &mini4_edge_depth_texture_); |
562 glDeleteTextures(1, &working_color_texture_); | 547 glDeleteTextures(1, &working_color_texture_); |
563 } | 548 } |
564 textures_initialized_ = false; | 549 textures_initialized_ = false; |
565 } | 550 } |
566 | 551 |
| 552 // TODO(dshwang): reuse CopyTextureCHROMIUMResourceManager. crbug.com/535198 |
567 void ApplyFramebufferAttachmentCMAAINTELResourceManager::CopyTexture( | 553 void ApplyFramebufferAttachmentCMAAINTELResourceManager::CopyTexture( |
568 GLint source, | 554 GLint source, |
569 GLint dest, | 555 GLint dest) { |
570 bool via_fbo) { | 556 glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_); |
| 557 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 558 GL_TEXTURE_2D, dest, 0); |
571 glViewport(0, 0, width_, height_); | 559 glViewport(0, 0, width_, height_); |
| 560 |
572 glActiveTexture(GL_TEXTURE0); | 561 glActiveTexture(GL_TEXTURE0); |
573 glBindTexture(GL_TEXTURE_2D, source); | 562 glBindTexture(GL_TEXTURE_2D, source); |
| 563 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 564 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
574 | 565 |
575 if (!via_fbo) { | 566 glUseProgram(copy_to_framebuffer_shader_); |
576 glUseProgram(copy_to_image_shader_); | |
577 if (!is_gles31_compatible_) { | |
578 glUniform1i(copy_to_image_shader_outTexture_, 0); | |
579 } | |
580 glBindImageTextureEXT(0, dest, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA8); | |
581 } else { | |
582 glDisable(GL_DEPTH_TEST); | |
583 glDisable(GL_STENCIL_TEST); | |
584 glDisable(GL_CULL_FACE); | |
585 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | |
586 glDepthMask(GL_FALSE); | |
587 glDisable(GL_BLEND); | |
588 glUseProgram(copy_to_framebuffer_shader_); | |
589 } | |
590 | 567 |
591 glDrawArrays(GL_TRIANGLES, 0, 3); | 568 glDrawArrays(GL_TRIANGLES, 0, 3); |
592 glUseProgram(0); | 569 glUseProgram(0); |
593 glBindTexture(GL_TEXTURE_2D, 0); | 570 glBindTexture(GL_TEXTURE_2D, 0); |
594 } | 571 } |
595 | 572 |
596 GLuint ApplyFramebufferAttachmentCMAAINTELResourceManager::CreateProgram( | 573 GLuint ApplyFramebufferAttachmentCMAAINTELResourceManager::CreateProgram( |
597 const char* defines, | 574 const char* defines, |
598 const char* vs_source, | 575 const char* vs_source, |
599 const char* fs_source) { | 576 const char* fs_source) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 | 685 |
709 \n#define SETTINGS_ALLOW_SHORT_Zs 1\n | 686 \n#define SETTINGS_ALLOW_SHORT_Zs 1\n |
710 \n#define EDGE_DETECT_THRESHOLD 13.0f\n | 687 \n#define EDGE_DETECT_THRESHOLD 13.0f\n |
711 \n#define saturate(x) clamp((x), 0.0, 1.0)\n | 688 \n#define saturate(x) clamp((x), 0.0, 1.0)\n |
712 | 689 |
713 // bind to a uniform buffer bind point 0 | 690 // bind to a uniform buffer bind point 0 |
714 layout(location = 0) uniform vec2 g_OneOverScreenSize; | 691 layout(location = 0) uniform vec2 g_OneOverScreenSize; |
715 \n#ifndef EDGE_DETECT_THRESHOLD\n | 692 \n#ifndef EDGE_DETECT_THRESHOLD\n |
716 layout(location = 1) uniform float g_ColorThreshold; | 693 layout(location = 1) uniform float g_ColorThreshold; |
717 \n#endif\n | 694 \n#endif\n |
| 695 \n#ifdef DETECT_EDGES1\n |
| 696 layout(location = 2) uniform int g_DoCopy; |
| 697 \n#endif\n |
718 | 698 |
719 \n#ifdef SUPPORTS_USAMPLER2D\n | 699 \n#ifdef SUPPORTS_USAMPLER2D\n |
720 \n#define USAMPLER usampler2D\n | 700 \n#define USAMPLER usampler2D\n |
721 \n#define UVEC4 uvec4\n | 701 \n#define UVEC4 uvec4\n |
722 \n#define LOAD_UINT(arg) arg\n | 702 \n#define LOAD_UINT(arg) arg\n |
723 \n#define STORE_UVEC4(arg) arg\n | 703 \n#define STORE_UVEC4(arg) arg\n |
724 \n#else\n | 704 \n#else\n |
725 \n#define USAMPLER sampler2D\n | 705 \n#define USAMPLER sampler2D\n |
726 \n#define UVEC4 vec4\n | 706 \n#define UVEC4 vec4\n |
727 \n#define LOAD_UINT(arg) uint(arg * 255.0f)\n | 707 \n#define LOAD_UINT(arg) uint(arg * 255.0f)\n |
728 \n#define STORE_UVEC4(arg) vec4(float(arg.x) / 255.0f, | 708 \n#define STORE_UVEC4(arg) vec4(float(arg.x) / 255.0f, |
729 float(arg.y) / 255.0f, | 709 float(arg.y) / 255.0f, |
730 float(arg.z) / 255.0f, | 710 float(arg.z) / 255.0f, |
731 float(arg.w) / 255.0f)\n | 711 float(arg.w) / 255.0f)\n |
732 \n#endif\n | 712 \n#endif\n |
733 | 713 |
734 // bind to texture stage 0/1 | 714 // bind to texture stage 0/1 |
735 layout(binding = 0) uniform highp sampler2D g_screenTexture; | 715 layout(binding = 0) uniform highp sampler2D g_screenTexture; |
736 layout(binding = 1) uniform highp sampler2D g_src0TextureFlt; | 716 layout(binding = 1) uniform highp sampler2D g_src0TextureFlt; |
737 layout(binding = 1) uniform highp USAMPLER g_src0Texture4Uint; | 717 layout(binding = 1) uniform highp USAMPLER g_src0Texture4Uint; |
738 | 718 |
739 // bind to image stage 0/1/2 | 719 // bind to image stage 0/1/2 |
740 \n#ifdef GL_ES\n | 720 \n#ifdef GL_ES\n |
741 layout(binding = 0, EDGE_READ_FORMAT) restrict writeonly uniform highp | 721 layout(binding = 0, EDGE_READ_FORMAT) restrict writeonly uniform highp |
742 image2D g_resultTexture; | 722 image2D g_resultEdgeTexture; |
743 layout(binding = 1, rgba8) restrict writeonly uniform highp | 723 layout(binding = 1, rgba8) restrict writeonly uniform highp |
744 image2D g_resultTextureFlt4Slot1; | 724 image2D g_resultRGBATextureSlot1; |
745 layout(binding = 2, EDGE_READ_FORMAT) restrict writeonly uniform highp | 725 layout(binding = 2, rgba8) restrict writeonly uniform highp |
746 image2D g_resultTextureSlot2; | 726 image2D g_targetTextureSlot2; |
747 \n#else\n | 727 \n#else\n |
748 layout(EDGE_READ_FORMAT) restrict writeonly uniform highp | 728 layout(EDGE_READ_FORMAT) restrict writeonly uniform highp |
749 image2D g_resultTexture; | 729 image2D g_resultEdgeTexture; |
750 layout(rgba8) restrict writeonly uniform highp | 730 layout(rgba8) restrict writeonly uniform highp |
751 image2D g_resultTextureFlt4Slot1; | 731 image2D g_resultRGBATextureSlot1; |
752 layout(EDGE_READ_FORMAT) restrict writeonly uniform highp | 732 layout(rgba8) restrict writeonly uniform highp |
753 image2D g_resultTextureSlot2; | 733 image2D g_targetTextureSlot2; |
754 \n#endif\n | 734 \n#endif\n |
755 | 735 |
756 // Constants | 736 // Constants |
757 const vec4 c_lumWeights = vec4(0.2126f, 0.7152f, 0.0722f, 0.0000f); | 737 const vec4 c_lumWeights = vec4(0.2126f, 0.7152f, 0.0722f, 0.0000f); |
758 | 738 |
759 \n#ifdef EDGE_DETECT_THRESHOLD\n | 739 \n#ifdef EDGE_DETECT_THRESHOLD\n |
760 const float c_ColorThreshold = 1.0f / EDGE_DETECT_THRESHOLD; | 740 const float c_ColorThreshold = 1.0f / EDGE_DETECT_THRESHOLD; |
761 \n#endif\n | 741 \n#endif\n |
762 | 742 |
763 // Must be even number; Will work with ~16 pretty good too for | 743 // Must be even number; Will work with ~16 pretty good too for |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 | 982 |
1003 float totalLength = float(loopTo - loopFrom) + 1.0 - leftOdd - | 983 float totalLength = float(loopTo - loopFrom) + 1.0 - leftOdd - |
1004 rightOdd; | 984 rightOdd; |
1005 | 985 |
1006 for (int i = loopFrom; i <= loopTo; i++) { | 986 for (int i = loopFrom; i <= loopTo; i++) { |
1007 highp ivec2 pixelPos = screenPos + stepRight * i; | 987 highp ivec2 pixelPos = screenPos + stepRight * i; |
1008 vec2 pixelPosFlt = vec2(float(pixelPos.x) + 0.5, | 988 vec2 pixelPosFlt = vec2(float(pixelPos.x) + 0.5, |
1009 float(pixelPos.y) + 0.5); | 989 float(pixelPos.y) + 0.5); |
1010 | 990 |
1011 \n#ifdef DEBUG_OUTPUT_AAINFO\n | 991 \n#ifdef DEBUG_OUTPUT_AAINFO\n |
1012 imageStore(g_resultTextureSlot2, pixelPos, | 992 imageStore(g_resultEdgeTexture, pixelPos, |
1013 PackBlurAAInfo(pixelPos, 1u)); | 993 PackBlurAAInfo(pixelPos, 1u)); |
1014 \n#endif\n | 994 \n#endif\n |
1015 | 995 |
1016 float m = (float(i) + 0.5 - leftOdd - float(loopFrom)) / | 996 float m = (float(i) + 0.5 - leftOdd - float(loopFrom)) / |
1017 totalLength; | 997 totalLength; |
1018 m = saturate(m); | 998 m = saturate(m); |
1019 float k = m - ((i > 0) ? 1.0 : 0.0); | 999 float k = m - ((i > 0) ? 1.0 : 0.0); |
1020 k = (invertedZShape) ? (k) : (-k); | 1000 k = (invertedZShape) ? (k) : (-k); |
1021 | 1001 |
1022 vec4 color = textureLod(g_screenTexture, | 1002 vec4 color = textureLod(g_screenTexture, |
1023 (pixelPosFlt + blendDir * k) * pixelSize, | 1003 (pixelPosFlt + blendDir * k) * pixelSize, |
1024 0.0); | 1004 0.0); |
1025 | 1005 |
1026 \n#ifdef IN_GAMMA_CORRECT_MODE\n | 1006 \n#ifdef IN_GAMMA_CORRECT_MODE\n |
1027 color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb); | 1007 color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb); |
1028 \n#endif\n | 1008 \n#endif\n |
1029 imageStore(g_resultTextureFlt4Slot1, pixelPos, color); | 1009 imageStore(g_resultRGBATextureSlot1, pixelPos, color); |
1030 } | 1010 } |
1031 } | 1011 } |
1032 | 1012 |
1033 vec4 CalcDbgDisplayColor(const vec4 blurMap) { | 1013 vec4 CalcDbgDisplayColor(const vec4 blurMap) { |
1034 vec3 pixelC = vec3(0.0, 0.0, 0.0); | 1014 vec3 pixelC = vec3(0.0, 0.0, 0.0); |
1035 vec3 pixelL = vec3(0.0, 0.0, 1.0); | 1015 vec3 pixelL = vec3(0.0, 0.0, 1.0); |
1036 vec3 pixelT = vec3(1.0, 0.0, 0.0); | 1016 vec3 pixelT = vec3(1.0, 0.0, 0.0); |
1037 vec3 pixelR = vec3(0.0, 1.0, 0.0); | 1017 vec3 pixelR = vec3(0.0, 1.0, 0.0); |
1038 vec3 pixelB = vec3(0.8, 0.8, 0.0); | 1018 vec3 pixelB = vec3(0.8, 0.8, 0.0); |
1039 | 1019 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(0, 1)); | 1059 texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(0, 1)); |
1080 vec4 pixel11 = | 1060 vec4 pixel11 = |
1081 texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(1, 1)); | 1061 texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(1, 1)); |
1082 vec4 pixel21 = | 1062 vec4 pixel21 = |
1083 texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(2, 1)); | 1063 texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(2, 1)); |
1084 vec4 pixel02 = | 1064 vec4 pixel02 = |
1085 texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(0, 2)); | 1065 texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(0, 2)); |
1086 vec4 pixel12 = | 1066 vec4 pixel12 = |
1087 texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(1, 2)); | 1067 texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(1, 2)); |
1088 | 1068 |
| 1069 if (g_DoCopy == 1) { |
| 1070 imageStore(g_targetTextureSlot2, screenPosI.xy + ivec2(0, 0), pixel00); |
| 1071 imageStore(g_targetTextureSlot2, screenPosI.xy + ivec2(1, 0), pixel10); |
| 1072 imageStore(g_targetTextureSlot2, screenPosI.xy + ivec2(0, 1), pixel01); |
| 1073 imageStore(g_targetTextureSlot2, screenPosI.xy + ivec2(1, 1), pixel11); |
| 1074 } |
| 1075 |
1089 float storeFlagPixel00 = 0.0; | 1076 float storeFlagPixel00 = 0.0; |
1090 float storeFlagPixel10 = 0.0; | 1077 float storeFlagPixel10 = 0.0; |
1091 float storeFlagPixel20 = 0.0; | 1078 float storeFlagPixel20 = 0.0; |
1092 float storeFlagPixel01 = 0.0; | 1079 float storeFlagPixel01 = 0.0; |
1093 float storeFlagPixel11 = 0.0; | 1080 float storeFlagPixel11 = 0.0; |
1094 float storeFlagPixel21 = 0.0; | 1081 float storeFlagPixel21 = 0.0; |
1095 float storeFlagPixel02 = 0.0; | 1082 float storeFlagPixel02 = 0.0; |
1096 float storeFlagPixel12 = 0.0; | 1083 float storeFlagPixel12 = 0.0; |
1097 | 1084 |
1098 vec2 et; | 1085 vec2 et; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 storeFlagPixel11 += et.x; | 1139 storeFlagPixel11 += et.x; |
1153 storeFlagPixel11 += et.y; | 1140 storeFlagPixel11 += et.y; |
1154 storeFlagPixel21 += et.x; | 1141 storeFlagPixel21 += et.x; |
1155 storeFlagPixel12 += et.y; | 1142 storeFlagPixel12 += et.y; |
1156 } | 1143 } |
1157 | 1144 |
1158 gl_FragDepth = any(bvec4(outputEdges)) ? 1.0 : 0.0; | 1145 gl_FragDepth = any(bvec4(outputEdges)) ? 1.0 : 0.0; |
1159 | 1146 |
1160 if (gl_FragDepth != 0.0) { | 1147 if (gl_FragDepth != 0.0) { |
1161 if (storeFlagPixel00 != 0.0) | 1148 if (storeFlagPixel00 != 0.0) |
1162 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(0, 0), | 1149 imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(0, 0), |
1163 pixel00); | 1150 pixel00); |
1164 if (storeFlagPixel10 != 0.0) | 1151 if (storeFlagPixel10 != 0.0) |
1165 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(1, 0), | 1152 imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(1, 0), |
1166 pixel10); | 1153 pixel10); |
1167 if (storeFlagPixel20 != 0.0) | 1154 if (storeFlagPixel20 != 0.0) |
1168 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(2, 0), | 1155 imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(2, 0), |
1169 pixel20); | 1156 pixel20); |
1170 if (storeFlagPixel01 != 0.0) | 1157 if (storeFlagPixel01 != 0.0) |
1171 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(0, 1), | 1158 imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(0, 1), |
1172 pixel01); | 1159 pixel01); |
1173 if (storeFlagPixel02 != 0.0) | 1160 if (storeFlagPixel02 != 0.0) |
1174 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(0, 2), | 1161 imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(0, 2), |
1175 pixel02); | 1162 pixel02); |
1176 if (storeFlagPixel11 != 0.0) | 1163 if (storeFlagPixel11 != 0.0) |
1177 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(1, 1), | 1164 imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(1, 1), |
1178 pixel11); | 1165 pixel11); |
1179 if (storeFlagPixel21 != 0.0) | 1166 if (storeFlagPixel21 != 0.0) |
1180 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(2, 1), | 1167 imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(2, 1), |
1181 pixel21); | 1168 pixel21); |
1182 if (storeFlagPixel12 != 0.0) | 1169 if (storeFlagPixel12 != 0.0) |
1183 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(1, 2), | 1170 imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(1, 2), |
1184 pixel12); | 1171 pixel12); |
1185 } | 1172 } |
1186 outEdges = STORE_UVEC4(outputEdges); | 1173 outEdges = STORE_UVEC4(outputEdges); |
1187 } | 1174 } |
1188 \n#endif\n // DETECT_EDGES1 | 1175 \n#endif\n // DETECT_EDGES1 |
1189 | 1176 |
1190 vec2 UnpackThresholds(uint val) { | 1177 vec2 UnpackThresholds(uint val) { |
1191 return vec2(val & 0x0Fu, val >> 4u) / 15.0f; | 1178 return vec2(val & 0x0Fu, val >> 4u) / 15.0f; |
1192 } | 1179 } |
1193 | 1180 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 packedVals[(0) * 6 + (2)] = LOAD_UINT(packedQ3.x); | 1265 packedVals[(0) * 6 + (2)] = LOAD_UINT(packedQ3.x); |
1279 packedVals[(1) * 6 + (2)] = LOAD_UINT(packedQ3.y); | 1266 packedVals[(1) * 6 + (2)] = LOAD_UINT(packedQ3.y); |
1280 packedVals[(0) * 6 + (3)] = LOAD_UINT(packedQ3.z); | 1267 packedVals[(0) * 6 + (3)] = LOAD_UINT(packedQ3.z); |
1281 packedVals[(1) * 6 + (3)] = LOAD_UINT(packedQ3.w); | 1268 packedVals[(1) * 6 + (3)] = LOAD_UINT(packedQ3.w); |
1282 } | 1269 } |
1283 | 1270 |
1284 if (bool(packedVals[(2) * 6 + (2)])) { | 1271 if (bool(packedVals[(2) * 6 + (2)])) { |
1285 CollectEdges(2, 2, edges, packedVals); | 1272 CollectEdges(2, 2, edges, packedVals); |
1286 uint pe = PackEdge(PruneNonDominantEdges(edges)); | 1273 uint pe = PackEdge(PruneNonDominantEdges(edges)); |
1287 if (pe != 0u) { | 1274 if (pe != 0u) { |
1288 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(0, 0), | 1275 imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(0, 0), |
1289 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); | 1276 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); |
1290 } | 1277 } |
1291 } | 1278 } |
1292 | 1279 |
1293 if (bool(packedVals[(3) * 6 + (2)]) || | 1280 if (bool(packedVals[(3) * 6 + (2)]) || |
1294 bool(packedVals[(3) * 6 + (3)])) { | 1281 bool(packedVals[(3) * 6 + (3)])) { |
1295 UVEC4 packedQ5 = texelFetchOffset(g_src0Texture4Uint, | 1282 UVEC4 packedQ5 = texelFetchOffset(g_src0Texture4Uint, |
1296 screenPosI.xy, 0, ivec2(1, 0)); | 1283 screenPosI.xy, 0, ivec2(1, 0)); |
1297 packedVals[(4) * 6 + (2)] = LOAD_UINT(packedQ5.x); | 1284 packedVals[(4) * 6 + (2)] = LOAD_UINT(packedQ5.x); |
1298 packedVals[(5) * 6 + (2)] = LOAD_UINT(packedQ5.y); | 1285 packedVals[(5) * 6 + (2)] = LOAD_UINT(packedQ5.y); |
1299 packedVals[(4) * 6 + (3)] = LOAD_UINT(packedQ5.z); | 1286 packedVals[(4) * 6 + (3)] = LOAD_UINT(packedQ5.z); |
1300 packedVals[(5) * 6 + (3)] = LOAD_UINT(packedQ5.w); | 1287 packedVals[(5) * 6 + (3)] = LOAD_UINT(packedQ5.w); |
1301 } | 1288 } |
1302 | 1289 |
1303 if (bool(packedVals[(3) * 6 + (2)])) { | 1290 if (bool(packedVals[(3) * 6 + (2)])) { |
1304 UVEC4 packedQ2 = texelFetchOffset(g_src0Texture4Uint, | 1291 UVEC4 packedQ2 = texelFetchOffset(g_src0Texture4Uint, |
1305 screenPosI.xy, 0, ivec2(1, -1)); | 1292 screenPosI.xy, 0, ivec2(1, -1)); |
1306 packedVals[(4) * 6 + (0)] = LOAD_UINT(packedQ2.x); | 1293 packedVals[(4) * 6 + (0)] = LOAD_UINT(packedQ2.x); |
1307 packedVals[(5) * 6 + (0)] = LOAD_UINT(packedQ2.y); | 1294 packedVals[(5) * 6 + (0)] = LOAD_UINT(packedQ2.y); |
1308 packedVals[(4) * 6 + (1)] = LOAD_UINT(packedQ2.z); | 1295 packedVals[(4) * 6 + (1)] = LOAD_UINT(packedQ2.z); |
1309 packedVals[(5) * 6 + (1)] = LOAD_UINT(packedQ2.w); | 1296 packedVals[(5) * 6 + (1)] = LOAD_UINT(packedQ2.w); |
1310 | 1297 |
1311 CollectEdges(3, 2, edges, packedVals); | 1298 CollectEdges(3, 2, edges, packedVals); |
1312 uvec4 dominant_edges = PruneNonDominantEdges(edges); | 1299 uvec4 dominant_edges = PruneNonDominantEdges(edges); |
1313 // The rightmost edge of the texture is not edge. | 1300 // The rightmost edge of the texture is not edge. |
1314 // Note: texelFetch() on out of range gives an undefined value. | 1301 // Note: texelFetch() on out of range gives an undefined value. |
1315 uint pe = PackEdge(dominant_edges * uvec4(notTopRight.x, 1, 1, 1)); | 1302 uint pe = PackEdge(dominant_edges * uvec4(notTopRight.x, 1, 1, 1)); |
1316 if (pe != 0u) { | 1303 if (pe != 0u) { |
1317 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(1, 0), | 1304 imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(1, 0), |
1318 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); | 1305 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); |
1319 } | 1306 } |
1320 } | 1307 } |
1321 | 1308 |
1322 if (bool(packedVals[(2) * 6 + (3)]) || | 1309 if (bool(packedVals[(2) * 6 + (3)]) || |
1323 bool(packedVals[(3) * 6 + (3)])) { | 1310 bool(packedVals[(3) * 6 + (3)])) { |
1324 UVEC4 packedQ7 = texelFetchOffset(g_src0Texture4Uint, | 1311 UVEC4 packedQ7 = texelFetchOffset(g_src0Texture4Uint, |
1325 screenPosI.xy, 0, ivec2(0, 1)); | 1312 screenPosI.xy, 0, ivec2(0, 1)); |
1326 packedVals[(2) * 6 + (4)] = LOAD_UINT(packedQ7.x); | 1313 packedVals[(2) * 6 + (4)] = LOAD_UINT(packedQ7.x); |
1327 packedVals[(3) * 6 + (4)] = LOAD_UINT(packedQ7.y); | 1314 packedVals[(3) * 6 + (4)] = LOAD_UINT(packedQ7.y); |
1328 packedVals[(2) * 6 + (5)] = LOAD_UINT(packedQ7.z); | 1315 packedVals[(2) * 6 + (5)] = LOAD_UINT(packedQ7.z); |
1329 packedVals[(3) * 6 + (5)] = LOAD_UINT(packedQ7.w); | 1316 packedVals[(3) * 6 + (5)] = LOAD_UINT(packedQ7.w); |
1330 } | 1317 } |
1331 | 1318 |
1332 if (bool(packedVals[(2) * 6 + (3)])) { | 1319 if (bool(packedVals[(2) * 6 + (3)])) { |
1333 UVEC4 packedQ6 = texelFetchOffset(g_src0Texture4Uint, | 1320 UVEC4 packedQ6 = texelFetchOffset(g_src0Texture4Uint, |
1334 screenPosI.xy, 0, ivec2(-1, -1)); | 1321 screenPosI.xy, 0, ivec2(-1, -1)); |
1335 packedVals[(0) * 6 + (4)] = LOAD_UINT(packedQ6.x); | 1322 packedVals[(0) * 6 + (4)] = LOAD_UINT(packedQ6.x); |
1336 packedVals[(1) * 6 + (4)] = LOAD_UINT(packedQ6.y); | 1323 packedVals[(1) * 6 + (4)] = LOAD_UINT(packedQ6.y); |
1337 packedVals[(0) * 6 + (5)] = LOAD_UINT(packedQ6.z); | 1324 packedVals[(0) * 6 + (5)] = LOAD_UINT(packedQ6.z); |
1338 packedVals[(1) * 6 + (5)] = LOAD_UINT(packedQ6.w); | 1325 packedVals[(1) * 6 + (5)] = LOAD_UINT(packedQ6.w); |
1339 | 1326 |
1340 CollectEdges(2, 3, edges, packedVals); | 1327 CollectEdges(2, 3, edges, packedVals); |
1341 uvec4 dominant_edges = PruneNonDominantEdges(edges); | 1328 uvec4 dominant_edges = PruneNonDominantEdges(edges); |
1342 uint pe = PackEdge(dominant_edges * uvec4(1, notTopRight.y, 1, 1)); | 1329 uint pe = PackEdge(dominant_edges * uvec4(1, notTopRight.y, 1, 1)); |
1343 if (pe != 0u) { | 1330 if (pe != 0u) { |
1344 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(0, 1), | 1331 imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(0, 1), |
1345 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); | 1332 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); |
1346 } | 1333 } |
1347 } | 1334 } |
1348 | 1335 |
1349 if (bool(packedVals[(3) * 6 + (3)])) { | 1336 if (bool(packedVals[(3) * 6 + (3)])) { |
1350 CollectEdges(3, 3, edges, packedVals); | 1337 CollectEdges(3, 3, edges, packedVals); |
1351 uvec4 dominant_edges = PruneNonDominantEdges(edges); | 1338 uvec4 dominant_edges = PruneNonDominantEdges(edges); |
1352 uint pe = PackEdge(dominant_edges * uvec4(notTopRight, 1, 1)); | 1339 uint pe = PackEdge(dominant_edges * uvec4(notTopRight, 1, 1)); |
1353 if (pe != 0u) { | 1340 if (pe != 0u) { |
1354 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(1, 1), | 1341 imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(1, 1), |
1355 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); | 1342 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); |
1356 } | 1343 } |
1357 } | 1344 } |
1358 } | 1345 } |
1359 \n#endif\n // DETECT_EDGES2 | 1346 \n#endif\n // DETECT_EDGES2 |
1360 | 1347 |
1361 \n#ifdef COMBINE_EDGES\n | 1348 \n#ifdef COMBINE_EDGES\n |
1362 void CombineEdges() { | 1349 void CombineEdges() { |
1363 ivec3 screenPosIBase = ivec3(ivec2(gl_FragCoord.xy) * 2, 0); | 1350 ivec3 screenPosIBase = ivec3(ivec2(gl_FragCoord.xy) * 2, 0); |
1364 vec3 screenPosBase = vec3(screenPosIBase); | 1351 vec3 screenPosBase = vec3(screenPosIBase); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 packedEdgesArray[(0 + 1) * 3 + (1 + 1)]); | 1389 packedEdgesArray[(0 + 1) * 3 + (1 + 1)]); |
1403 uvec4 pixelsU = uvec4(packedEdgesArray[(1 + 0) * 3 + (0 + 0)], | 1390 uvec4 pixelsU = uvec4(packedEdgesArray[(1 + 0) * 3 + (0 + 0)], |
1404 packedEdgesArray[(1 + 1) * 3 + (0 + 0)], | 1391 packedEdgesArray[(1 + 1) * 3 + (0 + 0)], |
1405 packedEdgesArray[(1 + 0) * 3 + (0 + 1)], | 1392 packedEdgesArray[(1 + 0) * 3 + (0 + 1)], |
1406 packedEdgesArray[(1 + 1) * 3 + (0 + 1)]); | 1393 packedEdgesArray[(1 + 1) * 3 + (0 + 1)]); |
1407 | 1394 |
1408 uvec4 outEdge4 = | 1395 uvec4 outEdge4 = |
1409 pixelsC | ((pixelsL & 0x01u) << 2u) | ((pixelsU & 0x02u) << 2u); | 1396 pixelsC | ((pixelsL & 0x01u) << 2u) | ((pixelsU & 0x02u) << 2u); |
1410 vec4 outEdge4Flt = vec4(outEdge4) / 255.0; | 1397 vec4 outEdge4Flt = vec4(outEdge4) / 255.0; |
1411 | 1398 |
1412 imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(0, 0), | 1399 imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(0, 0), |
1413 outEdge4Flt.xxxx); | 1400 outEdge4Flt.xxxx); |
1414 imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(1, 0), | 1401 imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(1, 0), |
1415 outEdge4Flt.yyyy); | 1402 outEdge4Flt.yyyy); |
1416 imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(0, 1), | 1403 imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(0, 1), |
1417 outEdge4Flt.zzzz); | 1404 outEdge4Flt.zzzz); |
1418 imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(1, 1), | 1405 imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(1, 1), |
1419 outEdge4Flt.wwww); | 1406 outEdge4Flt.wwww); |
1420 | 1407 |
1421 // uvec4 numberOfEdges4 = uvec4(bitCount(outEdge4)); | 1408 // uvec4 numberOfEdges4 = uvec4(bitCount(outEdge4)); |
1422 // gl_FragDepth = | 1409 // gl_FragDepth = |
1423 // any(greaterThan(numberOfEdges4, uvec4(1))) ? 1.0 : 0.0; | 1410 // any(greaterThan(numberOfEdges4, uvec4(1))) ? 1.0 : 0.0; |
1424 | 1411 |
1425 gl_FragDepth = | 1412 gl_FragDepth = |
1426 any(greaterThan(outEdge4, uvec4(1))) ? 1.0 : 0.0; | 1413 any(greaterThan(outEdge4, uvec4(1))) ? 1.0 : 0.0; |
1427 } | 1414 } |
1428 \n#endif\n // COMBINE_EDGES | 1415 \n#endif\n // COMBINE_EDGES |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 } | 1649 } |
1663 | 1650 |
1664 color /= fourWeightSum + 0.0001; | 1651 color /= fourWeightSum + 0.0001; |
1665 | 1652 |
1666 color = mix(color, pixelC, centerWeight / allWeightSum); | 1653 color = mix(color, pixelC, centerWeight / allWeightSum); |
1667 \n#ifdef IN_GAMMA_CORRECT_MODE\n | 1654 \n#ifdef IN_GAMMA_CORRECT_MODE\n |
1668 color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb); | 1655 color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb); |
1669 \n#endif\n | 1656 \n#endif\n |
1670 | 1657 |
1671 \n#ifdef DEBUG_OUTPUT_AAINFO\n | 1658 \n#ifdef DEBUG_OUTPUT_AAINFO\n |
1672 imageStore(g_resultTextureSlot2, screenPosI.xy, | 1659 imageStore(g_resultEdgeTexture, screenPosI.xy, |
1673 PackBlurAAInfo(screenPosI.xy, numberOfEdges)); | 1660 PackBlurAAInfo(screenPosI.xy, numberOfEdges)); |
1674 \n#endif\n | 1661 \n#endif\n |
1675 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy, color); | 1662 imageStore(g_resultRGBATextureSlot1, screenPosI.xy, color); |
1676 | 1663 |
1677 if (numberOfEdges == 2u) { | 1664 if (numberOfEdges == 2u) { |
1678 uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)]; | 1665 uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)]; |
1679 uint packedEdgesB = packedEdgesArray[(1 + _x) * 4 + (0 + _y)]; | 1666 uint packedEdgesB = packedEdgesArray[(1 + _x) * 4 + (0 + _y)]; |
1680 uint packedEdgesR = packedEdgesArray[(2 + _x) * 4 + (1 + _y)]; | 1667 uint packedEdgesR = packedEdgesArray[(2 + _x) * 4 + (1 + _y)]; |
1681 uint packedEdgesT = packedEdgesArray[(1 + _x) * 4 + (2 + _y)]; | 1668 uint packedEdgesT = packedEdgesArray[(1 + _x) * 4 + (2 + _y)]; |
1682 | 1669 |
1683 bool isHorizontalA = ((packedEdgesC) == (0x01u | 0x02u)) && | 1670 bool isHorizontalA = ((packedEdgesC) == (0x01u | 0x02u)) && |
1684 ((packedEdgesR & 0x08u) == 0x08u); | 1671 ((packedEdgesR & 0x08u) == 0x08u); |
1685 bool isHorizontalB = ((packedEdgesC) == (0x01u | 0x08u)) && | 1672 bool isHorizontalB = ((packedEdgesC) == (0x01u | 0x08u)) && |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 \n#endif\n | 1869 \n#endif\n |
1883 } | 1870 } |
1884 ); | 1871 ); |
1885 | 1872 |
1886 const char | 1873 const char |
1887 ApplyFramebufferAttachmentCMAAINTELResourceManager::copy_frag_str_[] = | 1874 ApplyFramebufferAttachmentCMAAINTELResourceManager::copy_frag_str_[] = |
1888 SHADER( | 1875 SHADER( |
1889 precision highp float; | 1876 precision highp float; |
1890 layout(binding = 0) uniform highp sampler2D inTexture; | 1877 layout(binding = 0) uniform highp sampler2D inTexture; |
1891 layout(location = 0) out vec4 outColor; | 1878 layout(location = 0) out vec4 outColor; |
1892 \n#ifdef GL_ES\n | |
1893 layout(binding = 0, rgba8) restrict writeonly uniform highp | |
1894 image2D outTexture; | |
1895 \n#else\n | |
1896 layout(rgba8) restrict writeonly uniform highp image2D outTexture; | |
1897 \n#endif\n | |
1898 | 1879 |
1899 void main() { | 1880 void main() { |
1900 ivec2 screenPosI = ivec2( gl_FragCoord.xy ); | 1881 ivec2 screenPosI = ivec2( gl_FragCoord.xy ); |
1901 vec4 pixel = texelFetch(inTexture, screenPosI, 0); | 1882 vec4 pixel = texelFetch(inTexture, screenPosI, 0); |
1902 \n#ifdef OUT_FBO\n | |
1903 outColor = pixel; | 1883 outColor = pixel; |
1904 \n#else\n | |
1905 imageStore(outTexture, screenPosI, pixel); | |
1906 \n#endif\n | |
1907 } | 1884 } |
1908 ); | 1885 ); |
1909 /* clang-format on */ | 1886 /* clang-format on */ |
1910 | 1887 |
1911 } // namespace gles2 | 1888 } // namespace gles2 |
1912 } // namespace gpu | 1889 } // namespace gpu |
OLD | NEW |