def test1(self): mgr = ColorManager() sampler = RegularSampler(2, 2, pixel=1.0) tile = Tile(5, 5, 20, 20) tile.split(1) runtime = Runtime() sampler.get_sample_asm([runtime], "get_sample", mgr.assembler) mc = mgr.assembler.assemble(self.asm_code()) ds = runtime.load('test', mc) sampler.set_tile(tile) while True: sample = sampler.get_sample() if sample is None: break runtime.run('test') self.sample_test(sample, ds) runtime.run('test') ret = ds['kraj'] self.assertFalse(ret)
def performance_regular_sampler(width, height): sam = RegularSampler(width, height) runtimes = [Runtime(), Runtime(), Runtime(), Runtime()] sam.prepare(runtimes) sam.set_pass(0) code = """ ret = 1 nsamples = 0 while ret != 0: ret = generate_sample(sample) if ret == 0: break nsamples = nsamples + 1 """ sample = Sample(0.0, 0.0, 0, 0, 1.0) props = {'sample': sample, 'ret': 0, 'nsamples': 0} bas = BasicShader(code, props) bas.prepare(runtimes, [sam.shader]) start = time.clock() bas.execute() end = time.clock() print("Exectution of generating %i samples took %f" % (bas.shader.get_value('nsamples'), end - start))
def test_regular_sampler(width, height): sam = RegularSampler(width, height, 0.1) runtime = Runtime() sam.prepare([runtime]) sam.set_pass(0) code = """ ret = generate_sample(sample) """ sample = Sample(0.0, 0.0, 0, 0, 1.0) props = {'sample': sample, 'ret': 0} bas = BasicShader(code, props) bas.prepare([runtime], [sam.shader]) while True: bas.execute() sample = sam.generate_sample() test_values(sample, bas.shader) if sample is None: break
#CODE macro mov eax, sample1 call get_sample mov dword [kraj], eax macro mov eax, sample1 macro mov ebx, ray1 call get_ray #END """ cam = Pinhole((2,3,4), (5,9,1)) mgr = ColorManager() width = 2 height = 2 sampler = RegularSampler(width, height) runtime = Runtime() sampler.get_sample_asm([runtime], "get_sample", mgr.assembler) cam.ray_asm([runtime], 'get_ray', mgr.assembler) mc = mgr.assembler.assemble(ASM_CODE) ds = runtime.load('test', mc) tile = Tile(0,0, width, height) tile.split(1) sampler.set_tile(tile) start = time.clock() while True: sample = sampler.get_sample() if sample is None: break