gpu: bypass TLS when making gl calls on the gpu service
The GLApi is kept as a pointer on the TLS, but it uniquely corresponds
to a context, so the decoders can cache the pointer to avoid a TLS
lookup.
This CL replaces all GL calls in the passthrough decoder, and a large
portion (but not all) in the validating decoder to explicitly use the
cached GLApi. Gives about 5-10% improvement on DecoderPerfTest when
stubbing out GL (1-2%).
Bug: 776876
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ia305fd511434d02d36bf86c80e40ea737b2519d5
Reviewed-on: https://chromium-review.googlesource.com/729641
Commit-Queue: Antoine Labour <[email protected]>
Reviewed-by: Geoff Lang <[email protected]>
Reviewed-by: Zhenyao Mo <[email protected]>
Reviewed-by: Victor Miura <[email protected]>
Cr-Commit-Position: refs/heads/master@{#511303}
diff --git a/gpu/command_buffer/service/context_state.h b/gpu/command_buffer/service/context_state.h
index 676f1b8..3a817ee 100644
--- a/gpu/command_buffer/service/context_state.h
+++ b/gpu/command_buffer/service/context_state.h
@@ -198,6 +198,9 @@
Logger* logger);
~ContextState();
+ void set_api(gl::GLApi* api) { api_ = api; }
+ gl::GLApi* api() const { return api_; }
+
void Initialize();
void SetLineWidthBounds(GLfloat min, GLfloat max);
@@ -251,14 +254,14 @@
cached_color_mask_green = green;
cached_color_mask_blue = blue;
cached_color_mask_alpha = alpha;
- glColorMask(red, green, blue, alpha);
+ api()->glColorMaskFn(red, green, blue, alpha);
}
inline void SetDeviceDepthMask(GLboolean mask) {
if (cached_depth_mask == mask && !ignore_cached_state)
return;
cached_depth_mask = mask;
- glDepthMask(mask);
+ api()->glDepthMaskFn(mask);
}
inline void SetDeviceStencilMaskSeparate(GLenum op, GLuint mask) {
@@ -274,7 +277,7 @@
NOTREACHED();
return;
}
- glStencilMaskSeparate(op, mask);
+ api()->glStencilMaskSeparateFn(op, mask);
}
ErrorState* GetErrorState();
@@ -394,6 +397,7 @@
GLfloat line_width_min_ = 0.0f;
GLfloat line_width_max_ = 1.0f;
+ gl::GLApi* api_ = nullptr;
FeatureInfo* feature_info_;
std::unique_ptr<ErrorState> error_state_;
};