OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 | 150 |
151 GR_STATIC_ASSERT(14 == kS2C_GrBlendCoeff); | 151 GR_STATIC_ASSERT(14 == kS2C_GrBlendCoeff); |
152 GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff); | 152 GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff); |
153 GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff); | 153 GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff); |
154 GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff); | 154 GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff); |
155 | 155 |
156 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope | 156 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope |
157 GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); | 157 GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); |
158 } | 158 } |
159 | 159 |
160 // Sample locations that are colocated at pixel center | |
Mark Kilgard
2015/09/21 17:03:50
for the sake of documentation, I recommend 2*16 in
| |
161 static const GrGLfloat gCenteredSampleLocations[32] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, | |
162 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, | |
163 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, | |
164 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 }; | |
165 | |
160 /////////////////////////////////////////////////////////////////////////////// | 166 /////////////////////////////////////////////////////////////////////////////// |
161 | 167 |
162 // Used in the map of pixel configs to stencil format indices. This value is use d to | 168 // Used in the map of pixel configs to stencil format indices. This value is use d to |
163 // indicate that a stencil format has not yet been set for the given config. | 169 // indicate that a stencil format has not yet been set for the given config. |
164 static const int kUnknownStencilIndex = -1; | 170 static const int kUnknownStencilIndex = -1; |
165 // This value is used as the stencil index when no stencil configs are supported with the | 171 // This value is used as the stencil index when no stencil configs are supported with the |
166 // given pixel config. | 172 // given pixel config. |
167 static const int kUnsupportedStencilIndex = -2; | 173 static const int kUnsupportedStencilIndex = -2; |
168 | 174 |
169 /////////////////////////////////////////////////////////////////////////////// | 175 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1893 if (!flipY) { | 1899 if (!flipY) { |
1894 dst += rowBytes; | 1900 dst += rowBytes; |
1895 } else { | 1901 } else { |
1896 dst -= rowBytes; | 1902 dst -= rowBytes; |
1897 } | 1903 } |
1898 } | 1904 } |
1899 } | 1905 } |
1900 return true; | 1906 return true; |
1901 } | 1907 } |
1902 | 1908 |
1909 void GrGLGpu::setProgrammableSampleLocations(GrRenderTarget* rt, bool useSampleL ocations) { | |
1910 if (0 == rt->numRasterSamples()) | |
1911 return; | |
Chris Dalton
2015/09/22 08:35:24
Skia style uses braces for one line if's.
| |
1912 | |
1913 GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt->asRenderTarget ()); | |
1914 SkASSERT(0 != target->renderFBOID()); | |
1915 | |
1916 if (useSampleLocations == target->usesProgrammableSampleLocations()) | |
1917 return; | |
1918 | |
1919 if (GrGLRenderTarget::kProgrammable_SampleLocationsConfig != target->sampleL ocationsConfig()) { | |
1920 uint32_t rtID = target->getUniqueID(); | |
Mark Kilgard
2015/09/21 17:03:51
is it worth considering using glNamedFramebufferPa
| |
1921 if (fHWBoundRenderTargetUniqueID != rtID) { | |
1922 fStats.incRenderTargetBinds(); | |
1923 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | |
1924 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | |
1925 } | |
1926 | |
1927 GL_CALL(FramebufferParameteri(GR_GL_FRAMEBUFFER, GR_GL_FRAMEBUFFER_PROGR AMMABLE_SAMPLE_LOCATIONS, true)); | |
1928 target->setSampleLocationsConfig(GrGLRenderTarget::kProgrammable_SampleL ocationsConfig); | |
1929 | |
1930 float defaultSampleLocations[32]; | |
Mark Kilgard
2015/09/21 17:03:50
worth adding
assert(rt->numRasterSamples()*2 == S
| |
1931 for (int i = 0; i < rt->numRasterSamples(); i++) { | |
1932 GL_CALL(GetMultisamplefv(GR_GL_SAMPLE_LOCATION_NV, i, &defaultSample Locations[i*2])); | |
Mark Kilgard
2015/09/21 17:03:51
calling a glGetMultisamplefv here many times (as m
| |
1933 } | |
1934 target->setDefaultSampleLocations(rt->numRasterSamples(), defaultSampleL ocations); | |
Chris Dalton
2015/09/22 08:35:24
We ought to set this up so it only queries the def
| |
1935 } | |
1936 | |
1937 GL_CALL(NamedFramebufferSampleLocationsfv(target->renderFBOID(), 0, rt->numR asterSamples(), | |
1938 useSampleLocations ? gCenteredSamp leLocations | |
1939 : target->defau ltSampleLocations())); | |
1940 target->flagAsUsingProgrammableSampleLocations(useSampleLocations); | |
1941 } | |
1942 | |
1903 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) { | 1943 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) { |
1904 | 1944 |
1905 SkASSERT(target); | 1945 SkASSERT(target); |
1906 | 1946 |
1907 uint32_t rtID = target->getUniqueID(); | 1947 uint32_t rtID = target->getUniqueID(); |
1908 if (fHWBoundRenderTargetUniqueID != rtID) { | 1948 if (fHWBoundRenderTargetUniqueID != rtID) { |
1909 fStats.incRenderTargetBinds(); | 1949 fStats.incRenderTargetBinds(); |
1910 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 1950 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
1911 #ifdef SK_DEBUG | 1951 #ifdef SK_DEBUG |
1912 // don't do this check in Chromium -- this is causing | 1952 // don't do this check in Chromium -- this is causing |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2143 GrStencilSettings::kFront_Face); | 2183 GrStencilSettings::kFront_Face); |
2144 } | 2184 } |
2145 } | 2185 } |
2146 fHWStencilSettings = stencilSettings; | 2186 fHWStencilSettings = stencilSettings; |
2147 } | 2187 } |
2148 } | 2188 } |
2149 | 2189 |
2150 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2190 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { |
2151 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); | 2191 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
2152 | 2192 |
2193 if (rt->hasMixedSamples()) { | |
2194 if (useHWAA) { | |
2195 setProgrammableSampleLocations(rt, false); | |
2196 } else { | |
2197 setProgrammableSampleLocations(rt, true); | |
2198 } | |
2199 useHWAA = true; | |
Chris Dalton
2015/09/22 08:35:24
I still think it's desirable to disable multisampl
| |
2200 } | |
2201 | |
2153 if (this->glCaps().multisampleDisableSupport()) { | 2202 if (this->glCaps().multisampleDisableSupport()) { |
2154 if (useHWAA) { | 2203 if (useHWAA) { |
2155 if (kYes_TriState != fMSAAEnabled) { | 2204 if (kYes_TriState != fMSAAEnabled) { |
2156 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2205 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
2157 fMSAAEnabled = kYes_TriState; | 2206 fMSAAEnabled = kYes_TriState; |
2158 } | 2207 } |
2159 } else { | 2208 } else { |
2160 if (kNo_TriState != fMSAAEnabled) { | 2209 if (kNo_TriState != fMSAAEnabled) { |
2161 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2210 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
2162 fMSAAEnabled = kNo_TriState; | 2211 fMSAAEnabled = kNo_TriState; |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3160 this->setVertexArrayID(gpu, 0); | 3209 this->setVertexArrayID(gpu, 0); |
3161 } | 3210 } |
3162 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3211 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3163 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3212 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3164 fDefaultVertexArrayAttribState.resize(attrCount); | 3213 fDefaultVertexArrayAttribState.resize(attrCount); |
3165 } | 3214 } |
3166 attribState = &fDefaultVertexArrayAttribState; | 3215 attribState = &fDefaultVertexArrayAttribState; |
3167 } | 3216 } |
3168 return attribState; | 3217 return attribState; |
3169 } | 3218 } |
OLD | NEW |