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 asm_code(self): ASM_CODE = " #DATA \n" + Sample.struct() + """ sample sample1 uint32 kraj #CODE macro mov eax, sample1 call get_sample mov dword [kraj], eax #END """ return ASM_CODE
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
import time from tdasm import Runtime from renmas3.core import Tile from renmas3.samplers import RegularSampler, Sample from renmas3.cameras import Pinhole from renmas3.core import ColorManager, Ray ASM_CODE = """ #DATA """ ASM_CODE += Sample.struct() + Ray.struct() + """ sample sample1 ray ray1 uint32 kraj #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)
from tdasm import Runtime from renmas3.base import Vector3, Ray from renmas3.samplers import Sample from renmas3.cameras import create_perspective_camera from renmas3.base import create_shader, arg_map eye = Vector3(2.2, 3.3, 4.4) lookat = Vector3(1.1, 2.2, 0.0) distance = 3.3 sample = Sample(2.2, 3.3, 5, 6, 1.0) camera = create_perspective_camera(eye, lookat, distance) runtimes = [Runtime()] camera.prepare(runtimes) call_code = """ generate_ray(sample, ray) """ args = arg_map([('sample', Sample), ('ray', Ray)]) shader = create_shader('test', call_code, args=args, shaders=[camera.shader]) shader.prepare(runtimes) shader.set_value('sample', sample) ray = camera.execute_py(sample) shader.execute() def cmp_vec3(vec1, vec2): if round(vec1.x - vec2.x, 3) != 0: