Jump to content
  • Advertisement

toukkapoukka

Member
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

102 Neutral

About toukkapoukka

  • Rank
    Newbie
  1. toukkapoukka

    Re: vector3 pod types (in C this time)

    Vector is in C side so no constructors there. In C++ this would be no problem since returning by value works with explicit copy constructors. But I was able to, at least temporarily, fix the issue by unioning the 3 float components with 3 integer components
  2. toukkapoukka

    Re: vector3 pod types (in C this time)

    asvec3.c #define _TEST_ONLY_ #ifndef _TEST_ONLY_ #include <stdio.h> #endif typedef float vec3_t[3]; typedef struct { vec3_t v; } asvec3_t; asvec3_t asvec3_123() { asvec3_t v = { {1,2,3} }; return v; } #ifndef _TEST_ONLY_ int main() { asvec3_t v = asvec3_123(); printf( "%f, %f, %f\n", v.v[0], v.v[1], v.v[2] ); return 0; } #endif asvec3.s .file "asvec3.c" .text .globl asvec3_123 .type asvec3_123, @function asvec3_123: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movl $0x3f800000, %eax movl %eax, -32(%rbp) movl $0x40000000, %eax movl %eax, -28(%rbp) movl $0x40400000, %eax movl %eax, -24(%rbp) movq -32(%rbp), %rax movq %rax, -16(%rbp) movl -24(%rbp), %eax movl %eax, -8(%rbp) movq -16(%rbp), %rdx mov -8(%rbp), %eax movq %rdx, -56(%rbp) movq -56(%rbp), %xmm0 movq %rax, -56(%rbp) movq -56(%rbp), %xmm1 popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size asvec3_123, .-asvec3_123 .ident "GCC: (GNU) 4.6.1 20110819 (prerelease)" .section .note.GNU-stack,"",@progbits Yes it seems to use the SSE registers for return value. I found a function attribute sseregparm for GCC, but unfortunately I can't find a complementary attribute to it.
  3. toukkapoukka

    Re: vector3 pod types (in C this time)

    At least this allows us to keep the 12-byte size on the vector, union { float v[3]; int i[3]; }; Apparently I need to have another flag than asOBJ_APP_CLASS to identify that the asvec3_t type should be returned in a swapped order, however I do not know how the application developer should know when to use one or the other. [/quote] Yes, this is a bad idea. Even Vicious dont approve If you have any idea on what the rule might be as to when gcc does it one way or the other I would really like to hear it. [/quote] I'm afraid I'm not that well equipped to investigate the bug on gcc/asm level. I wonder would issues in this thread be related: http://www.gamedev.n...urning-doubles/ Specially those " bigger changes to the code that implements the native calling conventions in version 2.20.2"? Our version is 2.21.0 btw.
  4. toukkapoukka

    Re: vector3 pod types (in C this time)

    Small update, I found something that temporarily fixes our problem. Any of the following methods produce the vector (1,2,3) correctly: struct vector { union { float xyz[3]; double _as_64bit_hack[3]; }; }; struct vector { float xyz[3]; float pad[2]; // <- has to be at least 2 elements }; struct vector { double xyz[3]; // works as double, see first method }; I tried different alignments with GCC align attribute, but none worked like these so I'm not sure is this alignment issue or framesize issue or what? Naturally this isnt 100% satisfactory workaround and I hope that you find a "correct" solution for this
  5. toukkapoukka

    Re: vector3 pod types (in C this time)

    Hi! There was a topic with similar problem that we are experiencing, http://www.gamedev.net/topic/607167-ogre-vector3-and-amd64/ . But what is different in our case is that our vector type is in pure C and writing explicit constructors/copy-constructors dont work in our case. And yes, the problem is returning simple struct type as value on linux x64 (GCC 4.6.1), the vector values are all funky. Saying returning vector with values (1,2,3) will give out (3,0,1). Vector struct looks like this; typedef float vec_t; typedef vec_t vec3_t[3]; typedef struct asvec3_s { vec3_t v; } asvec3_t; We register the type with flags (asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS). What are possible options that we have to fix this?
  6. toukkapoukka

    AngelScript <-> C++ binder class.

    Looking nice! How are you going to differentiate POD's, "classes" and reference objects? And you also should support single-ref objects too.
  7. toukkapoukka

    AngelScript <-> C++ binder class.

    More options for automatic reference-counting. Our project is interfacing libRocket and Angelscript and one of the problems is that we can't directly export libRocket functions because their reference-counting methods differ. libRocket returns reference-counted objects without increasing the reference so we have to write a wrapper for each of these functions that call AddReference there. Also IIRC we needed to do something like this for reference-counted elements in function parameters. We cant use autohandles (or what was it called) because of the binding library I posted that produces automatic prototype strings from C++ function/method definitions. BTW, the asbind.h states GPL license but that is because we use it in our GPL project, but I can relicense a version with more liberal license
  8. toukkapoukka

    AngelScript <-> C++ binder class.

    Hi! Good luck with your experiments. I thought I'd like to share this very similar thing that I wrote up: ASBind.h Maybe we can collaborate or exchange ideas on these?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!