| Index: gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc
|
| diff --git a/gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc b/gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc
|
| index 58051d49b45657ef86d52514034054608498e89f..b9209835ff59f42a90c35ec838a81ccef0fb802b 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc
|
| @@ -28,6 +28,8 @@ ApplyFramebufferAttachmentCMAAINTELResourceManager::
|
| frame_id_(0),
|
| width_(0),
|
| height_(0),
|
| + copy_to_framebuffer_shader_(0),
|
| + copy_to_image_shader_(0),
|
| edges0_shader_(0),
|
| edges1_shader_(0),
|
| edges_combine_shader_(0),
|
| @@ -41,11 +43,12 @@ ApplyFramebufferAttachmentCMAAINTELResourceManager::
|
| edges1_texture_(0),
|
| mini4_edge_texture_(0),
|
| mini4_edge_depth_texture_(0),
|
| - edges0_shader_result_rgba_texture_slot1_(0),
|
| - edges0_shader_target_texture_slot2_(0),
|
| - edges1_shader_result_edge_texture_(0),
|
| - process_and_apply_shader_result_rgba_texture_slot1_(0),
|
| - edges_combine_shader_result_edge_texture_(0) {}
|
| + edges1_shader_result_texture_float4_slot1_(0),
|
| + edges1_shader_result_texture_(0),
|
| + edges_combine_shader_result_texture_float4_slot1_(0),
|
| + process_and_apply_shader_result_texture_float4_slot1_(0),
|
| + edges_combine_shader_result_texture_slot2_(0),
|
| + copy_to_image_shader_outTexture_(0) {}
|
|
|
| ApplyFramebufferAttachmentCMAAINTELResourceManager::
|
| ~ApplyFramebufferAttachmentCMAAINTELResourceManager() {
|
| @@ -58,6 +61,10 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::Initialize(
|
| is_gles31_compatible_ =
|
| decoder->GetGLContext()->GetVersionInfo()->IsAtLeastGLES(3, 1);
|
|
|
| + copy_to_image_shader_ = CreateProgram("", vert_str_, copy_frag_str_);
|
| + copy_to_framebuffer_shader_ =
|
| + CreateProgram("#define OUT_FBO 1\n", vert_str_, copy_frag_str_);
|
| +
|
| // Check if RGBA8UI is supported as an FBO colour target with depth.
|
| // If not supported, GLSL needs to convert the data to/from float so there is
|
| // a small extra cost.
|
| @@ -173,16 +180,18 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::Initialize(
|
| process_and_apply_shader_ =
|
| CreateProgram(blur.str().c_str(), vert_str_, cmaa_frag_c_str);
|
|
|
| - edges0_shader_result_rgba_texture_slot1_ =
|
| - glGetUniformLocation(edges0_shader_, "g_resultRGBATextureSlot1");
|
| - edges0_shader_target_texture_slot2_ =
|
| - glGetUniformLocation(edges0_shader_, "g_targetTextureSlot2");
|
| - edges1_shader_result_edge_texture_ =
|
| - glGetUniformLocation(edges1_shader_, "g_resultEdgeTexture");
|
| - edges_combine_shader_result_edge_texture_ =
|
| - glGetUniformLocation(edges_combine_shader_, "g_resultEdgeTexture");
|
| - process_and_apply_shader_result_rgba_texture_slot1_ = glGetUniformLocation(
|
| - process_and_apply_shader_, "g_resultRGBATextureSlot1");
|
| + edges1_shader_result_texture_float4_slot1_ =
|
| + glGetUniformLocation(edges0_shader_, "g_resultTextureFlt4Slot1");
|
| + edges1_shader_result_texture_ =
|
| + glGetUniformLocation(edges1_shader_, "g_resultTexture");
|
| + edges_combine_shader_result_texture_float4_slot1_ =
|
| + glGetUniformLocation(edges_combine_shader_, "g_resultTextureFlt4Slot1");
|
| + edges_combine_shader_result_texture_slot2_ =
|
| + glGetUniformLocation(edges_combine_shader_, "g_resultTextureSlot2");
|
| + process_and_apply_shader_result_texture_float4_slot1_ = glGetUniformLocation(
|
| + process_and_apply_shader_, "g_resultTextureFlt4Slot1");
|
| + copy_to_image_shader_outTexture_ =
|
| + glGetUniformLocation(copy_to_image_shader_, "outTexture");
|
|
|
| initialized_ = true;
|
| }
|
| @@ -193,6 +202,8 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::Destroy() {
|
|
|
| ReleaseTextures();
|
|
|
| + glDeleteProgram(copy_to_image_shader_);
|
| + glDeleteProgram(copy_to_framebuffer_shader_);
|
| glDeleteProgram(process_and_apply_shader_);
|
| glDeleteProgram(edges_combine_shader_);
|
| glDeleteProgram(edges1_shader_);
|
| @@ -213,10 +224,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::
|
| if (!framebuffer)
|
| return;
|
|
|
| - glDisable(GL_SCISSOR_TEST);
|
| - glDisable(GL_STENCIL_TEST);
|
| - glDisable(GL_CULL_FACE);
|
| - glDisable(GL_BLEND);
|
| + GLuint last_framebuffer = framebuffer->service_id();
|
|
|
| // Process each color attachment of the current draw framebuffer.
|
| uint32_t max_draw_buffers = decoder->GetContextGroup()->max_draw_buffers();
|
| @@ -241,20 +249,39 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::
|
| // Process using a GL_RGBA8 copy if this is not the case.
|
| bool do_copy = internal_format != GL_RGBA8;
|
|
|
| + // Copy source_texture to rgba8_texture_
|
| + if (do_copy) {
|
| + CopyTexture(source_texture, rgba8_texture_, false);
|
| + }
|
| +
|
| // CMAA Effect
|
| + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, last_framebuffer);
|
| if (do_copy) {
|
| - ApplyCMAAEffectTexture(source_texture, rgba8_texture_, do_copy);
|
| + ApplyCMAAEffectTexture(rgba8_texture_, rgba8_texture_);
|
| } else {
|
| - ApplyCMAAEffectTexture(source_texture, source_texture, do_copy);
|
| + ApplyCMAAEffectTexture(source_texture, source_texture);
|
| }
|
|
|
| // Copy rgba8_texture_ to source_texture
|
| if (do_copy) {
|
| - // copy_framebuffer_ always binds rgba8_texture_
|
| + // Move source_texture to the first color attachment of the copy fbo.
|
| + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, last_framebuffer);
|
| + glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
|
| + GL_TEXTURE_2D, 0, 0);
|
| + glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_);
|
| + glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
| + GL_TEXTURE_2D, source_texture, 0);
|
| +
|
| + CopyTexture(rgba8_texture_, source_texture, true);
|
| +
|
| + // Restore color attachments
|
| glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_);
|
| - CopyTexture(source_texture);
|
| + glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
| + GL_TEXTURE_2D, rgba8_texture_, 0);
|
| + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, last_framebuffer);
|
| + glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
|
| + GL_TEXTURE_2D, source_texture, 0);
|
| }
|
| - decoder->RestoreTextureState(source_texture);
|
| }
|
| }
|
|
|
| @@ -271,8 +298,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::
|
|
|
| void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture(
|
| GLuint source_texture,
|
| - GLuint dest_texture,
|
| - bool do_copy) {
|
| + GLuint dest_texture) {
|
| frame_id_++;
|
|
|
| GLuint edge_texture_a;
|
| @@ -318,7 +344,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture(
|
| // Outputs
|
| // gl_FragDepth mini4_edge_depth_texture_ fbo.depth
|
| // out uvec4 outEdges mini4_edge_texture_ fbo.col
|
| - // image2D g_resultRGBATextureSlot1 working_color_texture_ image1
|
| + // image2D g_resultTextureFlt4Slot1 working_color_texture_ image1
|
| GLenum edge_format = supports_r8_image_ ? GL_R8 : GL_R32F;
|
|
|
| {
|
| @@ -329,18 +355,10 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture(
|
| glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
| if (!is_gles31_compatible_) {
|
| - glUniform1i(edges0_shader_result_rgba_texture_slot1_, 1);
|
| - glUniform1i(edges0_shader_target_texture_slot2_, 2);
|
| + glUniform1i(edges1_shader_result_texture_float4_slot1_, 1);
|
| }
|
| glBindImageTextureEXT(1, working_color_texture_, 0, GL_FALSE, 0,
|
| GL_WRITE_ONLY, GL_RGBA8);
|
| - if (do_copy) {
|
| - glUniform1i(2, GL_TRUE);
|
| - glBindImageTextureEXT(2, dest_texture, 0, GL_FALSE, 0, GL_WRITE_ONLY,
|
| - GL_RGBA8);
|
| - } else {
|
| - glUniform1i(2, GL_FALSE);
|
| - }
|
|
|
| glActiveTexture(GL_TEXTURE0);
|
| glBindTexture(GL_TEXTURE_2D, source_texture);
|
| @@ -357,7 +375,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture(
|
| // Inputs
|
| // g_src0Texture4Uint mini4_edge_texture_ tex1
|
| // Outputs
|
| - // image2D g_resultEdgeTexture edge_texture_b image0
|
| + // image2D g_resultTexture edge_texture_b image0
|
| {
|
| glUseProgram(edges1_shader_);
|
| glUniform2f(0, 1.0f / width_, 1.0f / height_);
|
| @@ -366,7 +384,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture(
|
| glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
|
|
| if (!is_gles31_compatible_) {
|
| - glUniform1i(edges1_shader_result_edge_texture_, 0);
|
| + glUniform1i(edges1_shader_result_texture_, 0);
|
| }
|
| glBindImageTextureEXT(0, edge_texture_b, 0, GL_FALSE, 0, GL_WRITE_ONLY,
|
| edge_format);
|
| @@ -390,7 +408,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture(
|
| // Inputs
|
| // g_src0TextureFlt edge_texture_b tex1 //ps
|
| // Outputs
|
| - // image2D g_resultEdgeTexture edge_texture_a image2
|
| + // image2D g_resultTextureSlot2 edge_texture_a image2
|
| // gl_FragDepth mini4_edge_texture_ fbo.depth
|
| {
|
| // Combine edges: each pixel will now contain info on all (top, right,
|
| @@ -403,9 +421,9 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture(
|
| glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
|
|
| if (!is_gles31_compatible_) {
|
| - glUniform1i(edges_combine_shader_result_edge_texture_, 0);
|
| + glUniform1i(edges_combine_shader_result_texture_slot2_, 2);
|
| }
|
| - glBindImageTextureEXT(0, edge_texture_a, 0, GL_FALSE, 0, GL_WRITE_ONLY,
|
| + glBindImageTextureEXT(2, edge_texture_a, 0, GL_FALSE, 0, GL_WRITE_ONLY,
|
| edge_format);
|
|
|
| glActiveTexture(GL_TEXTURE1);
|
| @@ -429,7 +447,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture(
|
| // g_src0TextureFlt edge_texture_a tex1 //ps
|
| // sampled
|
| // Outputs
|
| - // g_resultRGBATextureSlot1 dest_texture image1
|
| + // g_resultTextureFlt4Slot1 dest_texture image1
|
| // gl_FragDepth mini4_edge_texture_ fbo.depth
|
| {
|
| glUseProgram(process_and_apply_shader_);
|
| @@ -439,7 +457,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture(
|
| glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
|
|
| if (!is_gles31_compatible_) {
|
| - glUniform1i(process_and_apply_shader_result_rgba_texture_slot1_, 1);
|
| + glUniform1i(process_and_apply_shader_result_texture_float4_slot1_, 1);
|
| }
|
| glBindImageTextureEXT(1, dest_texture, 0, GL_FALSE, 0, GL_WRITE_ONLY,
|
| GL_RGBA8);
|
| @@ -477,9 +495,6 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::OnSize(GLint width,
|
| glGenTextures(1, &rgba8_texture_);
|
| glBindTexture(GL_TEXTURE_2D, rgba8_texture_);
|
| glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8, width, height);
|
| - glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_);
|
| - glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
| - rgba8_texture_, 0);
|
|
|
| // Edges texture - R8
|
| // OpenGLES has no single component 8/16-bit image support, so needs to be R32
|
| @@ -550,15 +565,32 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ReleaseTextures() {
|
| }
|
|
|
| void ApplyFramebufferAttachmentCMAAINTELResourceManager::CopyTexture(
|
| - GLint dest) {
|
| + GLint source,
|
| + GLint dest,
|
| + bool via_fbo) {
|
| + glViewport(0, 0, width_, height_);
|
| glActiveTexture(GL_TEXTURE0);
|
| - glBindTexture(GL_TEXTURE_2D, dest);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
| + glBindTexture(GL_TEXTURE_2D, source);
|
|
|
| - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width_, height_);
|
| + if (!via_fbo) {
|
| + glUseProgram(copy_to_image_shader_);
|
| + if (!is_gles31_compatible_) {
|
| + glUniform1i(copy_to_image_shader_outTexture_, 0);
|
| + }
|
| + glBindImageTextureEXT(0, dest, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA8);
|
| + } else {
|
| + glDisable(GL_DEPTH_TEST);
|
| + glDisable(GL_STENCIL_TEST);
|
| + glDisable(GL_CULL_FACE);
|
| + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
| + glDepthMask(GL_FALSE);
|
| + glDisable(GL_BLEND);
|
| + glUseProgram(copy_to_framebuffer_shader_);
|
| + }
|
| +
|
| + glDrawArrays(GL_TRIANGLES, 0, 3);
|
| + glUseProgram(0);
|
| + glBindTexture(GL_TEXTURE_2D, 0);
|
| }
|
|
|
| GLuint ApplyFramebufferAttachmentCMAAINTELResourceManager::CreateProgram(
|
| @@ -683,9 +715,6 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s1_[] =
|
| \n#ifndef EDGE_DETECT_THRESHOLD\n
|
| layout(location = 1) uniform float g_ColorThreshold;
|
| \n#endif\n
|
| - \n#ifdef DETECT_EDGES1\n
|
| - layout(location = 2) uniform int g_DoCopy;
|
| - \n#endif\n
|
|
|
| \n#ifdef SUPPORTS_USAMPLER2D\n
|
| \n#define USAMPLER usampler2D\n
|
| @@ -710,18 +739,18 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s1_[] =
|
| // bind to image stage 0/1/2
|
| \n#ifdef GL_ES\n
|
| layout(binding = 0, EDGE_READ_FORMAT) restrict writeonly uniform highp
|
| - image2D g_resultEdgeTexture;
|
| + image2D g_resultTexture;
|
| layout(binding = 1, rgba8) restrict writeonly uniform highp
|
| - image2D g_resultRGBATextureSlot1;
|
| - layout(binding = 2, rgba8) restrict writeonly uniform highp
|
| - image2D g_targetTextureSlot2;
|
| + image2D g_resultTextureFlt4Slot1;
|
| + layout(binding = 2, EDGE_READ_FORMAT) restrict writeonly uniform highp
|
| + image2D g_resultTextureSlot2;
|
| \n#else\n
|
| layout(EDGE_READ_FORMAT) restrict writeonly uniform highp
|
| - image2D g_resultEdgeTexture;
|
| + image2D g_resultTexture;
|
| layout(rgba8) restrict writeonly uniform highp
|
| - image2D g_resultRGBATextureSlot1;
|
| - layout(rgba8) restrict writeonly uniform highp
|
| - image2D g_targetTextureSlot2;
|
| + image2D g_resultTextureFlt4Slot1;
|
| + layout(EDGE_READ_FORMAT) restrict writeonly uniform highp
|
| + image2D g_resultTextureSlot2;
|
| \n#endif\n
|
|
|
| // Constants
|
| @@ -980,7 +1009,7 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s1_[] =
|
| float(pixelPos.y) + 0.5);
|
|
|
| \n#ifdef DEBUG_OUTPUT_AAINFO\n
|
| - imageStore(g_resultEdgeTexture, pixelPos,
|
| + imageStore(g_resultTextureSlot2, pixelPos,
|
| PackBlurAAInfo(pixelPos, 1u));
|
| \n#endif\n
|
|
|
| @@ -997,7 +1026,7 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s1_[] =
|
| \n#ifdef IN_GAMMA_CORRECT_MODE\n
|
| color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb);
|
| \n#endif\n
|
| - imageStore(g_resultRGBATextureSlot1, pixelPos, color);
|
| + imageStore(g_resultTextureFlt4Slot1, pixelPos, color);
|
| }
|
| }
|
|
|
| @@ -1057,13 +1086,6 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s1_[] =
|
| vec4 pixel12 =
|
| texelFetchOffset(g_screenTexture, screenPosI.xy, 0, ivec2(1, 2));
|
|
|
| - if (g_DoCopy == 1) {
|
| - imageStore(g_targetTextureSlot2, screenPosI.xy + ivec2(0, 0), pixel00);
|
| - imageStore(g_targetTextureSlot2, screenPosI.xy + ivec2(1, 0), pixel10);
|
| - imageStore(g_targetTextureSlot2, screenPosI.xy + ivec2(0, 1), pixel01);
|
| - imageStore(g_targetTextureSlot2, screenPosI.xy + ivec2(1, 1), pixel11);
|
| - }
|
| -
|
| float storeFlagPixel00 = 0.0;
|
| float storeFlagPixel10 = 0.0;
|
| float storeFlagPixel20 = 0.0;
|
| @@ -1137,28 +1159,28 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s1_[] =
|
|
|
| if (gl_FragDepth != 0.0) {
|
| if (storeFlagPixel00 != 0.0)
|
| - imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(0, 0),
|
| + imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(0, 0),
|
| pixel00);
|
| if (storeFlagPixel10 != 0.0)
|
| - imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(1, 0),
|
| + imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(1, 0),
|
| pixel10);
|
| if (storeFlagPixel20 != 0.0)
|
| - imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(2, 0),
|
| + imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(2, 0),
|
| pixel20);
|
| if (storeFlagPixel01 != 0.0)
|
| - imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(0, 1),
|
| + imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(0, 1),
|
| pixel01);
|
| if (storeFlagPixel02 != 0.0)
|
| - imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(0, 2),
|
| + imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(0, 2),
|
| pixel02);
|
| if (storeFlagPixel11 != 0.0)
|
| - imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(1, 1),
|
| + imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(1, 1),
|
| pixel11);
|
| if (storeFlagPixel21 != 0.0)
|
| - imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(2, 1),
|
| + imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(2, 1),
|
| pixel21);
|
| if (storeFlagPixel12 != 0.0)
|
| - imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(1, 2),
|
| + imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(1, 2),
|
| pixel12);
|
| }
|
| outEdges = STORE_UVEC4(outputEdges);
|
| @@ -1263,7 +1285,7 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] =
|
| CollectEdges(2, 2, edges, packedVals);
|
| uint pe = PackEdge(PruneNonDominantEdges(edges));
|
| if (pe != 0u) {
|
| - imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(0, 0),
|
| + imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(0, 0),
|
| vec4(float(0x80u | pe) / 255.0, 0, 0, 0));
|
| }
|
| }
|
| @@ -1292,7 +1314,7 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] =
|
| // Note: texelFetch() on out of range gives an undefined value.
|
| uint pe = PackEdge(dominant_edges * uvec4(notTopRight.x, 1, 1, 1));
|
| if (pe != 0u) {
|
| - imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(1, 0),
|
| + imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(1, 0),
|
| vec4(float(0x80u | pe) / 255.0, 0, 0, 0));
|
| }
|
| }
|
| @@ -1319,7 +1341,7 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] =
|
| uvec4 dominant_edges = PruneNonDominantEdges(edges);
|
| uint pe = PackEdge(dominant_edges * uvec4(1, notTopRight.y, 1, 1));
|
| if (pe != 0u) {
|
| - imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(0, 1),
|
| + imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(0, 1),
|
| vec4(float(0x80u | pe) / 255.0, 0, 0, 0));
|
| }
|
| }
|
| @@ -1329,7 +1351,7 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] =
|
| uvec4 dominant_edges = PruneNonDominantEdges(edges);
|
| uint pe = PackEdge(dominant_edges * uvec4(notTopRight, 1, 1));
|
| if (pe != 0u) {
|
| - imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(1, 1),
|
| + imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(1, 1),
|
| vec4(float(0x80u | pe) / 255.0, 0, 0, 0));
|
| }
|
| }
|
| @@ -1387,13 +1409,13 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] =
|
| pixelsC | ((pixelsL & 0x01u) << 2u) | ((pixelsU & 0x02u) << 2u);
|
| vec4 outEdge4Flt = vec4(outEdge4) / 255.0;
|
|
|
| - imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(0, 0),
|
| + imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(0, 0),
|
| outEdge4Flt.xxxx);
|
| - imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(1, 0),
|
| + imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(1, 0),
|
| outEdge4Flt.yyyy);
|
| - imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(0, 1),
|
| + imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(0, 1),
|
| outEdge4Flt.zzzz);
|
| - imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(1, 1),
|
| + imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(1, 1),
|
| outEdge4Flt.wwww);
|
|
|
| // uvec4 numberOfEdges4 = uvec4(bitCount(outEdge4));
|
| @@ -1647,10 +1669,10 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] =
|
| \n#endif\n
|
|
|
| \n#ifdef DEBUG_OUTPUT_AAINFO\n
|
| - imageStore(g_resultEdgeTexture, screenPosI.xy,
|
| + imageStore(g_resultTextureSlot2, screenPosI.xy,
|
| PackBlurAAInfo(screenPosI.xy, numberOfEdges));
|
| \n#endif\n
|
| - imageStore(g_resultRGBATextureSlot1, screenPosI.xy, color);
|
| + imageStore(g_resultTextureFlt4Slot1, screenPosI.xy, color);
|
|
|
| if (numberOfEdges == 2u) {
|
| uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)];
|
| @@ -1860,6 +1882,30 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] =
|
| \n#endif\n
|
| }
|
| );
|
| +
|
| +const char
|
| + ApplyFramebufferAttachmentCMAAINTELResourceManager::copy_frag_str_[] =
|
| + SHADER(
|
| + precision highp float;
|
| + layout(binding = 0) uniform highp sampler2D inTexture;
|
| + layout(location = 0) out vec4 outColor;
|
| + \n#ifdef GL_ES\n
|
| + layout(binding = 0, rgba8) restrict writeonly uniform highp
|
| + image2D outTexture;
|
| + \n#else\n
|
| + layout(rgba8) restrict writeonly uniform highp image2D outTexture;
|
| + \n#endif\n
|
| +
|
| + void main() {
|
| + ivec2 screenPosI = ivec2( gl_FragCoord.xy );
|
| + vec4 pixel = texelFetch(inTexture, screenPosI, 0);
|
| + \n#ifdef OUT_FBO\n
|
| + outColor = pixel;
|
| + \n#else\n
|
| + imageStore(outTexture, screenPosI, pixel);
|
| + \n#endif\n
|
| + }
|
| + );
|
| /* clang-format on */
|
|
|
| } // namespace gles2
|
|
|