本文整理汇总了Python中pyopencl.enqueue_release_gl_objects函数的典型用法代码示例。如果您正苦于以下问题:Python enqueue_release_gl_objects函数的具体用法?Python enqueue_release_gl_objects怎么用?Python enqueue_release_gl_objects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enqueue_release_gl_objects函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: execute
def execute(self, sub_intervals):
cl.enqueue_acquire_gl_objects(self.queue, self.gl_objects)
global_size = (self.num,)
local_size = None
# set up the Kernel argument list
w = numpy.int32(640)
h = numpy.int32(480)
kernelargs = (self.pos_cl,
self.col_cl,
self.depth_cl,
self.rgb_cl,
self.pt_cl,
self.ipt_cl,
w,
h)
for i in xrange(0, sub_intervals):
self.program.project(self.queue, global_size, local_size, *(kernelargs))
#pos = numpy.ndarray((self.imsize*4, 1), dtype=numpy.float32)
#cl.enqueue_read_buffer(self.queue, self.pos_cl, pos).wait()
#for i in xrange(0, 100, 4):
# print pos[i], pos[i+1], pos[i+2], pos[i+3]
cl.enqueue_release_gl_objects(self.queue, self.gl_objects)
self.queue.finish()
开发者ID:Dining-Engineers,项目名称:left-luggage-detection,代码行数:29,代码来源:kinect.py
示例2: initialize
def initialize():
plats = cl.get_platforms()
ctx_props = cl.context_properties
props = [(ctx_props.PLATFORM, plats[0]),
(ctx_props.GL_CONTEXT_KHR, platform.GetCurrentContext())]
import sys
if sys.platform == "linux2":
props.append(
(ctx_props.GLX_DISPLAY_KHR,
GLX.glXGetCurrentDisplay()))
elif sys.platform == "win32":
props.append(
(ctx_props.WGL_HDC_KHR,
WGL.wglGetCurrentDC()))
ctx = cl.Context(properties=props)
glClearColor(1, 1, 1, 1)
glColor(0, 0, 1)
vbo = glGenBuffers(1)
glBindBuffer(GL_ARRAY_BUFFER, vbo)
rawGlBufferData(GL_ARRAY_BUFFER, n_vertices * 2 * 4, None, GL_STATIC_DRAW)
glEnableClientState(GL_VERTEX_ARRAY)
glVertexPointer(2, GL_FLOAT, 0, None)
coords_dev = cl.GLBuffer(ctx, cl.mem_flags.READ_WRITE, int(vbo))
prog = cl.Program(ctx, src).build()
queue = cl.CommandQueue(ctx)
cl.enqueue_acquire_gl_objects(queue, [coords_dev])
prog.generate_sin(queue, (n_vertices,), None, coords_dev)
cl.enqueue_release_gl_objects(queue, [coords_dev])
queue.finish()
glFlush()
开发者ID:initcrash,项目名称:pyopencl,代码行数:33,代码来源:gl_interop_demo.py
示例3: step
def step(self, step_size):
if len(self.network_data.gl_objects) > 0:
cl.enqueue_acquire_gl_objects(self.queue, self.network_data.gl_objects)
global_size = (len(self.units),)
kernel_args = [
self.network_data.unit_state_index_buf,
self.network_data.unit_param_index_buf,
self.network_data.state_buf,
self.network_data.params_buf,
self.network_data.unit_weight_index_buf,
self.network_data.conn_index_buf,
self.network_data.num_connections_buf,
self.network_data.weights_buf,
self.network_data.next_state_buf,
np.float32(step_size),
self.network_data.color_buf,
]
self.program.unit_step(self.queue, global_size, None, *kernel_args)
self.time += step_size
self.network_data.update_state(self.cl_context, self.queue, self.time)
if len(self.network_data.gl_objects) > 0:
cl.enqueue_release_gl_objects(self.queue, self.network_data.gl_objects)
return self.network_data.state
开发者ID:mschachter,项目名称:nads,代码行数:30,代码来源:gpu.py
示例4: execute
def execute(self, subintervals):
dt = numpy.float32(self.dt)
dx = numpy.float32(self.dx)
ntracers = numpy.int32(self.ntracers)
num = numpy.int32(self.num)
choice = numpy.int32(self.params[0]) # choice)
k = numpy.float32(self.params[1]) # k)
ymin = numpy.float32(self.params[2]) # ymin)
ymax = numpy.float32(self.params[3]) # ymax)
"""
print "in execute, num", self.num
print "tracers", self.ntracers
print "choice", choice
print "k", k
print "ymin", ymin
print "ymax", ymax
print "dt", dt
print "dx", dx
"""
cl.enqueue_acquire_gl_objects(self.queue, self.gl_objects)
global_size = (self.num,)
local_size = None
kernelargs = (self.pos_cl, self.col_cl, self.pos_gen_cl, ntracers, choice, num, k, ymin, ymax, dt, dx)
for i in xrange(0, subintervals):
self.program.wave(self.queue, global_size, local_size, *(kernelargs))
cl.enqueue_release_gl_objects(self.queue, self.gl_objects)
self.queue.finish()
开发者ID:orangejulius,项目名称:adventures_in_opencl,代码行数:33,代码来源:wave.py
示例5: run
def run(self):
for ii in range(0,10):
for jj in range(0,10):
r = np.random.random([self.nsample,3])
r[:,0]=(r[:,0]+ii)*0.1
r[:,1]=(r[:,1]+jj)*0.1
self.X = np.zeros((self.nsample,4), dtype = np.float32)
self.X[:,0:3] = r
self.X[:,3] = 1.
self.I = np.zeros((self.nsample,4), dtype = np.float32)
self.I[:,0:3] = 1.
#self.I[:,3] = 0.
cl.enqueue_acquire_gl_objects(self.queue, [self.X_cl,self.I_cl])
cl.enqueue_copy(self.queue, self.X_cl, self.X)
cl.enqueue_copy(self.queue, self.I_cl, self.I)
self.program.Solve(self.queue, (self.nsample, self.na), None, self.A_cl, self.X_cl, self.I_cl, self.alpha)
cl.enqueue_release_gl_objects(self.queue, [self.X_cl,self.I_cl])
self.queue.finish()
self.draw()
self.scrnData = np.zeros((self.width,self.height), dtype = np.float32)
glReadPixels(0, 0, self.width, self.height, GL_ALPHA, GL_FLOAT, self.scrnData)
print np.max(self.scrnData)
scipy.misc.imsave('render.png', np.flipud(self.scrnData))
开发者ID:temik42,项目名称:render,代码行数:28,代码来源:render.py
示例6: buildCopImageDataTexture
def buildCopImageDataTexture(self):
if not cl.have_gl():
raise BaseException("No OpenGL interop !!!")
if self.node:
# bind texture from current compy node
cl_image_buffer = self.node.getCookedData()
glBindTexture(GL_TEXTURE_2D, self.node_gl_tex_id)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, self.node.xRes(), self.node.yRes(), 0, GL_RGB, GL_FLOAT, None)
logger.debug("Node size to display: %s %s" % (self.node.xRes(), self.node.yRes()))
node_gl_texture = cl.GLTexture(hou.openclContext(), cl.mem_flags.WRITE_ONLY, GL_TEXTURE_2D, 0, self.node_gl_tex_id, 2)
# Aquire OpenGL texture object
cl.enqueue_acquire_gl_objects(hou.openclQueue(), [node_gl_texture])
# copy OpenCL buffer to OpenGl texture
cl.enqueue_copy_image(hou.openclQueue(), cl_image_buffer, node_gl_texture, (0,0), (0,0), (self.node.xRes(), self.node.yRes()), wait_for=None)
# Release OpenGL texturte object
cl.enqueue_release_gl_objects(hou.openclQueue(), [node_gl_texture])
hou.openclQueue().finish()
glGenerateMipmap(GL_TEXTURE_2D) #Generate mipmaps now!!!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)
glBindTexture(GL_TEXTURE_2D, 0)
开发者ID:cinepost,项目名称:Copperfield_FX,代码行数:32,代码来源:composite_view_panel.py
示例7: execute
def execute(self, newp, t):
self.count += 1
if self.count >= self.ntracers-1:
self.count = 0
cl.enqueue_acquire_gl_objects(self.queue, self.gl_objects)
global_size = (self.ntracers,)
local_size = None
ca_kernelargs = (self.pos_cl,
self.col_cl,
self.time_cl,
self.props_cl,
np.int32(self.count),
np.float32(t),
newp,
self.params_cl
)
#print len(self.params)
self.prgs["cartist"].cartist(self.queue, global_size, local_size, *(ca_kernelargs))
cl.enqueue_release_gl_objects(self.queue, self.gl_objects)
self.queue.finish()
开发者ID:AytacKi,项目名称:adventures_in_opencl,代码行数:26,代码来源:cartist.py
示例8: render_advanced
def render_advanced(self):
"""
Render particles as a fluid surface (Simon Green's screen space rendering).
"""
self._create_thickness_map()
# render depth to depth target
with self.depth_target:
self.render_point_sprites(self.depth_shader)
# smooth depth texture
if self.smooth_depth:
cl.enqueue_acquire_gl_objects(self.queue, self.cl_gl_objects)
local_size = self.cl_local_size
for i in range(self.smoothing_iterations):
# alternate between writing to depth2_target and depth1_target
# (can't read from and write to the same texture at the same time).
args = (np.float32(self.smoothing_dt),
np.float32(self.smoothing_z_contrib),)
self.prg.curvatureFlow(self.queue, self.window_size, local_size, self.depth_cl, self.depth2_cl, *args).wait()
self.prg.curvatureFlow(self.queue, self.window_size, local_size, self.depth2_cl, self.depth_cl, *args).wait()
cl.enqueue_release_gl_objects(self.queue, self.cl_gl_objects)
if self.render_mean_curvature:
cl.enqueue_acquire_gl_objects(self.queue, self.cl_gl_objects)
self.prg.test(self.queue, self.window_size, self.cl_local_size, self.depth_cl, self.test_cl).wait()
cl.enqueue_release_gl_objects(self.queue, self.cl_gl_objects)
with self.tex_shader:
self.render_texture(self.test_target.texture)
return
# # testing
# cl.enqueue_acquire_gl_objects(self.queue, [self.depth_cl, self.test_cl])
# self.prg.test(self.queue, self.depth_target.size, self.cl_local_size, self.depth_cl, self.test_cl).wait()
# with self.tex_shader:
# self.render_texture(self.test_target.texture)
# #self.render_texture(self.depth_target.texture)
# cl.enqueue_release_gl_objects(self.queue, [self.depth_cl, self.test_cl])
# return
# use alpha blending
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
# bind thickness texture
glActiveTexture(GL_TEXTURE0+1)
glBindTexture(GL_TEXTURE_2D, self.thickness_target.texture)
with self.final_shader:
self.render_texture(self.depth_target.texture)
glActiveTexture(GL_TEXTURE0)
glDisable(GL_BLEND)
开发者ID:dancsi,项目名称:pysph,代码行数:55,代码来源:fluid_renderer.py
示例9: step
def step(self):
"""
Advance simulation.
"""
prg = self.prg
queue = self.queue
if self.gl_interop:
cl.enqueue_acquire_gl_objects(queue, self.cl_gl_objects)
## one simulation step consists of four steps:
## step 1) assign particles to cells in the uniform grid
## step 2) compute densities
## step 3) compute accelerations from forces
## step 4) move particles according to accelerations.
## for now, simple collision detection is done in the last step.
# step 1)
if self.use_grid:
self.assign_cells()
global_size = self.global_size
local_size = self.local_size
# if we use a grid based neighbour search, we need to pass
# some additional arguments.
grid_args = [self.grid_index_cl,
self.cell_start_cl,
self.cell_end_cl] if self.use_grid else []
# step 2)
prg.stepDensity(queue, global_size, local_size,
self.position_sorted_cl if self.use_grid and self.reorder else self.position_cl,
self.density_cl,
self.pressure_cl,
self.params_cl, *grid_args).wait()
# step 3)
prg.stepForces(queue, global_size, local_size,
self.position_sorted_cl if self.use_grid and self.reorder else self.position_cl,
self.velocity_sorted_cl if self.use_grid and self.reorder else self.velocity_cl,
self.acceleration_cl,
self.density_cl,
self.pressure_cl,
self.params_cl, *grid_args).wait()
# step 4)
prg.stepMove(queue, global_size, local_size,
self.position_cl,
self.velocity_cl,
self.acceleration_cl,
self.params_cl).wait()
if self.gl_interop:
cl.enqueue_release_gl_objects(queue, self.cl_gl_objects)
开发者ID:dancsi,项目名称:pysph,代码行数:55,代码来源:sph.py
示例10: execute
def execute(self, a=1.0):
if self.use_gl_texture_as_tmp:
cl.enqueue_acquire_gl_objects(self.queue, [self.cl_image, self.cl_lapl_mask, self.cl_tmp])
else:
cl.enqueue_acquire_gl_objects(self.queue, [self.cl_image, self.cl_lapl_mask])
self.program.laplace(self.queue, self.shape, None, self.cl_tmp, self.cl_image, self.cl_lapl_mask, float32(a))
self.program.laplace(self.queue, self.shape, None, self.cl_image, self.cl_tmp, self.cl_lapl_mask, float32(a))
if self.use_gl_texture_as_tmp:
cl.enqueue_release_gl_objects(self.queue, [self.cl_image, self.cl_lapl_mask, self.cl_tmp])
else:
cl.enqueue_release_gl_objects(self.queue, [self.cl_image, self.cl_lapl_mask])
开发者ID:adamlwgriffiths,项目名称:glitter,代码行数:11,代码来源:opencltexture.py
示例11: execute
def execute(self):
"""Execute the OpenCL kernel.
"""
# get secure access to GL-CL interop objects
cl.enqueue_acquire_gl_objects(self.queue, [self.glclbuf])
# arguments to the OpenCL kernel
kernelargs = (self.clbuf, self.glclbuf)
# execute the kernel
self.program.clkernel(self.queue, (self.count,), None, *kernelargs)
# release access to the GL-CL interop objects
cl.enqueue_release_gl_objects(self.queue, [self.glclbuf])
self.queue.finish()
开发者ID:kif,项目名称:codecamp-esrf-2014,代码行数:12,代码来源:demo.py
示例12: execute
def execute(self, sub_intervals):
cl.enqueue_acquire_gl_objects(self.queue, self.gl_objects)
global_size = (self.num,)
local_size = None
kernelargs = (self.pos_cl, self.col_cl, self.vel_cl, self.pos_gen_cl, self.vel_gen_cl, self.dt)
for i in xrange(0, sub_intervals):
self.program.part2(self.queue, global_size, local_size, *(kernelargs))
cl.enqueue_release_gl_objects(self.queue, self.gl_objects)
self.queue.finish()
开发者ID:phoenixstar7,项目名称:adventures_in_opencl,代码行数:13,代码来源:part2.py
示例13: change_display
def change_display(image) :
image_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=image)
mem = cl.GLBuffer(ctx, mf.WRITE_ONLY, numpy.float32(buf))
cl.enqueue_acquire_gl_objects(queue, [mem])
add_knl = prog.add
add_knl.set_args(image_buf, mem)
cl.enqueue_nd_range_kernel(queue, add_knl, image.shape, None)
cl.enqueue_release_gl_objects(queue, [mem])
queue.finish()
glFlush()
开发者ID:Blother,项目名称:Python_Interop,代码行数:13,代码来源:simple_interop.py
示例14: render
def render(self):
self.sample += 1
front_buf = self.buf[self.front]
back_buf = self.buf[1 - self.front]
self.front = 1 - self.front
prog = self.cache.get('kernels/test.cl')
cl.enqueue_acquire_gl_objects(self.queue, self.buf)
global_size = (self.width, self.height)
args = (self.cam_xform, np.int32(self.sample), self.env, back_buf, front_buf)
prog.test(self.queue, global_size, None, *args)
cl.enqueue_release_gl_objects(self.queue, self.buf)
self.queue.finish()
return front_buf.gl_object
开发者ID:scroll,项目名称:orange,代码行数:13,代码来源:orange.py
注:本文中的pyopencl.enqueue_release_gl_objects函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论