1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 // Fence.h: Defines the Fence class, which supports the GL_NV_fence extension.
16 
17 #ifndef LIBGLESV2_FENCE_H_
18 #define LIBGLESV2_FENCE_H_
19 
20 #include "common/Object.hpp"
21 #include <GLES2/gl2.h>
22 
23 namespace es2
24 {
25 
26 class Fence
27 {
28 public:
29 	Fence();
30 	virtual ~Fence();
31 
32 	GLboolean isFence();
33 	void setFence(GLenum condition);
34 	GLboolean testFence();
35 	void finishFence();
36 	void getFenceiv(GLenum pname, GLint *params);
37 
38 private:
39 	bool mQuery;
40 	GLenum mCondition;
41 	GLboolean mStatus;
42 };
43 
44 class FenceSync : public gl::NamedObject
45 {
46 public:
47 	FenceSync(GLuint name, GLenum condition, GLbitfield flags);
48 	virtual ~FenceSync();
49 
50 	GLenum clientWait(GLbitfield flags, GLuint64 timeout);
51 	void serverWait(GLbitfield flags, GLuint64 timeout);
52 	void getSynciv(GLenum pname, GLsizei *length, GLint *values);
53 
getCondition()54 	GLenum getCondition() const { return mCondition; }
getFlags()55 	GLbitfield getFlags() const { return mFlags; }
56 
57 private:
58 	GLenum mCondition;
59 	GLbitfield mFlags;
60 };
61 
62 }
63 
64 #endif   // LIBGLESV2_FENCE_H_
65