当前位置: 首页>>代码示例>>Python>>正文


Python tdasm.Tdasm类代码示例

本文整理汇总了Python中tdasm.Tdasm的典型用法代码示例。如果您正苦于以下问题:Python Tdasm类的具体用法?Python Tdasm怎么用?Python Tdasm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Tdasm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_struct

 def _create_struct(self, shape):
     code = " #DATA " + shape.asm_struct() + """
     #CODE
     #END
     """
     mc = Tdasm().assemble(code)
     return mc.get_struct(shape.asm_struct_name())
开发者ID:mario007,项目名称:renmas,代码行数:7,代码来源:mgr.py

示例2: test_pow_ps

    def test_pow_ps(self):
        asm = Tdasm()
        mc = asm.assemble(POW_CODE_PS)
        runtime = Runtime()
        load_math_func("fast_pow_ps", runtime)
        ds = runtime.load("pow_ps", mc)

        for x in range(1000):
            num1 = random.random() * 3 
            num2 = random.random() * 3
            num3 = random.random() * 3
            num4 = random.random() * 3
            num5 = random.random() * 3 
            num6 = random.random() * 3
            num7 = random.random() * 3
            num8 = random.random() * 3
            ds["v1"] = (num1, num2, num3, num4) 
            ds["v2"] = (num5, num6, num7, num8)
            runtime.run("pow_ps")
            rez_asm = ds["v1"]
            rez_py1 = math.pow(num1, num5)
            rez_py2 = math.pow(num2, num6)
            rez_py3 = math.pow(num3, num7)
            rez_py4 = math.pow(num4, num8)

            self.assertAlmostEqual(rez_asm[0], rez_py1, 1)
            self.assertAlmostEqual(rez_asm[1], rez_py2, 1)
            self.assertAlmostEqual(rez_asm[2], rez_py3, 1)
            self.assertAlmostEqual(rez_asm[3], rez_py4, 1)
开发者ID:mario007,项目名称:renmas,代码行数:29,代码来源:test_trigs.py

示例3: _create_struct

 def _create_struct(self, struct_def, name):
     code = " #DATA \n" + struct_def + """
     #CODE
     #END
     """
     mc = Tdasm().assemble(code)
     return mc.get_struct(name)
开发者ID:mario007,项目名称:renmas,代码行数:7,代码来源:arr.py

示例4: prepare

    def prepare(self, runtimes):
        self._load_color_funcs(runtimes)

        if self.loader:
            self.loader(runtimes)

        for s in self._shaders:
            s.prepare(runtimes)

        self._runtimes = runtimes
        asm = Tdasm()
        name = 'shader' + str(id(self))

        for fun in self._functions:
            fun_name, fun_label, avx, bit = fun
            load_asm_function(fun_name, fun_label, runtimes, avx, bit)

        ds = []
        for r in runtimes:
            if not r.global_exists(self._name):
                if self._name in self._mc_cache:
                    ds.append(r.load(name, self._mc_cache[self._name])) 
                else:
                    mc = asm.assemble(self._code, self._func)
                    self._mc_cache[self._name] = mc
                    ds.append(r.load(name, mc)) 
        if ds:
            self._ds = ds
开发者ID:mario007,项目名称:renmas,代码行数:28,代码来源:shader.py

示例5: test_sincos_ps

    def test_sincos_ps(self):
        asm = Tdasm()
        mc = asm.assemble(SINCOS_CODE_PS)
        runtime = Runtime()
        load_math_func("fast_sincos_ps", runtime)
        ds = runtime.load("sincos_ps", mc)

        for x in range(1000):
            num1 = random.random() * 2000
            num2 = random.random() * 2000
            num3 = random.random() * 2000
            num4 = random.random() * 2000
            ds["v1"] = (num1, num2, num3, num4) 
            runtime.run("sincos_ps")
            rez_asm_sin = ds["v1"]
            rez_asm_cos = ds["v2"]
            rez_py1_sin = math.sin(num1)
            rez_py2_sin = math.sin(num2)
            rez_py3_sin = math.sin(num3)
            rez_py4_sin = math.sin(num4)
            rez_py1_cos = math.cos(num1)
            rez_py2_cos = math.cos(num2)
            rez_py3_cos = math.cos(num3)
            rez_py4_cos = math.cos(num4)

            self.assertAlmostEqual(rez_asm_sin[0], rez_py1_sin, 3)
            self.assertAlmostEqual(rez_asm_sin[1], rez_py2_sin, 3)
            self.assertAlmostEqual(rez_asm_sin[2], rez_py3_sin, 3)
            self.assertAlmostEqual(rez_asm_sin[3], rez_py4_sin, 3)
            self.assertAlmostEqual(rez_asm_cos[0], rez_py1_cos, 3)
            self.assertAlmostEqual(rez_asm_cos[1], rez_py2_cos, 3)
            self.assertAlmostEqual(rez_asm_cos[2], rez_py3_cos, 3)
            self.assertAlmostEqual(rez_asm_cos[3], rez_py4_cos, 3)
开发者ID:mario007,项目名称:renmas,代码行数:33,代码来源:test_trigs.py

示例6: __init__

 def __init__(self):
     asm = Tdasm()
     m = asm.assemble(MEMCPY)
     self.r = Runtime()
     self.ds = self.r.load("memcpy", m)
     m2 = asm.assemble(BLTRGBA)
     self.ds2 = self.r.load("bltrgba", m2)
     m3 = asm.assemble(BLTFLOATRGBA)
     self.ds3 = self.r.load("bltfloatrgba", m3)
开发者ID:mario007,项目名称:renmas,代码行数:9,代码来源:blitter.py

示例7: create_float_image

def create_float_image(runtime):
    img = renmas.gui.ImageFloatRGBA(150, 150)
    
    img.set_pixel_asm(runtime, "set_pixel")

    asm = Tdasm()
    mc = asm.assemble(ASM)
    runtime.load("write", mc)
    runtime.run("write")
    return img
开发者ID:mario007,项目名称:renmas,代码行数:10,代码来源:test_image_asm.py

示例8: compile

 def compile(self, shaders=[]):
     stms = parse(self._code)
     cgen = CodeGenerator()
     asm, ret_type = cgen.generate_code(
         stms, args=self._args, is_func=self._is_func, name=self._name, func_args=self._func_args, shaders=shaders
     )
     self._asm_code = asm
     self._ret_type = ret_type
     asm = Tdasm()
     self._mc = asm.assemble(self._asm_code, self._is_func)
开发者ID:mario007,项目名称:renmas,代码行数:10,代码来源:shader.py

示例9: _create_struct

 def _create_struct(self, struct_def, name):
     code = " #DATA \n" + struct_def + """
     #CODE
     #END
     """
     ia32 = True
     bits = platform.architecture()[0]
     if bits == '64bit':
         ia32 = False
     mc = Tdasm().assemble(code, ia32=ia32)
     return mc.get_struct(name)
开发者ID:mario007,项目名称:renmas,代码行数:11,代码来源:arr.py

示例10: test_atan

    def test_atan(self):
        asm = Tdasm()
        mc = asm.assemble(ATAN_CODE)
        runtime = Runtime()
        load_math_func("fast_atan_ss", runtime)
        ds = runtime.load("atan", mc)

        for x in range(1000):
            num = random.random() * 2000
            ds["x"] = num 
            runtime.run("atan")
            rez_asm = ds["x"]
            rez_py = math.atan(num)
            self.assertAlmostEqual(rez_asm, rez_py, 3)
开发者ID:mario007,项目名称:renmas,代码行数:14,代码来源:test_trigs.py

示例11: test_log

    def test_log(self):
        asm = Tdasm()
        mc = asm.assemble(LOG_CODE)
        runtime = Runtime()
        load_math_func("fast_log_ss", runtime)
        ds = runtime.load("log", mc)

        for x in range(1000):
            num = random.random()  
            ds["x"] = num 
            runtime.run("log")
            rez_asm = ds["x"]
            rez_py = math.log(num)
            self.assertAlmostEqual(rez_asm, rez_py, 3)
开发者ID:mario007,项目名称:renmas,代码行数:14,代码来源:test_trigs.py

示例12: test_exp

    def test_exp(self):
        asm = Tdasm()
        mc = asm.assemble(EXP_CODE)
        runtime = Runtime()
        load_math_func("fast_exp_ss", runtime)
        ds = runtime.load("exp", mc)

        for x in range(1000):
            num = random.random() * 4 
            ds["x"] = num 
            runtime.run("exp")
            rez_asm = ds["x"]
            rez_py = math.exp(num)
            self.assertAlmostEqual(rez_asm, rez_py, 2)
开发者ID:mario007,项目名称:renmas,代码行数:14,代码来源:test_trigs.py

示例13: compile

 def compile(self, shaders=[], color_mgr=None):
     stms = parse(self._code)
     cgen = CodeGenerator()
     asm, ret_type, fns = cgen.generate_code(stms, args=self._args,
                                             is_func=self._is_func,
                                             name=self._name,
                                             func_args=self._func_args,
                                             shaders=shaders,
                                             color_mgr=color_mgr)
     self._asm_code = asm
     self._ret_type = ret_type
     self._ext_functions = fns
     asm = Tdasm()
     self._mc = asm.assemble(self._asm_code, naked=self._is_func,
                             ia32=not cgen.BIT64)
开发者ID:mario007,项目名称:renmas,代码行数:15,代码来源:shader.py

示例14: set_pixel_asm

    def set_pixel_asm(self, runtime, label):
        
        bits = platform.architecture()[0]
        if bits == "64bit": ecx = "rcx"
        else: ecx = "ecx"

        if util.AVX:
            line = "vmovaps oword [" + ecx + "], xmm0"
        else:
            line = "movaps oword [" + ecx + "], xmm0"

        bits = platform.architecture()[0]
        if bits == "64bit":
            l1 = "uint64 ptr_buffer"
            l2 = "mov rcx, qword [ptr_buffer]"
            l3 = "add rcx, rax"
        else:
            l1 = "uint32 ptr_buffer"
            l2 = "mov ecx, dword [ptr_buffer]"
            l3 = "add ecx, eax"

        asm_code = """
        #DATA
        """
        asm_code += l1 + """
        uint32 pitch
        #CODE
        ; eax = x , ebx = y, value = xmm0
        """
        asm_code += "global " + label + ": \n"
        asm_code += """
        imul ebx, dword [pitch]
        imul eax , eax, 16
        """
        asm_code += l2 + """
        add eax, ebx
        """
        asm_code += l3 + "\n"
        asm_code += line + """
        ret
        """

        asm = Tdasm()
        mc = asm.assemble(asm_code, True)
        name = "ImageFloatRGBA" + str(hash(self)) 
        self.ds = runtime.load(name, mc)
        self.ds["ptr_buffer"] = self.pixels.ptr()
        self.ds["pitch"] = self.pitch
开发者ID:mario007,项目名称:renmas,代码行数:48,代码来源:image.py

示例15: test_pow

    def test_pow(self):
        asm = Tdasm()
        mc = asm.assemble(POW_CODE)
        runtime = Runtime()
        load_math_func("fast_pow_ss", runtime)
        ds = runtime.load("pow", mc)

        for x in range(1000):
            num = random.random() * 3 
            num1 = random.random() * 3 
            ds["x"] = num 
            ds["y"] = num1 
            runtime.run("pow")
            rez_asm = ds["x"]
            rez_py = math.pow(num, num1)
            self.assertAlmostEqual(rez_asm, rez_py, 1)
开发者ID:mario007,项目名称:renmas,代码行数:16,代码来源:test_trigs.py


注:本文中的tdasm.Tdasm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。