Developing Games on Intel Graphics
If you are gaming on graphics integrated in your Intel Processor, this is the place for you! Find answers to your questions or post your issues with PC games

3D engine

Anonymous
Not applicable
54,660 Views

Hello there,

ok, here we go, I have a dream, make a 3D engine 100% assembler intel only with CPU, I use rotation matrix only for now.


it works of course, but it's slow when I put a lot of pixels.

Recently I decided to include voxels in my engine, and it's slow when I put> = 8000 voxels (20 * 20 * 20 cube) and when I saw that nvidia display 32M voxels (fire) I wonder how they can do it !



And I have a little idea of  the reason: MMU, paging, segmentation. memory.

Am I right?



Another question, is the FPU is the slowest to compute floating point  than SSE or depending of data manipulate ?


PS: I work without OS like Windows or Linux, I run on my own kernel + bootloader in assembly too with NASM.

Sorry if i don't wirte a good english, i'm french and use google translate ^-^

0 Kudos
1 Solution
Bradley_W_Intel
Employee
54,230 Views

You clearly are using the processor in a very advanced way. I will do my best to answer your questions:

1) Why is your voxel engine not able to efficiently render as many voxels as you'd like? Voxel engines need to maximize their use of parallelism (both threading and SIMD) and also to store the data efficiently in an octree or some other structure that can handle sparse data. If you are doing all these things and still not getting the performance you expect, it's an optimization problem. Some Intel tools like VTune Performance Analyzer are excellent for performance analysis.

2) Is single data floating point math faster than SIMD (if I understood you)? Typically SIMD will be faster than single data instructions if your data is laid out in a way that supports the SIMD calls. In all cases, the only way for you to know for certain which way is faster is to test it.

3) How can you select between discrete and processor graphics? DirectX has methods of enumerating adapters. In such a case, the processor graphics is listed separately from the discrete graphics. If you are choosing your adapter based on the amount of available memory, you may be favoring the processor graphics when you didn't intend to. Intel has sample code that shows how to properly detect adapters in DirectX at https://software.intel.com/en-us/vcsource/samples/gpu-detect. The process for OpenGL is not well documented.

4) Can I use one processor to control execution of a second processor? Probably not. The details on Intel processors are covered at http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html. It's possible, though unlikely, that you'll be able to find something in there that can help you.

 

View solution in original post

0 Kudos
270 Replies
Bernard
Valued Contributor I
3,271 Views

>>>So if i call function into win32k.sys, it will be faster than gdi32.dll's function ?>>>

This is driver which is servicing user32.dll calls.I am not sure if you can call directly from user mode win32k.sys function maybe some of them. Usually user mode application is linked against user32.dll which in turn does user-to-kernel mode transition and invokes routines in win32k.sys.

http://i-web.i.u-tokyo.ac.jp/edu/training/ss/lecture/new-documents/Lectures/17-Win32K/Win32K.pdf

Important:

Regarding calling directly into win32k.sys please read following discussion:

http://stackoverflow.com/questions/21594744/can-i-access-windows-kernel-system-calls-directly

 

0 Kudos
Anonymous
Not applicable
3,271 Views

Thanks

0 Kudos
Bernard
Valued Contributor I
3,271 Views

>>>And i learned dll is like sys cause i have open win32k.sys into http://www.nirsoft.net/utils/dll_export_viewer.html by modify extension: win32k.dll.>>>

Yes .sys file is like .dll because it is implemented by PE format. I advise do not fiddle with those files unless you have a deep knowledge of Windows Internals.

0 Kudos
Bernard
Valued Contributor I
3,271 Views

>>>But like you see, i do a lot of vmovss, cause i do a special instruction (swap: E.0 with E.1, E.2 with E.3, ...) who don't exist on CPU as i know :/>>>

vmovss cost is 1 CPU cycle while its throughput is 0.5 cycle because CPU like Haswell has 2 load Ports and 1 Store port.

0 Kudos
Anonymous
Not applicable
3,271 Views

I will test win32k.sys's function by integrate* it through Golink (http://www.godevtool.com/) later, i hope i will don't get BSOD.

Well, i see EngBitBlt function is present in gdi32.dll too, i don't get it, whereas on MS web site, it's wrote that function is only available through win32k.sys: (http://msdn.microsoft.com/en-us/library/windows/hardware/ff564185%28v=vs.85%29.aspx).

0 Kudos
Bernard
Valued Contributor I
3,271 Views

>>>PS: thanks for your programs.>>>

You are welcome.

I must admit that last source code is little messy so soon I will rewrite it.Basically it will be particle modelling program which is based on SoA and Hybrid SoA design.

0 Kudos
Bernard
Valued Contributor I
3,271 Views

shaynox s. wrote:

I will test win32k.sys's function by integrate* it through Golink (http://www.godevtool.com/) later, i hope i will don't get BSOD.

Well, i see EngBitBlt function is present in gdi32.dll too, i don't get it, whereas on MS web site, it's wrote that function is only available through win32k.sys: (http://msdn.microsoft.com/en-us/library/windows/hardware/ff564185%28v=vs...).

Because EngBitBlt is lower level function which is implemented inside wink32.sys.

Please refer to this document(related to calling NT API from user mode) also http://www.osronline.com/article.cfm?article=91

 

0 Kudos
Anonymous
Not applicable
3,271 Views

Do you know view/camera equation linear without matrix form ?

I have try this, but it doesn't work:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;	glm::mat4 FPSViewRH( glm::vec3 eye, float yaw, float pitch )                                             ;;;
;;;	{                                                                                                        ;;;
;;;		using namespace glm;                                                                                 ;;;
;;;																											 ;;;
;;;		// If the pitch and yaw angles are in degrees,                                                       ;;;
;;;		// they need to be converted to radians. Here                                                        ;;;
;;;		// I assume the values are already converted to radians.                                             ;;;
;;;		float cosPitch = cos(pitch);                                                                         ;;;
;;;		float sinPitch = sin(pitch);                                                                         ;;;
;;;		float cosYaw = cos(yaw);                                                                             ;;;
;;;		float sinYaw = sin(yaw);                                                                             ;;;
;;;																											 ;;;
;;;		vec3 xaxis(      cosYaw      ,     0     ,     -sinYaw       );                                      ;;;
;;;		vec3 yaxis( sinYaw * sinPitch,  cosPitch , cosYaw * sinPitch );                                      ;;;
;;;		vec3 zaxis( sinYaw * cosPitch, -sinPitch , cosYaw * cosPitch );                                      ;;;
;;;																											 ;;;
;;;		// Create a 4x4 view matrix from the right, up, forward and eye position vectors                     ;;;
;;;		mat4 viewMatrix(                                                                                     ;;;
;;;						vec4(       xaxis.x,            yaxis.x,            zaxis.x,      0 ),               ;;;
;;;						vec4(       xaxis.y,            yaxis.y,            zaxis.y,      0 ),               ;;;
;;;						vec4(       xaxis.z,            yaxis.z,            zaxis.z,      0 ),               ;;;
;;;						vec4(  -dot(xaxis, eye)  , -dot(yaxis, eye)  , -dot(zaxis, eye) , 1 )                ;;;
;;;					   );                                                                                    ;;;
;;;																											 ;;;
;;;		//return viewMatrix;                                                                                 ;;;
;;;																											 ;;;
;;;		mat4 rotX = eulerAngleX( pitch );                                                                    ;;;
;;;		mat4 rotY = eulerAngleY( yaw );                                                                      ;;;
;;;		//mat4 rotation = rotY * rotX;                                                                       ;;;
;;;		mat4 rotation = eulerAngleYX( yaw, pitch );                                                          ;;;
;;;		mat4 translation = translate(eye);                                                                   ;;;
;;;																											 ;;;
;;;		return inverse( translation * rotation );                                                            ;;;
;;;	}                                                                                                        ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; X-axe
	View matrix on x:
				eye.x
				eye.y
				eye.z
						xaxis.							    yaxis.							   zaxis.								                            Rotation matrix on x:																							 Vector:
		 ___________________________________ ___________________________________ ___________________________________ ___________________________________         __________________________ _________________________ _________________________ _________________________         _________________________
		|						            |						            |						            |						            |       |						   |						 |						   |						 |       |      	               |
		|           cos(cam_phi_y)          |			      0 			    |			      0 			    |			      0                 |	    | 			  1 		   | 		    0 			 | 		      0 		   |			 0           |       |      	  x            |
		|___________________________________|___________________________________|___________________________________|___________________________________|       |__________________________|_________________________|_________________________|_________________________|       |_________________________|
		|						            |						            |						            |						            |       |						   |						 |						   |						 |       |      	               |
		|			       0 			    |			      1 			    |			      0 			    |			      0 			    |	    | 			  0 		   |        cos(phi_x)       |       -sin(phi_x)       | 		     0 			 |       |      	  y            |
		|___________________________________|___________________________________|___________________________________|___________________________________|	*   |__________________________|_________________________|_________________________|_________________________|       |_________________________| 
		|						            |						            |						            |						            |       |						   |						 |						   |					     |       |      	               |
		|          -sin(cam_phi_y)          |			      0 			    |			      1 			    |			      0 			    |       | 			  0 		   |        sin(phi_x)       |        cos(phi_x)       |			 0			 |   *   |      	  z            |
		|						            |						            |						            |						            |       |						   |						 |						   |						 |       |      	               |
		|___________________________________|___________________________________|___________________________________|___________________________________|       |__________________________|_________________________|_________________________|_________________________|       |_________________________|
		|						            |						            |						            |						            |       |			   		       |			 			 |			   			   |		        	     |       |      	               |
		|						            |						            |						            |			       	                |       |                          |						 |						   |						 |       |      	               |
		|	       -dot(xaxis, eye)	        |			      0 			    |			      0 			    |			      1	                |       |			  0		       |		    0		     |			  0		       |			 1		     |       |      	color          |
		|						            |						            |						            |			       	                |       |			  		       |			 		     |			   		       |			  		     |       |      	               |
		|___________________________________|___________________________________|___________________________________|___________________________________|       |__________________________|_________________________|_________________________|_________________________|       |_________________________|


	View matrix on x * Rotation matrix on x:																														                                                        Vector:
		 ________________________________________________ ________________________________________________ ________________________________________________ ________________________________________________         _________________________
		|						                         |						                          |						                           |						                        |       |      	                  |
		|                  cos(cam_phi_y)                |                        0                       |                        0                       |                        0                       |       |            x            |
		|						                         |                                                |                                                |						                        |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|       |_________________________|
		|						                         |						                          |						                           |						                        |       |                         |
		|                        0                       |                    cos(phi_x)                  |                   -sin(phi_x)                  |                        0                       |       |            y            |
		|						                         |                                                |                                                |						                        |       |                         | 
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|   *   |_________________________|
		|						                         |						                          |						                           |						                        |       |                         |
		|                 -sin(cam_phi_y)                |                    sin(phi_x)                  |                    cos(phi_x)                  |                        0                       |       |            z            |
		|                                                |                                                |                                                |						                        |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|       |_________________________|
		|						                         |						                          |						                           |						                        |       |                         |
		|                 -dot(xaxis, eye)               |                        0                       |                        0                       |                        1                       |       |          color          |
		|						                         |                                                |                                                |						                        |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|       |_________________________|
		
		*Result:
			x' =  (x * cos(cam_phi_y))
			y' =                         (y * cos(phi_x)) - (z * sin(phi_x))
			z' = -(x * sin(cam_phi_y)) + (y * sin(phi_x)) + (z * cos(phi_x))
			
		*Vectorization help:
			x' =  (x * cos(cam_phi_y)) + (y *     0     ) + (z *     0     )
			y' =  (x *       0       ) + (y * cos(phi_x)) - (z * sin(phi_x))
			z' = -(x * sin(cam_phi_y)) + (y * sin(phi_x)) + (z * cos(phi_x))
; Y-axe
	View matrix on y:
				eye.x
				eye.y
				eye.z
						xaxis.							    yaxis.							   zaxis.								                            Rotation matrix on y:																							 Vector:
		 ___________________________________ ___________________________________ ___________________________________ ___________________________________         __________________________ _________________________ _________________________ _________________________         _________________________
		|						            |						            |						            |						            |       |						   |						 |						   |						 |       |      	               |
		|			      1 			    |  sin(cam_phi_y) * sin(cam_phi_x)  |			      0 			    |			      0                 |	    |        cos(phi_y)        | 		    0 			 |       -sin(phi_y)       | 		    0 			 |       |      	  x            |
		|___________________________________|___________________________________|___________________________________|___________________________________|       |__________________________|_________________________|_________________________|_________________________|       |_________________________|
		|						            |						            |						            |						            |       |						   |						 |						   |						 |       |      	               |
		|			      0 			    |          cos(cam_phi_x)           |			      0 			    |			      0 			    |	    | 			  0 		   |			1	         | 			  0 		   | 		    0 			 |       |      	  y            |
		|___________________________________|___________________________________|___________________________________|___________________________________|	*   |__________________________|_________________________|_________________________|_________________________|       |_________________________|
		|						            |						            |						            |						            |       |						   |						 |						   |					     |       |      	               |
		|			      0 			    |  cos(cam_phi_y) * sin(cam_phi_x)  |			      1 			    |			      0 			    |       |        sin(phi_y)        | 		    0 			 |        cos(phi_y)       | 		    0 			 |   *   |      	  z            |
		|						            |						            |						            |						            |       |						   |						 |						   |						 |       |      	               |
		|___________________________________|___________________________________|___________________________________|___________________________________|       |__________________________|_________________________|_________________________|_________________________|       |_________________________|
		|						            |						            |						            |						            |       |			   		       |			 			 |			   			   |		        	     |       |      	               |
		|						            |						            |						            |			       	                |       |                          |						 |						   |						 |       |      	               |
		|			      0 			    |	      -dot(yaxis, eye)	        |			      0 			    |			      1	                |       |			  0		       |		    0		     |			  0		       |		    1		     |       |      	color          |
		|						            |						            |						            |			       	                |       |			  		       |			 		     |			   		       |			  		     |       |      	               |
		|___________________________________|___________________________________|___________________________________|___________________________________|       |__________________________|_________________________|_________________________|_________________________|       |_________________________|


	View matrix on y * Rotation matrix on y:																														                                                        Vector:
		 ________________________________________________ ________________________________________________ ________________________________________________ ________________________________________________         _________________________
		|						                         |						                          |						                           |                                                |       |                         |
		|                    cos(phi_y)                  |         sin(cam_phi_y) * sin(cam_phi_x)        |					 -sin(phi_y)                   |                       0                        |       |            x            |
		|                                                |						                          |						                           |                                                |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|       |_________________________|
		|						                         |						                          |						                           |						                        |       |                         |
		|                        0                       |                 cos(cam_phi_x)                 |                       0                        |                       0                        |       |            y            |
		|						                         |						                          |						                           |						                        |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|   *   |_________________________|
		|						                         |						                          |						                           |						                        |       |                         |
		|                    sin(phi_y)                  |         cos(cam_phi_y) * sin(cam_phi_x)        |                  cos(phi_y)                    |                       0                        |       |            z            |
		|                                                |						                          |                                                |						                        |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|       |_________________________|
		|						                         |						                          |						                           |						                        |       |                         |
		|                        0                       |	               -dot(yaxis, eye)	              |                       0                        |                       1                        |       |          color          |
		|                                                |						                          |                                                |						                        |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|       |_________________________|
		
		*Result:
			x' =  (x * cos(phi_y)) + (y * sin(cam_phi_y) * sin(cam_phi_x)) - (z * sin(phi_y))
			y' =                     (y * cos(cam_phi_x)                 )
			z' = -(x * sin(phi_y)) + (y * cos(cam_phi_y) * sin(cam_phi_x)) + (z * cos(phi_y))
	
		*Vectorization help:
			x' =  (x * cos(phi_y)) + (y * sin(cam_phi_y) * sin(cam_phi_x)) - (z * sin(phi_y))
			y' =  (x *     0     ) + (y * cos(cam_phi_x)                 ) - (z *     0     )
			z' = -(x * sin(phi_y)) + (y * cos(cam_phi_y) * sin(cam_phi_x)) + (z * cos(phi_y))

; Z-axe
	View matrix on z:
				eye.x
				eye.y
				eye.z
						xaxis.							    yaxis.							   zaxis.								                            Rotation matrix on z:																							 Vector:
		 ___________________________________ ___________________________________ ___________________________________ ___________________________________         __________________________ _________________________ _________________________ _________________________         _________________________
		|						            |						            |						            |						            |       |						   |						 |						   |						 |       |      	               |
		|			      1 			    |			      0 			    |  sin(cam_phi_y) * cos(cam_phi_x)  |			      0                 |	    |        cos(phi_z)        |        -sin(phi_z)      |			  0			   |			0            |       |            x            |
		|___________________________________|___________________________________|___________________________________|___________________________________|       |__________________________|_________________________|_________________________|_________________________|       |_________________________|
		|						            |						            |						            |						            |       |						   |						 |						   |						 |       |                         |
		|			      0 			    |			      1 			    |         -sin(cam_phi_x)           |			      0 			    |	    |        sin(phi_z)        |         cos(phi_z)      | 			  0 		   | 		    0 			 |       |            y            |
		|___________________________________|___________________________________|___________________________________|___________________________________|	*   |__________________________|_________________________|_________________________|_________________________|       |_________________________| 
		|						            |						            |						            |						            |       |						   |						 |						   |					     |   *   |                         |
		|			      0 			    |			      0 			    |  cos(cam_phi_y) * cos(cam_phi_x)  |			      0 			    |       |			  0			   | 		    0 			 |			  1			   |			0			 |       |            z            |
		|						            |						            |						            |						            |       |						   |						 |						   |						 |       |                         |
		|___________________________________|___________________________________|___________________________________|___________________________________|       |__________________________|_________________________|_________________________|_________________________|       |_________________________|
		|						            |						            |						            |						            |       |			   		       |			 			 |			   			   |		        	     |       |                         |
		|						            |						            |						            |			       	                |       |                          |						 |						   |						 |       |                         |
		|			      0 			    |			      0 			    |	      -dot(zaxis, eye)	        |			      1	                |       |			  0		       |		    0		     |			  0		       |		    1		     |       |          color          |
		|						            |						            |						            |			       	                |       |			  		       |			 		     |			   		       |			  		     |       |                         |
		|___________________________________|___________________________________|___________________________________|___________________________________|       |__________________________|_________________________|_________________________|_________________________|       |_________________________|


	View matrix on z * Rotation matrix on z:																														                                                        Vector:
		 ________________________________________________ ________________________________________________ ________________________________________________ ________________________________________________         _________________________
		|						                         |						                          |						                           |						                        |       |      	                  |
		|                    cos(phi_z)                  |                   -sin(phi_z)                  |                        0                       |                        0                       |       |            x            |
		|						                         |						                          |						                           |						                        |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|       |_________________________|
		|						                         |						                          |						                           |						                        |       |                         |
		|                    sin(phi_z)                  |                    cos(phi_z)                  |                        0                       |                        0                       |       |            y            |
		|						                         |						                          |						                           |						                        |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|   *   |_________________________|
		|						                         |						                          |						                           |						                        |       |                         |
		|                        0                       |                        0                       |                        1                       |                        0                       |       |            z            |
		|						                         |                                                |						                           |						                        |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|       |_________________________|
		|						                         |						                          |						                           |						                        |       |                         |
		|                                                |                  -dot(zaxis, eye)              |                        0                       |                        1                       |       |          color          |
		|						 0                       |                                                |						                           |						                        |       |                         |
		|________________________________________________|________________________________________________|________________________________________________|________________________________________________|       |_________________________|
		
		*Result:
			x' = (x * cos(phi_z)) - (y * sin(phi_z))
			y' = (x * sin(phi_z)) + (y * cos(phi_z))
			z' =  0

		*Vectorization help:
			x' = (x * cos(phi_z)) - (y * sin(phi_z)) + (z * 0 )
			y' = (x * sin(phi_z)) + (y * cos(phi_z)) + (z * 0 )
			z' = (x *     0     ) + (y *     0     ) + (z * 0 )

Thanks

0 Kudos
Bernard
Valued Contributor I
3,271 Views

>>>Do you know view/camera equation linear without matrix form ?

I have try this, but it doesn't work:>>.

Your code looks like OpenGL. Why it does not work? Did you try to consult API and code examples?

0 Kudos
Anonymous
Not applicable
3,271 Views

I just know this view matrix is mulitply by model matrix, but honnestly i don't know what it correspond, all i have is 3 equations for get rotate X Y and Z.

I assume i'm bad in mathematics, and about eng tutorial, like i'm bad in english i don't understand all topics, i read some tuto in fr, but the author don't explain so much like eng tuto, it's wrote glm::LookAt() function.

 

(http://codes-sources.commentcamarche.net/source/100763-little-3d-engine-winapi-x64-avx-support-nasm I have update for manage mouse)

0 Kudos
Bernard
Valued Contributor I
3,246 Views

Can you describe what is really happening? What is not working?

You need to buy a good book about the 3D graphics.

Please consider Frank Luna "3D Game Programming with DirectX 11"

 

0 Kudos
Anonymous
Not applicable
3,246 Views

It's happen that it transform my cube in single line. But now I found a new thing: the repere change by do this algo:

Translate_object -> Rotate_object -> Repere_object

And it give:

	copy_coord_x4:		dd	0, 0, 0, 0		; - p1
						dd	0, 0, 0, 0		; - p2
						dd	0, 0, 0, 0		; - p3
						dd	0, 0, 0, 0		; - p4

	moveobject_tmp:
		translate_mat:		dd	0, 0, 0, 0		; x, y, z
		rotate_mat:			dd	0, 0, 0, 0		; x, y, z
		repere_mat:			dd	0, 0, 0, 0		; x, y, z
							dd	0, 0, 0, 0

	permut_dword:		dd	1, 0, 3, 2		; - p1
						dd	5, 4, 7, 6		; - p2

	; X-axe:
		rotate_x_yz:	dd	0, 0, 0, 0		;  y,  z, 2y, 2z
						dd	0, 0, 0, 0		; 3y, 3z, 4y, 4z

		rotate_x_zy:	dd	0, 0, 0, 0		;  z,  y, 2z, 2y
						dd	0, 0, 0, 0		; 3z, 3y, 4z, 4y

	; Y-axe:
						dd	0
		rotate_y_zx:	dd	0, 0, 0, 0		;  z,  x, 2z, 2x
						dd	0, 0, 0, 0		; 3z, 3x, 4z, 4x

		rotate_y_xz:	dd	0, 0, 0, 0		;  x,  z, 2x, 2z
						dd	0, 0, 0, 0		; 3x, 3z, 4x, 4z
	
	; Z-axe:
						dd	0
		rotate_z_xy:	dd	0, 0, 0, 0		;  x,  y, 2x, 2y
						dd	0, 0, 0, 0		; 3x, 3y, 4x, 4y

		rotate_z_yx:	dd	0, 0, 0, 0		;  y,  x, 2y, 2x
						dd	0, 0, 0, 0		; 3y, 3x, 4y, 4x
		; Manage translation
			vmovups		xmm0, [translate_mat]
			vaddps		xmm0, [r8 + OBJ_3D_PROP_POSITION]
		vmovups		[r8 + OBJ_3D_PROP_POSITION], xmm0
		
		; Manage repere
			vmovups		xmm0, [repere_mat]
			vaddps		xmm0, [r8 + OBJ_3D_PROP_REPERE]
		vmovups		[r8 + OBJ_3D_PROP_REPERE], xmm0
		
		call	reset_angle
		; Manage rotation
			vmovups		xmm0, [rotate_mat]
			vaddps		xmm0, [r8 + OBJ_3D_PROP_ANGLE]
			vmovups		[r8 + OBJ_3D_PROP_ANGLE], xmm0
		vmovups		[fsincosps_angle], xmm0
		call		fsincosps

		; Duplicate cos(x)
			vbroadcastss		ymm0, [fsincosps_cos + _1x]
		; Duplicate cos(y)
			vbroadcastss		ymm1, [fsincosps_cos + _1y]
		; Duplicate cos(z)
			vbroadcastss		ymm2, [fsincosps_cos + _1z]


		; Duplicate sin(x)
			vbroadcastss		ymm3, [fsincosps_sin + _1x]
		; Duplicate sin(y)
			vbroadcastss		ymm4, [fsincosps_sin + _1y]
		; Duplicate sin(z)
			vbroadcastss		ymm5, [fsincosps_sin + _1z]

		vbroadcastf128		ymm6, [r8 + OBJ_3D_PROP_POSITION]
		vbroadcastf128		ymm7, [r8 + OBJ_3D_PROP_REPERE]

;======================================================================================================================================================================================
;FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION
;======================================================================================================================================================================================
object_translate:
		vaddps		ymm8, ymm6, [rsi]
		vmovups		[copy_coord_x4], ymm8
		vaddps		ymm8, ymm6, [rsi + _3x]
		vmovups		[copy_coord_x4 + _3x], ymm8
;======================================================================================================================================================================================
;END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION
;======================================================================================================================================================================================

;======================================================================================================================================================================================
;FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION
;======================================================================================================================================================================================
; object_rotate:
; On applique la rotation au point	|[rsi + _1x]
;									|[rsi + _1y]
;									|[rsi + _1z]
;									|[rsi + _1color]	.Unmodified
;									|[rsi + _2x]
;									|[rsi + _2y]
;									|[rsi + _2z]
;									|[rsi + _2color]	.Unmodified
;									|[rsi + _3x]
;									|[rsi + _3y]
;									|[rsi + _3z]
;									|[rsi + _3color]	.Unmodified
;									|[rsi + _4x]
;									|[rsi + _4y]
;									|[rsi + _4z]
;									|[rsi + _4color]	.Unmodified
object_rotate:
		;=============
		; pitch
		;=============
			Pitch:	; x
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;; 						X-axe                            ;;
				;; 		1y' = (1y * cos(phi_x)) - (1z * sin(phi_x))      ;; 1 0
				;; 		1z' = (1z * cos(phi_x)) + (1y * sin(phi_x))      ;; 2 4
				;; 		2y' = (2y * cos(phi_x)) - (2z * sin(phi_x))      ;; 3 8
				;;		2z' = (2z * cos(phi_x)) + (2y * sin(phi_x))      ;; 4 12
				;; 		3y' = (3y * cos(phi_x)) - (3z * sin(phi_x))      ;; 5 16
				;; 		3z' = (3z * cos(phi_x)) + (3y * sin(phi_x))      ;; 6 20
				;; 		4y' = (4y * cos(phi_x)) - (4z * sin(phi_x))      ;; 7 24
				;;		4z' = (4z * cos(phi_x)) + (4y * sin(phi_x))      ;; 8 28
				;;                                                       ;;
				;; 		1y = 1y'     3y = 3y'                            ;;
				;;		1z = 1z'     3z = 3z'                            ;;
				;;		2y = 2y'     4y = 4y'                            ;;
				;;		2z = 2z'     4z = 4z'                            ;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				; Prepare data
					; Store i = 0::Loop(i <= 4 , j <= 8){ ymm = iY; j++; ymm = iZ; i++; j++;}
						vmovlps		xmm8, [copy_coord_x4 + _1y]
						vmovlps		xmm9, [copy_coord_x4 + _2y]
						vmovlps		xmm10, [copy_coord_x4 + _3y]
						vmovlps		xmm11, [copy_coord_x4 + _4y]
						vmovlps		[rotate_x_yz +  0], xmm8
						vmovlps		[rotate_x_yz +  8], xmm9
						vmovlps		[rotate_x_yz + 16], xmm10
						vmovlps		[rotate_x_yz + 24], xmm11				
					; Store i = 0::Loop(i <= 4 , j <= 8){ ymm = iZ; j++; ymm = iY; i++; j++;}
					
					; AVX2 requirement
						; vmovups		ymm9, [permut_dword]
						; vpermps		ymm9, ymm9, [rotate_x_yz]
						; vmovups		[rotate_x_zy], ymm9

						vextractps	dword [rotate_x_zy +  0], xmm8, 1	; _1z
						vmovss		dword [rotate_x_zy +  4], xmm8		; _1y
						vextractps	dword [rotate_x_zy +  8], xmm9, 1	; _2z
						vmovss		dword [rotate_x_zy + 12], xmm9		; _2y
						vextractps	dword [rotate_x_zy + 16], xmm10, 1	; _3z
						vmovss		dword [rotate_x_zy + 20], xmm10		; _3y
						vextractps	dword [rotate_x_zy + 24], xmm11, 1	; _4z
						vmovss		dword [rotate_x_zy + 28], xmm11		; _4y

					;			ymm8			   ymm9
					; y' = (y * cos(phi_x)) - (z * sin(phi_x))
					; z' = (z * cos(phi_x)) + (y * sin(phi_x))
							vmulps		ymm8, ymm0, [rotate_x_yz]		; ymm8 * cos(x)
							vmulps		ymm9, ymm3, [rotate_x_zy]		; ymm9 * sin(x)
						vaddsubps		ymm8, ymm9

					vmovups		[temp256], ymm8
					; y = y'  ymm8
					; z = z'  ymm8
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;;					    /X-axe                           ;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;=============
		; / pitch
		;=============
		
		;=============
		; yaw
		;=============
			Yaw:	; y
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;; 						Y-axe                            ;;
				;; End.1z  = 1z' = (1z * cos(phi_y)) - (1x * sin(phi_y)) ;; 1 0
				;;			 1x' = (1x * cos(phi_y)) + (1z * sin(phi_y)) ;; 2 4
				;; End.2z  = 2z' = (2z * cos(phi_y)) - (2x * sin(phi_y)) ;; 3 8
				;;			 2x' = (2x * cos(phi_y)) + (2z * sin(phi_y)) ;; 4 12
				;; End.3z  = 3z' = (3z * cos(phi_y)) - (3x * sin(phi_y)) ;; 5 16
				;;			 3x' = (3x * cos(phi_y)) + (3z * sin(phi_y)) ;; 6 20
				;; End.4z  = 4z' = (4z * cos(phi_y)) - (4x * sin(phi_y)) ;; 7 24
				;;			 4x' = (4x * cos(phi_y)) + (4z * sin(phi_y)) ;; 8 28
				;;                                                       ;;
				;;			1x = 1x'                                     ;;
				;;			2x = 2x'                                     ;;
				;;			3x = 3x'                                     ;;
				;;			4x = 4x'                                     ;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				; Prepare data
					vmovss		xmm9,  [copy_coord_x4 + _1x]
					vmovss		xmm10,  [copy_coord_x4 + _2x]
					vmovss		xmm11,  [copy_coord_x4 + _3x]
					vmovss		xmm12, [copy_coord_x4 + _4x]
					; Store i = 0::Loop(i <= 4 , j <= 8){ ymm = iZ; j++; ymm = iX; i++; j++;}
						vmovups		[rotate_y_zx -  4], ymm8
						vmovss		[rotate_y_zx +  4], xmm9
						vmovss		[rotate_y_zx + 12], xmm10
						vmovss		[rotate_y_zx + 20], xmm11
						vmovss		[rotate_y_zx + 28], xmm12

					; Store i = 0::Loop(i <= 4 , j <= 8){ ymm = iX; j++; ymm = iZ; i++; j++;}
					
					; AVX2 requirement
						; vmovups		ymm9, [permut_dword]
						; vpermps		ymm9, ymm9, [rotate_y_zx]
						; vmovups		[rotate_y_xz], ymm9
						
						vmovups		[rotate_y_xz +  0], ymm8
						vmovss		[rotate_y_xz +  0], xmm9
						vmovss		[rotate_y_xz +  8], xmm10
						vmovss		[rotate_y_xz + 16], xmm11
						vmovss		[rotate_y_xz + 24], xmm12

				;			ymm8			   ymm9
				; z' = (z * cos(phi_y)) - (x * sin(phi_y))
				; x' = (x * cos(phi_y)) + (z * sin(phi_y))
						vmulps		ymm8, ymm1, [rotate_y_zx]		; ymm8 * cos(y)
						vmulps		ymm9, ymm4, [rotate_y_xz]		; ymm9 * sin(y)
					vaddsubps		ymm8, ymm9

				; x = x'  xmm3
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;; 					    /Y-axe                           ;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;=============
		; / yaw
		;=============
		
		;=============
		; roll
		;=============
			Roll:	; z
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;; 						Z-axe                            ;;
				;; End.1x  = 1x' = (1x * cos(phi_z)) - (1y * sin(phi_z)) ;; 1 0
				;; End.1y  = 1y' = (1y * cos(phi_z)) + (1x * sin(phi_z)) ;; 2 4
				;; End.2x  = 2x' = (2x * cos(phi_z)) - (2y * sin(phi_z)) ;; 3 8
				;; End.2y  = 2y' = (2y * cos(phi_z)) + (2x * sin(phi_z)) ;; 4 12
				;; End.3x  = 3x' = (3x * cos(phi_z)) - (3y * sin(phi_z)) ;; 5 16
				;; End.3y  = 3y' = (3y * cos(phi_z)) + (3x * sin(phi_z)) ;; 6 20
				;; End.4x  = 4x' = (4x * cos(phi_z)) - (4y * sin(phi_z)) ;; 7 24
				;; End.4y  = 4y' = (4y * cos(phi_z)) + (4x * sin(phi_z)) ;; 8 28
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				; Prepare data
					vmovss		xmm9 , [temp256]
					vmovss		xmm10 , [temp256 +  8]
					vmovss		xmm11 , [temp256 + 16]
					vmovss		xmm12, [temp256 + 24]
					; Store i = 0::Loop(i <= 4 , j <= 8){ ymm = iX; j++; ymm = iY; i++; j++;}
						vmovups		[rotate_z_xy -  4], ymm8
						vmovss		[rotate_z_xy +  4], xmm9
						vmovss		[rotate_z_xy + 12], xmm10
						vmovss		[rotate_z_xy + 20], xmm11
						vmovss		[rotate_z_xy + 28], xmm12

					; Store i = 0::Loop(i <= 4 , j <= 8){ ymm = iY; j++; ymm = iX; i++; j++;}
						vmovups		[rotate_z_yx +  0], ymm8
						vmovss		[rotate_z_yx +  0], xmm9
						vmovss		[rotate_z_yx +  8], xmm10
						vmovss		[rotate_z_yx + 16], xmm11
						vmovss		[rotate_z_yx + 24], xmm12

				; Save z					
					vmovss			[rbx + _1z], xmm8
					vextractps		[rbx + _2z], xmm8, 2
					vextractf128	xmm8, ymm8, 1
					vmovss			[rbx + _3z], xmm8
					vextractps		[rbx + _4z], xmm8, 2
				;			ymm8			   ymm9
				; x' = (x * cos(phi_z)) - (y * sin(phi_z))
				; y' = (y * cos(phi_z)) + (x * sin(phi_z))
						vmulps		ymm8, ymm2, [rotate_z_xy]		; ymm8 * cos(z)
						vmulps		ymm9, ymm5, [rotate_z_yx]		; ymm9 * sin(z)
					vaddsubps		ymm8, ymm9

				; Save x y
					vmovsd			[rbx + _1x], xmm8
					vpextrq			[rbx + _2x], xmm8, 2
					vextractf128	xmm8, ymm8, 1
					vmovsd			[rbx + _3x], xmm8
					vpextrq			[rbx + _4x], xmm8, 2
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;; 					    /Z-axe                           ;;
				;;-------------------------------------------------------;;
				;;                                                       ;;
				;;-------------------------------------------------------;;
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;=============
		; / roll
		;=============
end_object_rotate:
; ret
;======================================================================================================================================================================================
;END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION
;======================================================================================================================================================================================

;======================================================================================================================================================================================
;FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION	FUNCTION
;======================================================================================================================================================================================
object_repere:
		vaddps		ymm8, ymm7, [rbx]
		vmovups		[rbx], ymm8
		vaddps		ymm8, ymm7, [rbx + _3x]
		vmovups		[rbx + _3x], ymm8
;======================================================================================================================================================================================
;END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION	END_FUNCTION
;======================================================================================================================================================================================
				
		vmovss		xmm8, [rsi + _1color]
		vmovss		xmm9, [rsi + _2color]
		vmovss		xmm10, [rsi + _3color]
		vmovss		xmm11, [rsi + _4color]

		vmovss		[rbx + _1color], xmm8
		vmovss		[rbx + _2color], xmm9
		vmovss		[rbx + _3color], xmm10
		vmovss		[rbx + _4color], xmm11

 

0 Kudos
Bernard
Valued Contributor I
3,246 Views

But what is happening? It is not easy to look at assembly source code and immediately know what went wrong?

0 Kudos
Anonymous
Not applicable
3,246 Views

It's just change my voxel cube in line and rotate 40% degree (20 -> (-20) | -(20) -> 20 ), but I put this previous code in garbage and choose the new code (above), and have a new proprietie: repere.

And I think I will play with those 3 proprieties (translation/rotation/repere) for found how manage camera.

0 Kudos
Bernard
Valued Contributor I
3,246 Views

What does it mean "repere"? Is that some reference point?

0 Kudos
Anonymous
Not applicable
3,246 Views

Well yes

0 Kudos
Bernard
Valued Contributor I
3,246 Views

Look at this GitHub hosted  source code of various camera models.

https://github.com/mmp/pbrt-v2/tree/master/src/cameras

0 Kudos
Bernard
Valued Contributor I
3,246 Views

You could look at this book "Physically Based Rendering" heavy on math , but it describes production-quality ray tracer.

0 Kudos
Bernard
Valued Contributor I
3,246 Views

I think that you can use quaternions for managing virtual camera movement.For example quaternion can be defined this way

typedef struct QUATERNION_XYZW_F

{

 union

{

  declspec(aligned 16)) float _quaternion_xyzw [4];

 

 struct{

   float x, y, z, w;

}

 struct

{

 __m128 quaternion;

}

}

} QUATERNION, *QUATERNION_PTR;

0 Kudos
Bernard
Valued Contributor I
3,246 Views

Matrix 4x4 which can be used to perform rotation can be defined this way.

typedef struct MATRIX4x4

{

union

{

struct

{

float m00,m01,m02,m03;

float m10,m11,m12,m13;

float m20,m21,m22,m23;

float m30,m31,m32,m33;

}

struct 

{

 __m128 vx,vy,vz,vw;

 

}

}

}MATRIX4x4_F, *MATRIX4x4_F_PTR;

0 Kudos
Bernard
Valued Contributor I
3,246 Views

Maybe you mean focal distance?

>>>And about quaternions, all people say it's wonderful tool for make rotation, but we need always sin and cos function right ? So I don't get in what is real faster.>>>

Yes you need sin and cos of course in order to represent rotation.Quaternion has nice features because it is more like hyper complex number.

0 Kudos
Reply