2626#include " pxr/imaging/hgiGL/scopedStateHolder.h"
2727#include " pxr/imaging/hgiGL/conversions.h"
2828#include " pxr/imaging/hgiGL/diagnostic.h"
29+ #include " pxr/imaging/hgiGL/hgi.h"
2930
3031#include " pxr/base/trace/trace.h"
3132#include " pxr/base/tf/diagnostic.h"
3233#include " pxr/base/tf/iterator.h"
3334
3435PXR_NAMESPACE_OPEN_SCOPE
3536
36- HgiGL_ScopedStateHolder::HgiGL_ScopedStateHolder ()
37- : _restoreRenderBuffer(0 )
37+ HgiGL_ScopedStateHolder::HgiGL_ScopedStateHolder (
38+ HgiCapabilities const & capabilities)
39+ : _coreProfile(capabilities.GetCoreProfile())
40+ , _restoreRenderBuffer(0 )
3841 , _restoreVao(0 )
3942 , _restoreDepthTest(false )
4043 , _restoreDepthWriteMask(false )
@@ -115,7 +118,9 @@ HgiGL_ScopedStateHolder::HgiGL_ScopedStateHolder()
115118 glGetBooleanv (
116119 GL_SAMPLE_ALPHA_TO_ONE,
117120 (GLboolean*)&_restoreSampleAlphaToOne);
118- glGetFloatv (GL_LINE_WIDTH, &_lineWidth);
121+ if (!_coreProfile) {
122+ glGetFloatv (GL_LINE_WIDTH, &_lineWidth);
123+ }
119124 glGetBooleanv (GL_CULL_FACE, (GLboolean*)&_cullFace);
120125 glGetIntegerv (GL_CULL_FACE_MODE, &_cullMode);
121126 glGetIntegerv (GL_FRONT_FACE, &_frontFace);
@@ -139,7 +144,9 @@ HgiGL_ScopedStateHolder::HgiGL_ScopedStateHolder()
139144 }
140145
141146 glGetBooleanv (GL_MULTISAMPLE, (GLboolean*)&_restoreMultiSample);
142- glGetBooleanv (GL_POINT_SMOOTH, (GLboolean*)&_restorePointSmooth);
147+ if (!_coreProfile) {
148+ glGetBooleanv (GL_POINT_SMOOTH, (GLboolean*)&_restorePointSmooth);
149+ }
143150
144151 HGIGL_POST_PENDING_GL_ERRORS ();
145152 #if defined(GL_KHR_debug)
@@ -235,7 +242,9 @@ HgiGL_ScopedStateHolder::~HgiGL_ScopedStateHolder()
235242 _restoreViewport[2 ], _restoreViewport[3 ]);
236243 glBindVertexArray (_restoreVao);
237244 glBindRenderbuffer (GL_RENDERBUFFER, _restoreRenderBuffer);
238- glLineWidth (_lineWidth);
245+ if (!_coreProfile) {
246+ glLineWidth (_lineWidth);
247+ }
239248 if (_cullFace) {
240249 glEnable (GL_CULL_FACE);
241250 } else {
@@ -285,10 +294,12 @@ HgiGL_ScopedStateHolder::~HgiGL_ScopedStateHolder()
285294 glDisable (GL_MULTISAMPLE);
286295 }
287296
288- if (_restorePointSmooth) {
289- glEnable (GL_POINT_SMOOTH);
290- } else {
291- glDisable (GL_POINT_SMOOTH);
297+ if (!_coreProfile) {
298+ if (_restorePointSmooth) {
299+ glEnable (GL_POINT_SMOOTH);
300+ } else {
301+ glDisable (GL_POINT_SMOOTH);
302+ }
292303 }
293304
294305 static const GLuint samplers[8 ] = {0 };
0 commit comments