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 8db5f430d9e6a1f1e7f2fe3cfd4f15c1ab6bc4b1..58051d49b45657ef86d52514034054608498e89f 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 |
@@ -41,11 +41,11 @@ ApplyFramebufferAttachmentCMAAINTELResourceManager:: |
edges1_texture_(0), |
mini4_edge_texture_(0), |
mini4_edge_depth_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) {} |
+ 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) {} |
ApplyFramebufferAttachmentCMAAINTELResourceManager:: |
~ApplyFramebufferAttachmentCMAAINTELResourceManager() { |
@@ -173,16 +173,16 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::Initialize( |
process_and_apply_shader_ = |
CreateProgram(blur.str().c_str(), vert_str_, cmaa_frag_c_str); |
- 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"); |
+ 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"); |
initialized_ = true; |
} |
@@ -241,26 +241,17 @@ 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) { |
- glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_); |
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
- GL_TEXTURE_2D, source_texture, 0); |
- CopyTexture(rgba8_texture_); |
- } |
- |
// CMAA Effect |
if (do_copy) { |
- ApplyCMAAEffectTexture(rgba8_texture_, rgba8_texture_); |
+ ApplyCMAAEffectTexture(source_texture, rgba8_texture_, do_copy); |
} else { |
- ApplyCMAAEffectTexture(source_texture, source_texture); |
+ ApplyCMAAEffectTexture(source_texture, source_texture, do_copy); |
} |
// Copy rgba8_texture_ to source_texture |
if (do_copy) { |
+ // copy_framebuffer_ always binds rgba8_texture_ |
glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_); |
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
- GL_TEXTURE_2D, rgba8_texture_, 0); |
CopyTexture(source_texture); |
} |
decoder->RestoreTextureState(source_texture); |
@@ -280,7 +271,8 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager:: |
void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( |
GLuint source_texture, |
- GLuint dest_texture) { |
+ GLuint dest_texture, |
+ bool do_copy) { |
frame_id_++; |
GLuint edge_texture_a; |
@@ -326,7 +318,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( |
// Outputs |
// gl_FragDepth mini4_edge_depth_texture_ fbo.depth |
// out uvec4 outEdges mini4_edge_texture_ fbo.col |
- // image2D g_resultTextureFlt4Slot1 working_color_texture_ image1 |
+ // image2D g_resultRGBATextureSlot1 working_color_texture_ image1 |
GLenum edge_format = supports_r8_image_ ? GL_R8 : GL_R32F; |
{ |
@@ -337,10 +329,18 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( |
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
if (!is_gles31_compatible_) { |
- glUniform1i(edges1_shader_result_texture_float4_slot1_, 1); |
+ glUniform1i(edges0_shader_result_rgba_texture_slot1_, 1); |
+ glUniform1i(edges0_shader_target_texture_slot2_, 2); |
} |
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 +357,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( |
// Inputs |
// g_src0Texture4Uint mini4_edge_texture_ tex1 |
// Outputs |
- // image2D g_resultTexture edge_texture_b image0 |
+ // image2D g_resultEdgeTexture edge_texture_b image0 |
{ |
glUseProgram(edges1_shader_); |
glUniform2f(0, 1.0f / width_, 1.0f / height_); |
@@ -366,7 +366,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( |
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
if (!is_gles31_compatible_) { |
- glUniform1i(edges1_shader_result_texture_, 0); |
+ glUniform1i(edges1_shader_result_edge_texture_, 0); |
} |
glBindImageTextureEXT(0, edge_texture_b, 0, GL_FALSE, 0, GL_WRITE_ONLY, |
edge_format); |
@@ -390,7 +390,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( |
// Inputs |
// g_src0TextureFlt edge_texture_b tex1 //ps |
// Outputs |
- // image2D g_resultTextureSlot2 edge_texture_a image2 |
+ // image2D g_resultEdgeTexture 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 +403,9 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( |
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
if (!is_gles31_compatible_) { |
- glUniform1i(edges_combine_shader_result_texture_slot2_, 2); |
+ glUniform1i(edges_combine_shader_result_edge_texture_, 0); |
} |
- glBindImageTextureEXT(2, edge_texture_a, 0, GL_FALSE, 0, GL_WRITE_ONLY, |
+ glBindImageTextureEXT(0, edge_texture_a, 0, GL_FALSE, 0, GL_WRITE_ONLY, |
edge_format); |
glActiveTexture(GL_TEXTURE1); |
@@ -429,7 +429,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( |
// g_src0TextureFlt edge_texture_a tex1 //ps |
// sampled |
// Outputs |
- // g_resultTextureFlt4Slot1 dest_texture image1 |
+ // g_resultRGBATextureSlot1 dest_texture image1 |
// gl_FragDepth mini4_edge_texture_ fbo.depth |
{ |
glUseProgram(process_and_apply_shader_); |
@@ -439,7 +439,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ApplyCMAAEffectTexture( |
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
if (!is_gles31_compatible_) { |
- glUniform1i(process_and_apply_shader_result_texture_float4_slot1_, 1); |
+ glUniform1i(process_and_apply_shader_result_rgba_texture_slot1_, 1); |
} |
glBindImageTextureEXT(1, dest_texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, |
GL_RGBA8); |
@@ -477,6 +477,9 @@ 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 |
@@ -680,6 +683,9 @@ 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 |
@@ -704,18 +710,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_resultTexture; |
+ image2D g_resultEdgeTexture; |
layout(binding = 1, rgba8) restrict writeonly uniform highp |
- image2D g_resultTextureFlt4Slot1; |
- layout(binding = 2, EDGE_READ_FORMAT) restrict writeonly uniform highp |
- image2D g_resultTextureSlot2; |
+ image2D g_resultRGBATextureSlot1; |
+ layout(binding = 2, rgba8) restrict writeonly uniform highp |
+ image2D g_targetTextureSlot2; |
\n#else\n |
layout(EDGE_READ_FORMAT) restrict writeonly uniform highp |
- image2D g_resultTexture; |
+ image2D g_resultEdgeTexture; |
layout(rgba8) restrict writeonly uniform highp |
- image2D g_resultTextureFlt4Slot1; |
- layout(EDGE_READ_FORMAT) restrict writeonly uniform highp |
- image2D g_resultTextureSlot2; |
+ image2D g_resultRGBATextureSlot1; |
+ layout(rgba8) restrict writeonly uniform highp |
+ image2D g_targetTextureSlot2; |
\n#endif\n |
// Constants |
@@ -974,7 +980,7 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s1_[] = |
float(pixelPos.y) + 0.5); |
\n#ifdef DEBUG_OUTPUT_AAINFO\n |
- imageStore(g_resultTextureSlot2, pixelPos, |
+ imageStore(g_resultEdgeTexture, pixelPos, |
PackBlurAAInfo(pixelPos, 1u)); |
\n#endif\n |
@@ -991,7 +997,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_resultTextureFlt4Slot1, pixelPos, color); |
+ imageStore(g_resultRGBATextureSlot1, pixelPos, color); |
} |
} |
@@ -1051,6 +1057,13 @@ 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; |
@@ -1124,28 +1137,28 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s1_[] = |
if (gl_FragDepth != 0.0) { |
if (storeFlagPixel00 != 0.0) |
- imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(0, 0), |
+ imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(0, 0), |
pixel00); |
if (storeFlagPixel10 != 0.0) |
- imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(1, 0), |
+ imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(1, 0), |
pixel10); |
if (storeFlagPixel20 != 0.0) |
- imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(2, 0), |
+ imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(2, 0), |
pixel20); |
if (storeFlagPixel01 != 0.0) |
- imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(0, 1), |
+ imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(0, 1), |
pixel01); |
if (storeFlagPixel02 != 0.0) |
- imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(0, 2), |
+ imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(0, 2), |
pixel02); |
if (storeFlagPixel11 != 0.0) |
- imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(1, 1), |
+ imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(1, 1), |
pixel11); |
if (storeFlagPixel21 != 0.0) |
- imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(2, 1), |
+ imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(2, 1), |
pixel21); |
if (storeFlagPixel12 != 0.0) |
- imageStore(g_resultTextureFlt4Slot1, screenPosI.xy + ivec2(1, 2), |
+ imageStore(g_resultRGBATextureSlot1, screenPosI.xy + ivec2(1, 2), |
pixel12); |
} |
outEdges = STORE_UVEC4(outputEdges); |
@@ -1250,7 +1263,7 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] = |
CollectEdges(2, 2, edges, packedVals); |
uint pe = PackEdge(PruneNonDominantEdges(edges)); |
if (pe != 0u) { |
- imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(0, 0), |
+ imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(0, 0), |
vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); |
} |
} |
@@ -1279,7 +1292,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_resultTexture, 2 * screenPosI.xy + ivec2(1, 0), |
+ imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(1, 0), |
vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); |
} |
} |
@@ -1306,7 +1319,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_resultTexture, 2 * screenPosI.xy + ivec2(0, 1), |
+ imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(0, 1), |
vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); |
} |
} |
@@ -1316,7 +1329,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_resultTexture, 2 * screenPosI.xy + ivec2(1, 1), |
+ imageStore(g_resultEdgeTexture, 2 * screenPosI.xy + ivec2(1, 1), |
vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); |
} |
} |
@@ -1374,13 +1387,13 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] = |
pixelsC | ((pixelsL & 0x01u) << 2u) | ((pixelsU & 0x02u) << 2u); |
vec4 outEdge4Flt = vec4(outEdge4) / 255.0; |
- imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(0, 0), |
+ imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(0, 0), |
outEdge4Flt.xxxx); |
- imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(1, 0), |
+ imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(1, 0), |
outEdge4Flt.yyyy); |
- imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(0, 1), |
+ imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(0, 1), |
outEdge4Flt.zzzz); |
- imageStore(g_resultTextureSlot2, screenPosIBase.xy + ivec2(1, 1), |
+ imageStore(g_resultEdgeTexture, screenPosIBase.xy + ivec2(1, 1), |
outEdge4Flt.wwww); |
// uvec4 numberOfEdges4 = uvec4(bitCount(outEdge4)); |
@@ -1634,10 +1647,10 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] = |
\n#endif\n |
\n#ifdef DEBUG_OUTPUT_AAINFO\n |
- imageStore(g_resultTextureSlot2, screenPosI.xy, |
+ imageStore(g_resultEdgeTexture, screenPosI.xy, |
PackBlurAAInfo(screenPosI.xy, numberOfEdges)); |
\n#endif\n |
- imageStore(g_resultTextureFlt4Slot1, screenPosI.xy, color); |
+ imageStore(g_resultRGBATextureSlot1, screenPosI.xy, color); |
if (numberOfEdges == 2u) { |
uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)]; |