diff --git a/GL/glext.h b/GL/glext.h index af58da28e8..f0999b8acb 100644 --- a/GL/glext.h +++ b/GL/glext.h @@ -6,7 +6,14 @@ extern "C" { #endif /* -** Copyright (c) 2007-2011 The Khronos Group Inc. +** THIS FILE IS OBSOLETE. Please migrate away from using the +** ".spec" files and the headers generated from them to the +** XML Registry and headers generated from that. See +** http://www.opengl.org/registry/api/README.txt +** for more information. +** +** +** Copyright (c) 2007-2013 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -29,9 +36,9 @@ extern "C" { */ /* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated $Date: 2011-10-02 22:22:16 -0700 (Sun, 02 Oct 2011) $ */ +/* glext.h last updated $Date: 2013-06-13 02:52:31 -0700 (Thu, 13 Jun 2013) $ */ /* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 73 +#define GL_GLEXT_VERSION 87 /* Function declaration macros - to move into glplatform.h */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -88,9 +95,6 @@ extern "C" { #define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 #define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_VERSION_1_2_DEPRECATED #define GL_RESCALE_NORMAL 0x803A #define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 #define GL_SINGLE_COLOR 0x81F9 @@ -110,9 +114,6 @@ extern "C" { #define GL_BLEND_EQUATION 0x8009 #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B -#endif - -#ifndef GL_ARB_imaging_DEPRECATED #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 @@ -239,9 +240,6 @@ extern "C" { #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 #define GL_CLAMP_TO_BORDER 0x812D -#endif - -#ifndef GL_VERSION_1_3_DEPRECATED #define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 #define GL_MAX_TEXTURE_UNITS 0x84E2 #define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 @@ -298,9 +296,6 @@ extern "C" { #define GL_TEXTURE_DEPTH_SIZE 0x884A #define GL_TEXTURE_COMPARE_MODE 0x884C #define GL_TEXTURE_COMPARE_FUNC 0x884D -#endif - -#ifndef GL_VERSION_1_4_DEPRECATED #define GL_POINT_SIZE_MIN 0x8126 #define GL_POINT_SIZE_MAX 0x8127 #define GL_POINT_DISTANCE_ATTENUATION 0x8129 @@ -354,9 +349,7 @@ extern "C" { #define GL_DYNAMIC_READ 0x88E9 #define GL_DYNAMIC_COPY 0x88EA #define GL_SAMPLES_PASSED 0x8914 -#endif - -#ifndef GL_VERSION_1_5_DEPRECATED +#define GL_SRC1_ALPHA 0x8589 #define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 #define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 #define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 @@ -378,7 +371,6 @@ extern "C" { #define GL_SRC1_RGB 0x8581 #define GL_SRC2_RGB 0x8582 #define GL_SRC0_ALPHA 0x8588 -#define GL_SRC1_ALPHA 0x8589 #define GL_SRC2_ALPHA 0x858A #endif @@ -463,9 +455,6 @@ extern "C" { #define GL_STENCIL_BACK_REF 0x8CA3 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_VERSION_2_0_DEPRECATED #define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 #define GL_POINT_SPRITE 0x8861 #define GL_COORD_REPLACE 0x8862 @@ -489,9 +478,6 @@ extern "C" { #define GL_SRGB8_ALPHA8 0x8C43 #define GL_COMPRESSED_SRGB 0x8C48 #define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#endif - -#ifndef GL_VERSION_2_1_DEPRECATED #define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F #define GL_SLUMINANCE_ALPHA 0x8C44 #define GL_SLUMINANCE8_ALPHA8 0x8C45 @@ -518,7 +504,7 @@ extern "C" { #define GL_CONTEXT_FLAGS 0x821E #define GL_COMPRESSED_RED 0x8225 #define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 #define GL_RGBA32F 0x8814 #define GL_RGB32F 0x8815 #define GL_RGBA16F 0x881A @@ -726,9 +712,6 @@ extern "C" { /* reuse GL_RG32UI */ /* Reuse tokens from ARB_vertex_array_object */ /* reuse GL_VERTEX_ARRAY_BINDING */ -#endif - -#ifndef GL_VERSION_3_0_DEPRECATED #define GL_CLAMP_VERTEX_COLOR 0x891A #define GL_CLAMP_FRAGMENT_COLOR 0x891B #define GL_ALPHA_INTEGER 0x8D97 @@ -749,7 +732,6 @@ extern "C" { #define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B #define GL_TEXTURE_BINDING_BUFFER 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E #define GL_TEXTURE_RECTANGLE 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 @@ -935,7 +917,6 @@ extern "C" { /* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ /* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ /* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ -/* reuse GL_MAX_VERTEX_STREAMS */ /* Reuse tokens from ARB_gpu_shader_fp64 */ /* reuse GL_DOUBLE_VEC2 */ /* reuse GL_DOUBLE_VEC3 */ @@ -1015,10 +996,12 @@ extern "C" { /* reuse GL_MEDIUM_INT */ /* reuse GL_HIGH_INT */ /* reuse GL_SHADER_COMPILER */ +/* reuse GL_SHADER_BINARY_FORMATS */ /* reuse GL_NUM_SHADER_BINARY_FORMATS */ /* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ /* reuse GL_MAX_VARYING_VECTORS */ /* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ +/* reuse GL_RGB565 */ /* Reuse tokens from ARB_get_program_binary */ /* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ /* reuse GL_PROGRAM_BINARY_LENGTH */ @@ -1163,6 +1146,290 @@ extern "C" { /* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ #endif +#ifndef GL_VERSION_4_3 +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +/* Reuse tokens from ARB_arrays_of_arrays (none, GLSL only) */ +/* Reuse tokens from ARB_fragment_layer_viewport (none, GLSL only) */ +/* Reuse tokens from ARB_shader_image_size (none, GLSL only) */ +/* Reuse tokens from ARB_ES3_compatibility */ +/* reuse GL_COMPRESSED_RGB8_ETC2 */ +/* reuse GL_COMPRESSED_SRGB8_ETC2 */ +/* reuse GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ +/* reuse GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ +/* reuse GL_COMPRESSED_RGBA8_ETC2_EAC */ +/* reuse GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC */ +/* reuse GL_COMPRESSED_R11_EAC */ +/* reuse GL_COMPRESSED_SIGNED_R11_EAC */ +/* reuse GL_COMPRESSED_RG11_EAC */ +/* reuse GL_COMPRESSED_SIGNED_RG11_EAC */ +/* reuse GL_PRIMITIVE_RESTART_FIXED_INDEX */ +/* reuse GL_ANY_SAMPLES_PASSED_CONSERVATIVE */ +/* reuse GL_MAX_ELEMENT_INDEX */ +/* Reuse tokens from ARB_clear_buffer_object (none) */ +/* Reuse tokens from ARB_compute_shader */ +/* reuse GL_COMPUTE_SHADER */ +/* reuse GL_MAX_COMPUTE_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_COMPUTE_IMAGE_UNIFORMS */ +/* reuse GL_MAX_COMPUTE_SHARED_MEMORY_SIZE */ +/* reuse GL_MAX_COMPUTE_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTERS */ +/* reuse GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMPUTE_LOCAL_INVOCATIONS */ +/* reuse GL_MAX_COMPUTE_WORK_GROUP_COUNT */ +/* reuse GL_MAX_COMPUTE_WORK_GROUP_SIZE */ +/* reuse GL_COMPUTE_LOCAL_WORK_SIZE */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_DISPATCH_INDIRECT_BUFFER */ +/* reuse GL_DISPATCH_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_copy_image (none) */ +/* Reuse tokens from KHR_debug */ +/* reuse GL_DEBUG_OUTPUT_SYNCHRONOUS */ +/* reuse GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH */ +/* reuse GL_DEBUG_CALLBACK_FUNCTION */ +/* reuse GL_DEBUG_CALLBACK_USER_PARAM */ +/* reuse GL_DEBUG_SOURCE_API */ +/* reuse GL_DEBUG_SOURCE_WINDOW_SYSTEM */ +/* reuse GL_DEBUG_SOURCE_SHADER_COMPILER */ +/* reuse GL_DEBUG_SOURCE_THIRD_PARTY */ +/* reuse GL_DEBUG_SOURCE_APPLICATION */ +/* reuse GL_DEBUG_SOURCE_OTHER */ +/* reuse GL_DEBUG_TYPE_ERROR */ +/* reuse GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR */ +/* reuse GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR */ +/* reuse GL_DEBUG_TYPE_PORTABILITY */ +/* reuse GL_DEBUG_TYPE_PERFORMANCE */ +/* reuse GL_DEBUG_TYPE_OTHER */ +/* reuse GL_MAX_DEBUG_MESSAGE_LENGTH */ +/* reuse GL_MAX_DEBUG_LOGGED_MESSAGES */ +/* reuse GL_DEBUG_LOGGED_MESSAGES */ +/* reuse GL_DEBUG_SEVERITY_HIGH */ +/* reuse GL_DEBUG_SEVERITY_MEDIUM */ +/* reuse GL_DEBUG_SEVERITY_LOW */ +/* reuse GL_DEBUG_TYPE_MARKER */ +/* reuse GL_DEBUG_TYPE_PUSH_GROUP */ +/* reuse GL_DEBUG_TYPE_POP_GROUP */ +/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */ +/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_BUFFER */ +/* reuse GL_SHADER */ +/* reuse GL_PROGRAM */ +/* reuse GL_QUERY */ +/* reuse GL_PROGRAM_PIPELINE */ +/* reuse GL_SAMPLER */ +/* reuse GL_DISPLAY_LIST */ +/* reuse GL_MAX_LABEL_LENGTH */ +/* reuse GL_DEBUG_OUTPUT */ +/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */ +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +/* Reuse tokens from ARB_explicit_uniform_location */ +/* reuse GL_MAX_UNIFORM_LOCATIONS */ +/* Reuse tokens from ARB_framebuffer_no_attachments */ +/* reuse GL_FRAMEBUFFER_DEFAULT_WIDTH */ +/* reuse GL_FRAMEBUFFER_DEFAULT_HEIGHT */ +/* reuse GL_FRAMEBUFFER_DEFAULT_LAYERS */ +/* reuse GL_FRAMEBUFFER_DEFAULT_SAMPLES */ +/* reuse GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_MAX_FRAMEBUFFER_WIDTH */ +/* reuse GL_MAX_FRAMEBUFFER_HEIGHT */ +/* reuse GL_MAX_FRAMEBUFFER_LAYERS */ +/* reuse GL_MAX_FRAMEBUFFER_SAMPLES */ +/* Reuse tokens from ARB_internalformat_query2 */ +/* reuse GL_INTERNALFORMAT_SUPPORTED */ +/* reuse GL_INTERNALFORMAT_PREFERRED */ +/* reuse GL_INTERNALFORMAT_RED_SIZE */ +/* reuse GL_INTERNALFORMAT_GREEN_SIZE */ +/* reuse GL_INTERNALFORMAT_BLUE_SIZE */ +/* reuse GL_INTERNALFORMAT_ALPHA_SIZE */ +/* reuse GL_INTERNALFORMAT_DEPTH_SIZE */ +/* reuse GL_INTERNALFORMAT_STENCIL_SIZE */ +/* reuse GL_INTERNALFORMAT_SHARED_SIZE */ +/* reuse GL_INTERNALFORMAT_RED_TYPE */ +/* reuse GL_INTERNALFORMAT_GREEN_TYPE */ +/* reuse GL_INTERNALFORMAT_BLUE_TYPE */ +/* reuse GL_INTERNALFORMAT_ALPHA_TYPE */ +/* reuse GL_INTERNALFORMAT_DEPTH_TYPE */ +/* reuse GL_INTERNALFORMAT_STENCIL_TYPE */ +/* reuse GL_MAX_WIDTH */ +/* reuse GL_MAX_HEIGHT */ +/* reuse GL_MAX_DEPTH */ +/* reuse GL_MAX_LAYERS */ +/* reuse GL_MAX_COMBINED_DIMENSIONS */ +/* reuse GL_COLOR_COMPONENTS */ +/* reuse GL_DEPTH_COMPONENTS */ +/* reuse GL_STENCIL_COMPONENTS */ +/* reuse GL_COLOR_RENDERABLE */ +/* reuse GL_DEPTH_RENDERABLE */ +/* reuse GL_STENCIL_RENDERABLE */ +/* reuse GL_FRAMEBUFFER_RENDERABLE */ +/* reuse GL_FRAMEBUFFER_RENDERABLE_LAYERED */ +/* reuse GL_FRAMEBUFFER_BLEND */ +/* reuse GL_READ_PIXELS */ +/* reuse GL_READ_PIXELS_FORMAT */ +/* reuse GL_READ_PIXELS_TYPE */ +/* reuse GL_TEXTURE_IMAGE_FORMAT */ +/* reuse GL_TEXTURE_IMAGE_TYPE */ +/* reuse GL_GET_TEXTURE_IMAGE_FORMAT */ +/* reuse GL_GET_TEXTURE_IMAGE_TYPE */ +/* reuse GL_MIPMAP */ +/* reuse GL_MANUAL_GENERATE_MIPMAP */ +/* reuse GL_AUTO_GENERATE_MIPMAP */ +/* reuse GL_COLOR_ENCODING */ +/* reuse GL_SRGB_READ */ +/* reuse GL_SRGB_WRITE */ +/* reuse GL_FILTER */ +/* reuse GL_VERTEX_TEXTURE */ +/* reuse GL_TESS_CONTROL_TEXTURE */ +/* reuse GL_TESS_EVALUATION_TEXTURE */ +/* reuse GL_GEOMETRY_TEXTURE */ +/* reuse GL_FRAGMENT_TEXTURE */ +/* reuse GL_COMPUTE_TEXTURE */ +/* reuse GL_TEXTURE_SHADOW */ +/* reuse GL_TEXTURE_GATHER */ +/* reuse GL_TEXTURE_GATHER_SHADOW */ +/* reuse GL_SHADER_IMAGE_LOAD */ +/* reuse GL_SHADER_IMAGE_STORE */ +/* reuse GL_SHADER_IMAGE_ATOMIC */ +/* reuse GL_IMAGE_TEXEL_SIZE */ +/* reuse GL_IMAGE_COMPATIBILITY_CLASS */ +/* reuse GL_IMAGE_PIXEL_FORMAT */ +/* reuse GL_IMAGE_PIXEL_TYPE */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_SIZE */ +/* reuse GL_CLEAR_BUFFER */ +/* reuse GL_TEXTURE_VIEW */ +/* reuse GL_VIEW_COMPATIBILITY_CLASS */ +/* reuse GL_FULL_SUPPORT */ +/* reuse GL_CAVEAT_SUPPORT */ +/* reuse GL_IMAGE_CLASS_4_X_32 */ +/* reuse GL_IMAGE_CLASS_2_X_32 */ +/* reuse GL_IMAGE_CLASS_1_X_32 */ +/* reuse GL_IMAGE_CLASS_4_X_16 */ +/* reuse GL_IMAGE_CLASS_2_X_16 */ +/* reuse GL_IMAGE_CLASS_1_X_16 */ +/* reuse GL_IMAGE_CLASS_4_X_8 */ +/* reuse GL_IMAGE_CLASS_2_X_8 */ +/* reuse GL_IMAGE_CLASS_1_X_8 */ +/* reuse GL_IMAGE_CLASS_11_11_10 */ +/* reuse GL_IMAGE_CLASS_10_10_10_2 */ +/* reuse GL_VIEW_CLASS_128_BITS */ +/* reuse GL_VIEW_CLASS_96_BITS */ +/* reuse GL_VIEW_CLASS_64_BITS */ +/* reuse GL_VIEW_CLASS_48_BITS */ +/* reuse GL_VIEW_CLASS_32_BITS */ +/* reuse GL_VIEW_CLASS_24_BITS */ +/* reuse GL_VIEW_CLASS_16_BITS */ +/* reuse GL_VIEW_CLASS_8_BITS */ +/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGB */ +/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGBA */ +/* reuse GL_VIEW_CLASS_S3TC_DXT3_RGBA */ +/* reuse GL_VIEW_CLASS_S3TC_DXT5_RGBA */ +/* reuse GL_VIEW_CLASS_RGTC1_RED */ +/* reuse GL_VIEW_CLASS_RGTC2_RG */ +/* reuse GL_VIEW_CLASS_BPTC_UNORM */ +/* reuse GL_VIEW_CLASS_BPTC_FLOAT */ +/* Reuse tokens from ARB_invalidate_subdata (none) */ +/* Reuse tokens from ARB_multi_draw_indirect (none) */ +/* Reuse tokens from ARB_program_interface_query */ +/* reuse GL_UNIFORM */ +/* reuse GL_UNIFORM_BLOCK */ +/* reuse GL_PROGRAM_INPUT */ +/* reuse GL_PROGRAM_OUTPUT */ +/* reuse GL_BUFFER_VARIABLE */ +/* reuse GL_SHADER_STORAGE_BLOCK */ +/* reuse GL_VERTEX_SUBROUTINE */ +/* reuse GL_TESS_CONTROL_SUBROUTINE */ +/* reuse GL_TESS_EVALUATION_SUBROUTINE */ +/* reuse GL_GEOMETRY_SUBROUTINE */ +/* reuse GL_FRAGMENT_SUBROUTINE */ +/* reuse GL_COMPUTE_SUBROUTINE */ +/* reuse GL_VERTEX_SUBROUTINE_UNIFORM */ +/* reuse GL_TESS_CONTROL_SUBROUTINE_UNIFORM */ +/* reuse GL_TESS_EVALUATION_SUBROUTINE_UNIFORM */ +/* reuse GL_GEOMETRY_SUBROUTINE_UNIFORM */ +/* reuse GL_FRAGMENT_SUBROUTINE_UNIFORM */ +/* reuse GL_COMPUTE_SUBROUTINE_UNIFORM */ +/* reuse GL_TRANSFORM_FEEDBACK_VARYING */ +/* reuse GL_ACTIVE_RESOURCES */ +/* reuse GL_MAX_NAME_LENGTH */ +/* reuse GL_MAX_NUM_ACTIVE_VARIABLES */ +/* reuse GL_MAX_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_NAME_LENGTH */ +/* reuse GL_TYPE */ +/* reuse GL_ARRAY_SIZE */ +/* reuse GL_OFFSET */ +/* reuse GL_BLOCK_INDEX */ +/* reuse GL_ARRAY_STRIDE */ +/* reuse GL_MATRIX_STRIDE */ +/* reuse GL_IS_ROW_MAJOR */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_INDEX */ +/* reuse GL_BUFFER_BINDING */ +/* reuse GL_BUFFER_DATA_SIZE */ +/* reuse GL_NUM_ACTIVE_VARIABLES */ +/* reuse GL_ACTIVE_VARIABLES */ +/* reuse GL_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_REFERENCED_BY_GEOMETRY_SHADER */ +/* reuse GL_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_TOP_LEVEL_ARRAY_SIZE */ +/* reuse GL_TOP_LEVEL_ARRAY_STRIDE */ +/* reuse GL_LOCATION */ +/* reuse GL_LOCATION_INDEX */ +/* reuse GL_IS_PER_PATCH */ +/* Reuse tokens from ARB_robust_buffer_access_behavior (none) */ +/* Reuse tokens from ARB_shader_storage_buffer_object */ +/* reuse GL_SHADER_STORAGE_BUFFER */ +/* reuse GL_SHADER_STORAGE_BUFFER_BINDING */ +/* reuse GL_SHADER_STORAGE_BUFFER_START */ +/* reuse GL_SHADER_STORAGE_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS */ +/* reuse GL_MAX_SHADER_STORAGE_BLOCK_SIZE */ +/* reuse GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_SHADER_STORAGE_BARRIER_BIT */ +/* reuse GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES */ +/* Reuse tokens from ARB_stencil_texturing */ +/* reuse GL_DEPTH_STENCIL_TEXTURE_MODE */ +/* Reuse tokens from ARB_texture_buffer_range */ +/* reuse GL_TEXTURE_BUFFER_OFFSET */ +/* reuse GL_TEXTURE_BUFFER_SIZE */ +/* reuse GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT */ +/* Reuse tokens from ARB_texture_query_levels (none) */ +/* Reuse tokens from ARB_texture_storage_multisample (none) */ +/* Reuse tokens from ARB_texture_view */ +/* reuse GL_TEXTURE_VIEW_MIN_LEVEL */ +/* reuse GL_TEXTURE_VIEW_NUM_LEVELS */ +/* reuse GL_TEXTURE_VIEW_MIN_LAYER */ +/* reuse GL_TEXTURE_VIEW_NUM_LAYERS */ +/* reuse GL_TEXTURE_IMMUTABLE_LEVELS */ +/* Reuse tokens from ARB_vertex_attrib_binding */ +/* reuse GL_VERTEX_ATTRIB_BINDING */ +/* reuse GL_VERTEX_ATTRIB_RELATIVE_OFFSET */ +/* reuse GL_VERTEX_BINDING_DIVISOR */ +/* reuse GL_VERTEX_BINDING_OFFSET */ +/* reuse GL_VERTEX_BINDING_STRIDE */ +/* reuse GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET */ +/* reuse GL_MAX_VERTEX_ATTRIB_BINDINGS */ +#endif + #ifndef GL_ARB_multitexture #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 @@ -1692,7 +1959,7 @@ extern "C" { #define GL_TEXTURE_DEPTH_TYPE 0x8C16 #define GL_UNSIGNED_NORMALIZED 0x8C17 #define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 #define GL_RENDERBUFFER_BINDING 0x8CA7 #define GL_READ_FRAMEBUFFER 0x8CA8 #define GL_DRAW_FRAMEBUFFER 0x8CA9 @@ -1745,9 +2012,6 @@ extern "C" { #define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 #define GL_MAX_SAMPLES 0x8D57 -#endif - -#ifndef GL_ARB_framebuffer_object_DEPRECATED #define GL_INDEX 0x8222 #define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 #define GL_TEXTURE_INTENSITY_TYPE 0x8C15 @@ -1882,7 +2146,9 @@ extern "C" { #endif #ifndef GL_ARB_copy_buffer +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 #define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 #define GL_COPY_WRITE_BUFFER 0x8F37 #endif @@ -1977,6 +2243,7 @@ extern "C" { #ifndef GL_ARB_texture_gather #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F #endif #ifndef GL_ARB_texture_query_lod @@ -2131,7 +2398,9 @@ extern "C" { #ifndef GL_ARB_transform_feedback2 #define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 #define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 #define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 #define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 #endif @@ -2152,10 +2421,12 @@ extern "C" { #define GL_MEDIUM_INT 0x8DF4 #define GL_HIGH_INT 0x8DF5 #define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB #define GL_MAX_VARYING_VECTORS 0x8DFC #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 #endif #ifndef GL_ARB_get_program_binary @@ -2393,6 +2664,386 @@ extern "C" { #define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F #endif +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + +#ifndef GL_KHR_debug +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_DISPLAY_LIST 0x82E7 +/* DISPLAY_LIST used in compatibility profile only */ +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +#endif + +#ifndef GL_ARB_arrays_of_arrays +#endif + +#ifndef GL_ARB_clear_buffer_object +#endif + +#ifndef GL_ARB_compute_shader +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif + +#ifndef GL_ARB_copy_image +#endif + +#ifndef GL_ARB_texture_view +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#endif + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#endif + +#ifndef GL_ARB_robustness_isolation +#endif + +#ifndef GL_ARB_ES3_compatibility +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif + +#ifndef GL_ARB_explicit_uniform_location +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#endif + +#ifndef GL_ARB_fragment_layer_viewport +#endif + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#endif + +#ifndef GL_ARB_internalformat_query2 +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ +/* reuse GL_NUM_SAMPLE_COUNTS */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_SAMPLES */ +/* reuse GL_TEXTURE_1D */ +/* reuse GL_TEXTURE_1D_ARRAY */ +/* reuse GL_TEXTURE_2D */ +/* reuse GL_TEXTURE_2D_ARRAY */ +/* reuse GL_TEXTURE_3D */ +/* reuse GL_TEXTURE_CUBE_MAP */ +/* reuse GL_TEXTURE_CUBE_MAP_ARRAY */ +/* reuse GL_TEXTURE_RECTANGLE */ +/* reuse GL_TEXTURE_BUFFER */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_COMPRESSED */ +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_SRGB_DECODE_ARB 0x8299 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#endif + +#ifndef GL_ARB_invalidate_subdata +#endif + +#ifndef GL_ARB_multi_draw_indirect +#endif + +#ifndef GL_ARB_program_interface_query +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +/* reuse GL_ATOMIC_COUNTER_BUFFER */ +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +#endif + +#ifndef GL_ARB_robust_buffer_access_behavior +#endif + +#ifndef GL_ARB_shader_image_size +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ +#endif + +#ifndef GL_ARB_stencil_texturing +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#endif + +#ifndef GL_ARB_texture_buffer_range +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#endif + +#ifndef GL_ARB_texture_query_levels +#endif + +#ifndef GL_ARB_texture_storage_multisample +#endif + #ifndef GL_EXT_abgr #define GL_ABGR_EXT 0x8000 #endif @@ -2831,12 +3482,9 @@ extern "C" { #ifndef GL_SGIX_tag_sample_buffer #endif -#ifndef GL_FfdMaskSGIX +#ifndef GL_SGIX_polynomial_ffd #define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 #define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd #define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 #define GL_TEXTURE_DEFORMATION_SGIX 0x8195 #define GL_DEFORMATIONS_MASK_SGIX 0x8196 @@ -2908,6 +3556,8 @@ extern "C" { #define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B #define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C #define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 #define GL_COLOR3_BIT_PGI 0x00010000 #define GL_COLOR4_BIT_PGI 0x00020000 #define GL_EDGEFLAG_BIT_PGI 0x00040000 @@ -2924,8 +3574,6 @@ extern "C" { #define GL_TEXCOORD2_BIT_PGI 0x20000000 #define GL_TEXCOORD3_BIT_PGI 0x40000000 #define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 #endif #ifndef GL_PGI_misc_hints @@ -3094,16 +3742,6 @@ extern "C" { #define GL_ALPHA_MAX_SGIX 0x8321 #endif -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - #ifndef GL_EXT_bgra #define GL_BGR_EXT 0x80E0 #define GL_BGRA_EXT 0x80E1 @@ -3251,11 +3889,6 @@ extern "C" { #define GL_TRANSFORM_HINT_APPLE 0x85B1 #endif -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - #ifndef GL_SUNX_constant_data #define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 #define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 @@ -3362,12 +3995,12 @@ extern "C" { #endif #ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 #define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 #define GL_MODELVIEW1_MATRIX_EXT 0x8506 #define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW0_EXT 0x1700 #define GL_MODELVIEW1_EXT 0x850A #define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B #define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C @@ -3528,12 +4161,6 @@ extern "C" { #define GL_YCRCBA_SGIX 0x8319 #endif -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - #ifndef GL_3DFX_texture_compression_FXT1 #define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 #define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 @@ -3617,6 +4244,11 @@ extern "C" { #define GL_FENCE_CONDITION_NV 0x84F4 #endif +#ifndef GL_IBM_static_data +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +#endif + #ifndef GL_IBM_texture_mirrored_repeat #define GL_MIRRORED_REPEAT_IBM 0x8370 #endif @@ -3680,11 +4312,11 @@ extern "C" { #define GL_SHADER_OPERATION_NV 0x86DF #define GL_CULL_MODES_NV 0x86E0 #define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 #define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 #define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 #define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 #define GL_CONST_EYE_NV 0x86E5 #define GL_PASS_THROUGH_NV 0x86E6 @@ -4249,6 +4881,8 @@ extern "C" { #define GL_RGB4_S3TC 0x83A1 #define GL_RGBA_S3TC 0x83A2 #define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 #endif #ifndef GL_ATI_draw_buffers @@ -4272,7 +4906,7 @@ extern "C" { #endif #ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 #define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 #endif @@ -4362,11 +4996,37 @@ extern "C" { #ifndef GL_ATI_vertex_attrib_array_object #endif +#ifndef GL_OES_byte_coordinates +#endif + +#ifndef GL_OES_fixed_point +#define GL_FIXED_OES 0x140C +#endif + +#ifndef GL_OES_single_precision +#endif + +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + #ifndef GL_OES_read_format #define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A #define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B #endif +#ifndef GL_OES_query_matrix +#endif + #ifndef GL_EXT_depth_bounds_test #define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 #define GL_DEPTH_BOUNDS_EXT 0x8891 @@ -4511,7 +5171,7 @@ extern "C" { #ifndef GL_EXT_framebuffer_blit #define GL_READ_FRAMEBUFFER_EXT 0x8CA8 #define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 #define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA #endif @@ -4732,7 +5392,7 @@ extern "C" { #define GL_PRIMITIVES_GENERATED_NV 0x8C87 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 #define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B #define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C #define GL_SEPARATE_ATTRIBS_NV 0x8C8D @@ -4899,7 +5559,7 @@ extern "C" { #ifndef GL_AMD_texture_texture4 #endif -#ifndef GL_AMD_vertex_shader_tesselator +#ifndef GL_AMD_vertex_shader_tessellator #define GL_SAMPLER_BUFFER_AMD 0x9001 #define GL_INT_SAMPLER_BUFFER_AMD 0x9002 #define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 @@ -5236,8 +5896,8 @@ extern "C" { #endif #ifndef GL_NV_multisample_coverage -#define GL_COVERAGE_SAMPLES_NV 0x80A9 #define GL_COLOR_SAMPLES_NV 0x8E20 +/* reuse GL_SAMPLES_ARB */ #endif #ifndef GL_AMD_name_gen_delete @@ -5249,6 +5909,7 @@ extern "C" { #endif #ifndef GL_AMD_debug_output +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 #define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 #define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 @@ -5311,6 +5972,212 @@ extern "C" { #define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB #endif +#ifndef GL_NV_path_rendering +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +/* reuse GL_PRIMARY_COLOR */ +/* reuse GL_PRIMARY_COLOR_NV */ +/* reuse GL_SECONDARY_COLOR_NV */ +#endif + +#ifndef GL_AMD_pinned_memory +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif + +#ifndef GL_AMD_stencil_operation_extended +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +#endif + +#ifndef GL_AMD_vertex_shader_viewport_index +#endif + +#ifndef GL_AMD_vertex_shader_layer +#endif + +#ifndef GL_NV_bindless_texture +#endif + +#ifndef GL_NV_shader_atomic_float +#endif + +#ifndef GL_AMD_query_buffer_object +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif + +#ifndef GL_NV_compute_program5 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif + +#ifndef GL_NV_shader_storage_buffer_object +#endif + +#ifndef GL_NV_shader_atomic_counters +#endif + +#ifndef GL_NV_deep_texture3D +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif + +#ifndef GL_NVX_conditional_render +#endif + +#ifndef GL_AMD_sparse_texture +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +#endif + +#ifndef GL_AMD_shader_trinary_minmax +#endif + +#ifndef GL_INTEL_map_texture +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +#endif + +#ifndef GL_NV_draw_texture +#endif + /*************************************************************/ @@ -5410,31 +6277,28 @@ typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLen typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); #endif +#ifndef GL_KHR_debug +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + #ifndef GL_NV_vdpau_interop typedef GLintptr GLvdpauSurfaceNV; #endif +#ifndef GL_OES_fixed_point +/* GLint must be 32 bits, a relatively safe assumption on modern CPUs */ +typedef GLint GLfixed; +#endif + #ifndef GL_VERSION_1_2 #define GL_VERSION_1_2 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GLAPI void APIENTRY glBlendEquation (GLenum mode); GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_2_DEPRECATED -#define GL_VERSION_1_2_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); @@ -5468,6 +6332,12 @@ GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean si GLAPI void APIENTRY glResetHistogram (GLenum target); GLAPI void APIENTRY glResetMinmax (GLenum target); #endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); @@ -5506,7 +6376,7 @@ typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); #define GL_VERSION_1_3 1 #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glActiveTexture (GLenum texture); -GLAPI void APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); @@ -5514,21 +6384,6 @@ GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_3_DEPRECATED -#define GL_VERSION_1_3_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glClientActiveTexture (GLenum texture); GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); @@ -5567,6 +6422,15 @@ GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); #endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); @@ -5610,25 +6474,12 @@ typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); #define GL_VERSION_1_4 1 #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_VERSION_1_4_DEPRECATED -#define GL_VERSION_1_4_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFogCoordf (GLfloat coord); GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); GLAPI void APIENTRY glFogCoordd (GLdouble coord); @@ -5668,6 +6519,13 @@ GLAPI void APIENTRY glWindowPos3iv (const GLint *v); GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); #endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); @@ -5789,7 +6647,7 @@ GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoi GLAPI GLboolean APIENTRY glIsProgram (GLuint program); GLAPI GLboolean APIENTRY glIsShader (GLuint shader); GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); GLAPI void APIENTRY glUseProgram (GLuint program); GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); @@ -5883,7 +6741,7 @@ typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); @@ -5979,7 +6837,7 @@ GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); GLAPI void APIENTRY glEndTransformFeedback (void); GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); @@ -6038,7 +6896,7 @@ typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); @@ -6094,13 +6952,13 @@ typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint ind /* ARB_copy_buffer */ /* ARB_uniform_buffer_object */ #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); #endif @@ -6155,13 +7013,13 @@ typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divi /* ARB_transform_feedback2 */ /* ARB_transform_feedback3 */ #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShading (GLclampf value); +GLAPI void APIENTRY glMinSampleShading (GLfloat value); GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLclampf value); +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); @@ -6195,6 +7053,33 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, /* ARB_texture_storage */ #endif +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +/* OpenGL 4.3 reuses entry points from these extensions: */ +/* ARB_arrays_of_arrays (no entry points, GLSL only) */ +/* ARB_fragment_layer_viewport (no entry points, GLSL only) */ +/* ARB_shader_image_size (no entry points, GLSL only) */ +/* ARB_ES3_compatibility (no entry points) */ +/* ARB_clear_buffer_object */ +/* ARB_compute_shader */ +/* ARB_copy_image */ +/* KHR_debug (includes ARB_debug_output commands promoted to KHR without suffixes) */ +/* ARB_explicit_uniform_location (no entry points) */ +/* ARB_framebuffer_no_attachments */ +/* ARB_internalformat_query2 */ +/* ARB_invalidate_subdata */ +/* ARB_multi_draw_indirect */ +/* ARB_program_interface_query */ +/* ARB_robust_buffer_access_behavior (no entry points) */ +/* ARB_shader_storage_buffer_object */ +/* ARB_stencil_texturing (no entry points) */ +/* ARB_texture_buffer_range */ +/* ARB_texture_query_levels (no entry points) */ +/* ARB_texture_storage_multisample */ +/* ARB_texture_view */ +/* ARB_vertex_attrib_binding */ +#endif + #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 #ifdef GL_GLEXT_PROTOTYPES @@ -6286,9 +7171,9 @@ typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); #ifndef GL_ARB_multisample #define GL_ARB_multisample 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); #endif #ifndef GL_ARB_texture_env_add @@ -6907,7 +7792,7 @@ typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); #ifndef GL_ARB_uniform_buffer_object #define GL_ARB_uniform_buffer_object 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); @@ -6915,7 +7800,7 @@ GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlo GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); @@ -6949,13 +7834,13 @@ typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum w #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); #endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); #endif #ifndef GL_ARB_fragment_coord_conventions @@ -7029,9 +7914,9 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcR #ifndef GL_ARB_sample_shading #define GL_ARB_sample_shading 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShadingARB (GLclampf value); +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); #endif #ifndef GL_ARB_texture_cube_map_array @@ -7358,14 +8243,14 @@ typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index GLAPI void APIENTRY glReleaseShaderCompiler (void); GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -GLAPI void APIENTRY glDepthRangef (GLclampf n, GLclampf f); -GLAPI void APIENTRY glClearDepthf (GLclampf d); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); #endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLclampf d); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); #endif #ifndef GL_ARB_get_program_binary @@ -7385,7 +8270,7 @@ typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pnam #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* *strings); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* const *strings); GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); @@ -7446,7 +8331,7 @@ GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSiz #endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* *strings); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* const *strings); typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); @@ -7541,8 +8426,8 @@ GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); -GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLclampd *v); -GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLclampd n, GLclampd f); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); #endif /* GL_GLEXT_PROTOTYPES */ @@ -7552,8 +8437,8 @@ typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); #endif @@ -7633,13 +8518,13 @@ typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint locati #ifndef GL_ARB_base_instance #define GL_ARB_base_instance 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); #endif #ifndef GL_ARB_shading_language_420pack @@ -7649,11 +8534,11 @@ typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (G #ifndef GL_ARB_transform_feedback_instanced #define GL_ARB_transform_feedback_instanced 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #endif #ifndef GL_ARB_compressed_texture_pixel_storage @@ -7716,6 +8601,242 @@ typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum ta typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #endif +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +#endif + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +#endif + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +#endif + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#endif + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif + #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #endif @@ -7723,9 +8844,9 @@ typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum ta #ifndef GL_EXT_blend_color #define GL_EXT_blend_color 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #endif #ifndef GL_EXT_polygon_offset @@ -8044,8 +9165,9 @@ typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); #define GL_SGIX_pixel_tiles 1 #endif -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +/* This used to be SGIX prefix, which was an error in the header */ #endif #ifndef GL_SGIX_sprite @@ -8457,11 +9579,15 @@ GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); #endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); #endif #ifndef GL_EXT_pixel_transform_color_table @@ -8813,11 +9939,11 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLen #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); #endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); #endif #ifndef GL_NV_light_max_exponent @@ -8944,6 +10070,10 @@ typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); #endif +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#endif + #ifndef GL_IBM_cull_vertex #define GL_IBM_cull_vertex 1 #endif @@ -9082,6 +10212,18 @@ typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); #endif +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#endif + #ifndef GL_NV_evaluators #define GL_NV_evaluators 1 #ifdef GL_GLEXT_PROTOTYPES @@ -9766,15 +10908,15 @@ typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs) /* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); #endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); @@ -9881,10 +11023,10 @@ typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, c #ifndef GL_NV_pixel_data_range #define GL_NV_pixel_data_range 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const GLvoid *pointer); GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const GLvoid *pointer); typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); #endif @@ -9938,10 +11080,304 @@ typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); #endif +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#endif + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#endif + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); +GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +#endif + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#endif + #ifndef GL_OES_read_format #define GL_OES_read_format 1 #endif +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#endif + #ifndef GL_EXT_depth_bounds_test #define GL_EXT_depth_bounds_test 1 #ifdef GL_GLEXT_PROTOTYPES @@ -10317,13 +11753,13 @@ typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLen #ifndef GL_NV_parameter_buffer_object #define GL_NV_parameter_buffer_object 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); #endif #ifndef GL_EXT_draw_buffers2 @@ -10954,8 +12390,8 @@ typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, #define GL_AMD_texture_texture4 1 #endif -#ifndef GL_AMD_vertex_shader_tesselator -#define GL_AMD_vertex_shader_tesselator 1 +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); @@ -11393,7 +12829,7 @@ typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); GLAPI void APIENTRY glVDPAUFiniNV (void); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); @@ -11404,7 +12840,7 @@ GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSur #endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); @@ -11478,6 +12914,230 @@ typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLe #define GL_EXT_framebuffer_multisample_blit_scaled 1 #endif +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#endif + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#endif + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#endif + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#endif + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#endif + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#endif + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#endif + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI GLvoid* APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef GLvoid* (APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout); +#endif + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif + #ifdef __cplusplus } diff --git a/Utilities/Array.h b/Utilities/Array.h index 45961bd7cd..11439694e9 100644 --- a/Utilities/Array.h +++ b/Utilities/Array.h @@ -2,6 +2,7 @@ template class Array { +protected: u32 m_count; T* m_array; @@ -87,11 +88,14 @@ public: return m_count - 1; } - inline bool AddCpy(const u32 pos, const T* data, u64 count = 1) + inline bool AddCpy(const u32 pos, const T* data, u32 count = 1) { if(!InsertRoom(pos, count)) return false; - memcpy(m_array + pos, data, sizeof(T) * count); + for(u32 i=0; i= count) return; - - _InsertRoomEnd(count - GetCount()); + if(m_count >= count) return; - if(memzero) memset(m_array + GetCount(), 0, count - GetCount()); + _InsertRoomEnd(count - m_count); + + if(memzero) memset(m_array + m_count - count, 0, sizeof(T) * (m_count - count)); } void Reserve(const u32 count) @@ -162,6 +175,7 @@ public: } inline T* GetPtr() { return m_array; } + inline const T* GetPtr() const { return m_array; } T& operator[](u32 num) const { return m_array[num]; } @@ -185,6 +199,96 @@ protected: } }; +class ArrayString : public Array +{ +public: + ArrayString() : Array() + { + } + + ArrayString(const wxString& value) : Array() + { + *this = value; + } + + ArrayString(const char* value) : Array() + { + *this = value; + } + + virtual u32 GetCount() const + { + return m_array ? strlen(m_array) : 0; + } + + virtual void SetCount(const u32 count, bool memzero = true) + { + if(m_count && count < m_count - 1) + { + m_array[count] = '\0'; + } + else + { + Array::SetCount(count + 1, memzero); + } + } + + ArrayString& operator = (const char* right) + { + Clear(); + + if(right) + { + size_t len = strlen(right); + + if(len) + { + SetCount(len); + memcpy(m_array, right, len * sizeof(char)); + m_array[len] = '\0'; + } + } + + return *this; + } + + ArrayString& operator = (const ArrayString& right) + { + Clear(); + + if(size_t len = right.GetCount()) + { + SetCount(len); + memcpy(m_array, right.GetPtr(), len * sizeof(char)); + m_array[len] = '\0'; + } + + return *this; + } + + ArrayString& operator = (const wxString& right) + { + Clear(); + + if(size_t len = right.Len()) + { + SetCount(len); + memcpy(m_array, right.c_str(), len * sizeof(char)); + m_array[len] = '\0'; + } + + return *this; + } + + ArrayString* Clone() const + { + ArrayString* new_array = new ArrayString(); + (*new_array) = m_array; + + return new_array; + } +}; + template struct Stack : public Array { Stack() : Array() @@ -209,6 +313,61 @@ template struct Stack : public Array } }; +template class SizedStack +{ + T m_ptr[size]; + uint m_count; + +public: + SizedStack() + { + Clear(); + } + + ~SizedStack() + { + Clear(); + } + + void Clear() + { + m_count = 0; + } + + bool Pop(T& dst) + { + if(!m_count) + return false; + + dst = m_ptr[--m_count]; + return true; + } + + bool Push(const T& src) + { + if(m_count + 1 > size) + return false; + + m_ptr[m_count++] = src; + return true; + } + + size_t GetFreeCount() const + { + return size - m_count; + } + + size_t GetCount() const + { + return m_count; + } + + size_t GetMaxCount() const + { + return size; + } +}; + template class ArrayF { u32 m_count; diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 38f6807aeb..f98c22107b 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -1,5 +1,9 @@ #pragma once #include "Array.h" +#include +#include +#include +#include class ThreadExec; @@ -59,7 +63,7 @@ public: m_parent = nullptr; - //if(wait) + if(wait) { Delete(); //wxCriticalSectionLocker lock(m_wait_for_exit); diff --git a/bin/dev_hdd0/game/TEST12345/USRDIR/cube.elf b/bin/dev_hdd0/game/TEST12345/USRDIR/cube.elf new file mode 100644 index 0000000000..020b9b4ec2 Binary files /dev/null and b/bin/dev_hdd0/game/TEST12345/USRDIR/cube.elf differ diff --git a/bin/dev_hdd0/game/TEST12345/USRDIR/hello_world.elf b/bin/dev_hdd0/game/TEST12345/USRDIR/hello_world.elf new file mode 100644 index 0000000000..ecc3ccb41a Binary files /dev/null and b/bin/dev_hdd0/game/TEST12345/USRDIR/hello_world.elf differ diff --git a/rpcs3/Emu/Cell/MFC.cpp b/rpcs3/Emu/Cell/MFC.cpp new file mode 100644 index 0000000000..f63341b79c --- /dev/null +++ b/rpcs3/Emu/Cell/MFC.cpp @@ -0,0 +1,2 @@ +#include "stdafx.h" +#include "MFC.h" diff --git a/rpcs3/Emu/Cell/MFC.h b/rpcs3/Emu/Cell/MFC.h new file mode 100644 index 0000000000..7031505600 --- /dev/null +++ b/rpcs3/Emu/Cell/MFC.h @@ -0,0 +1,252 @@ +#pragma once +#include + +enum +{ + MFC_PUT_CMD = 0x20, + MFC_GET_CMD = 0x40, + MFC_MASK_CMD = 0xffff, +}; + +enum +{ + MFC_SPU_TO_PPU_MAILBOX_STATUS_MASK = 0x000000FF, + MFC_SPU_TO_PPU_MAILBOX_STATUS_SHIFT = 0x0, + MFC_PPU_TO_SPU_MAILBOX_STATUS_MASK = 0x0000FF00, + MFC_PPU_TO_SPU_MAILBOX_STATUS_SHIFT = 0x8, + MFC_PPU_TO_SPU_MAILBOX_MAX = 0x4, + MFC_SPU_TO_PPU_INT_MAILBOX_STATUS_MASK = 0x00FF0000, + MFC_SPU_TO_PPU_INT_MAILBOX_STATUS_SHIFT = 0x10, +}; + +enum +{ + MFC_PPU_DMA_CMD_ENQUEUE_SUCCESSFUL = 0x00, + MFC_PPU_DMA_CMD_SEQUENCE_ERROR = 0x01, + MFC_PPU_DMA_QUEUE_FULL = 0x02, +}; + +enum +{ + MFC_PPU_MAX_QUEUE_SPACE = 0x08, + MFC_SPU_MAX_QUEUE_SPACE = 0x10, +}; + +struct DMAC_Queue +{ + bool is_valid; + u64 ea; + u32 lsa; + u16 size; + u32 op; + u8 tag; + u8 rt; + u16 list_addr; + u16 list_size; + u32 dep_state; + u32 cmd; + u32 dep_type; +}; + +struct DMAC_Proxy +{ + u64 ea; + u32 lsa; + u16 size; + u32 op; + u8 tag; + u8 rt; + u16 list_addr; + u16 list_size; + u32 dep_state; + u32 cmd; + u32 dep_type; +}; + +template +class SPUReg +{ + u64 m_addr; + u32 m_pos; + +public: + static const size_t max_count = _max_count; + static const size_t size = max_count * 4; + + SPUReg() + { + Init(); + } + + void Init() + { + m_pos = 0; + } + + void SetAddr(u64 addr) + { + m_addr = addr; + } + + u64 GetAddr() const + { + return m_addr; + } + + __forceinline bool Pop(u32& res) + { + if(!m_pos) return false; + res = Memory.Read32(m_addr + m_pos--); + return true; + } + + __forceinline bool Push(u32 value) + { + if(m_pos >= max_count) return false; + Memory.Write32(m_addr + m_pos++, value); + return true; + } + + u32 GetCount() const + { + return m_pos; + } + + u32 GetFreeCount() const + { + return max_count - m_pos; + } + + void SetValue(u32 value) + { + Memory.Write32(m_addr, value); + } + + u32 GetValue() const + { + return Memory.Read32(m_addr); + } +}; + +struct DMAC +{ + DMAC_Queue queue[MFC_SPU_MAX_QUEUE_SPACE]; + DMAC_Proxy proxy[MFC_PPU_MAX_QUEUE_SPACE]; + u64 ls_offset; + std::atomic queue_pos; + std::atomic proxy_pos; + + u32 Cmd(u32 cmd, u32 tag, u32 lsa, u64 ea, u32 size) + { + if(!Memory.IsGoodAddr(ls_offset + lsa, size) || !Memory.IsGoodAddr(ea, size)) + { + return MFC_PPU_DMA_CMD_SEQUENCE_ERROR; + } + + if(proxy_pos >= MFC_PPU_MAX_QUEUE_SPACE) + { + return MFC_PPU_DMA_QUEUE_FULL; + } + + DMAC_Proxy& p = proxy[proxy_pos++]; + p.cmd = cmd; + p.tag = tag; + p.lsa = lsa; + p.ea = ea; + p.size = size; + + return MFC_PPU_DMA_CMD_ENQUEUE_SUCCESSFUL; + } + + void DoCmd() + { + if(proxy_pos) + { + DMAC_Proxy p = proxy[0]; + memcpy(proxy, proxy + 1, proxy_pos--); + + switch(p.cmd) + { + case MFC_PUT_CMD: + memcpy(Memory + ls_offset + p.lsa, Memory + p.ea, p.size); + break; + + case MFC_GET_CMD: + memcpy(Memory + p.ea, Memory + ls_offset + p.lsa, p.size); + break; + + default: + ConLog.Error("Unknown DMA cmd."); + break; + } + } + } +}; + +struct MFC +{ + SPUReg<1> MFC_LSA; + SPUReg<1> MFC_EAH; + SPUReg<1> MFC_EAL; + SPUReg<1> MFC_Size_Tag; + SPUReg<1> MFC_CMDStatus; + SPUReg<1> MFC_QStatus; + SPUReg<1> Prxy_QueryType; + SPUReg<1> Prxy_QueryMask; + SPUReg<1> Prxy_TagStatus; + SPUReg<1> SPU_Out_MBox; + SPUReg<4> SPU_In_MBox; + SPUReg<1> SPU_MBox_Status; + SPUReg<1> SPU_RunCntl; + SPUReg<1> SPU_Status; + SPUReg<1> SPU_NPC; + SPUReg<1> SPU_RdSigNotify1; + SPUReg<1> SPU_RdSigNotify2; + + DMAC dmac; + + void Handle() + { + u32 cmd = MFC_CMDStatus.GetValue(); + + if(cmd) + { + u16 op = cmd & MFC_MASK_CMD; + + switch(op) + { + case MFC_PUT_CMD: + case MFC_GET_CMD: + { + u32 lsa = MFC_LSA.GetValue(); + u64 ea = (u64)MFC_EAL.GetValue() | ((u64)MFC_EAH.GetValue() << 32); + u32 size_tag = MFC_Size_Tag.GetValue(); + u16 tag = (u16)size_tag; + u16 size = size_tag >> 16; + + ConLog.Warning("RawSPU DMA %s:", op == MFC_PUT_CMD ? "PUT" : "GET"); + ConLog.Warning("*** lsa = 0x%x", lsa); + ConLog.Warning("*** ea = 0x%llx", ea); + ConLog.Warning("*** tag = 0x%x", tag); + ConLog.Warning("*** size = 0x%x", size); + ConLog.SkipLn(); + + MFC_CMDStatus.SetValue(dmac.Cmd(cmd, tag, lsa, ea, size)); + } + break; + + default: + ConLog.Error("Unknown MFC cmd. (opcode=0x%x, cmd=0x%x)", op, cmd); + break; + } + } + + if(Prxy_QueryType.GetValue() == 2) + { + Prxy_QueryType.SetValue(0); + u32 mask = Prxy_QueryMask.GetValue(); + // + MFC_QStatus.SetValue(mask); + } + } +}; \ No newline at end of file diff --git a/rpcs3/Emu/Cell/PPCDecoder.h b/rpcs3/Emu/Cell/PPCDecoder.h index 053a30c2d1..68e7d6da72 100644 --- a/rpcs3/Emu/Cell/PPCDecoder.h +++ b/rpcs3/Emu/Cell/PPCDecoder.h @@ -1,6 +1,6 @@ #pragma once #include "PPCInstrTable.h" -#pragma warning( disable : 4800 4554 ) +#pragma warning( disable : 4800 ) template class InstrCaller @@ -381,7 +381,11 @@ public: , m_parent(nullptr) , m_opcode(-1) { - memset(m_instrs, 0, sizeof(InstrCaller*) * count); + for(int i=0; i*) * count); } @@ -413,6 +417,14 @@ public: void set_error_func(InstrCaller* error_func) { + for(int i=0; i* instr = m_instrs[entry]; - - if(instr) - { - (*instr)(op, code); - } - else if(m_error_func) - { - (*m_error_func)(op, code); - } + (*m_instrs[entry])(op, code); } virtual void operator ()(TO* op, u32 code) const @@ -482,21 +485,21 @@ static InstrList* connect_list(InstrList* parent, InstrL } template -static InstrList<1 << (to - from + 1), TO>* new_list(const CodeField& func, InstrCaller* error_func = nullptr) +static InstrList<1 << CodeField::size, TO>* new_list(const CodeField& func, InstrCaller* error_func = nullptr) { - return new InstrList<1 << (to - from + 1), TO>(func, error_func); + return new InstrList<1 << CodeField::size, TO>(func, error_func); } template -static InstrList<1 << (to - from + 1), TO>* new_list(InstrList* parent, int opcode, const CodeField& func, InstrCaller* error_func = nullptr) +static InstrList<1 << CodeField::size, TO>* new_list(InstrList* parent, int opcode, const CodeField& func, InstrCaller* error_func = nullptr) { - return connect_list(parent, new InstrList<1 << (to - from + 1), TO>(func, error_func), opcode); + return connect_list(parent, new InstrList<1 << CodeField::size, TO>(func, error_func), opcode); } template -static InstrList<1 << (to - from + 1), TO>* new_list(InstrList* parent, const CodeField& func, InstrCaller* error_func = nullptr) +static InstrList<1 << CodeField::size, TO>* new_list(InstrList* parent, const CodeField& func, InstrCaller* error_func = nullptr) { - return connect_list(parent, new InstrList<1 << (to - from + 1), TO>(func, error_func)); + return connect_list(parent, new InstrList<1 << CodeField::size, TO>(func, error_func)); } template diff --git a/rpcs3/Emu/Cell/PPCDisAsm.h b/rpcs3/Emu/Cell/PPCDisAsm.h index 0c8ee7eb3b..c3ca64fa25 100644 --- a/rpcs3/Emu/Cell/PPCDisAsm.h +++ b/rpcs3/Emu/Cell/PPCDisAsm.h @@ -23,7 +23,7 @@ protected: { case DumpMode: { - wxString mem = wxString::Format("\t%x:\t", dump_pc); + wxString mem = wxString::Format("\t%08llx:\t", dump_pc); for(u8 i=0; i < 4; ++i) { mem += wxString::Format("%02x", Memory.Read8(dump_pc + i)); @@ -36,14 +36,11 @@ protected: case InterpreterMode: { - wxString mem = wxString::Format("[%x] ", dump_pc); - for(u8 i=0; i < 4; ++i) - { - mem += wxString::Format("%02x", Memory.Read8(dump_pc + i)); - if(i < 3) mem += " "; - } - - last_opcode = mem + ": " + value; + last_opcode = wxString::Format("[%08llx] %02x %02x %02x %02x: %s", dump_pc, + Memory.Read8(offset + dump_pc), + Memory.Read8(offset + dump_pc + 1), + Memory.Read8(offset + dump_pc + 2), + Memory.Read8(offset + dump_pc + 3), value); } break; @@ -55,12 +52,14 @@ protected: public: wxString last_opcode; - uint dump_pc; + u64 dump_pc; + u64 offset; protected: PPC_DisAsm(PPCThread& cpu, DisAsmModes mode = NormalMode) : m_mode(mode) , disasm_frame(NULL) + , offset(0) { if(m_mode != NormalMode) return; diff --git a/rpcs3/Emu/Cell/PPCInstrTable.h b/rpcs3/Emu/Cell/PPCInstrTable.h index 76328a8b36..97f701b02d 100644 --- a/rpcs3/Emu/Cell/PPCInstrTable.h +++ b/rpcs3/Emu/Cell/PPCInstrTable.h @@ -1,10 +1,12 @@ #pragma once -template __forceinline static T sign(const T value) +template __forceinline static T sign(const T value) { - if(value & (1 << (size - 1))) + static_assert(size > 0 && size < sizeof(T) * 8, "Bad size"); + static const T sub_value = T(1) << size; + if(value & (T(1) << (size - 1))) { - return value - (1 << size); + return value - sub_value; } return value; @@ -52,6 +54,7 @@ public: { } + static const u32 size = to - from + 1; static const u32 shift = 31 - to; static const u32 mask = ((1ULL << ((to - from) + 1)) - 1) << shift; diff --git a/rpcs3/Emu/Cell/PPCThread.cpp b/rpcs3/Emu/Cell/PPCThread.cpp index 8124a58115..45ba83d0ec 100644 --- a/rpcs3/Emu/Cell/PPCThread.cpp +++ b/rpcs3/Emu/Cell/PPCThread.cpp @@ -10,13 +10,15 @@ PPCThread* GetCurrentPPCThread() PPCThread::PPCThread(PPCThreadType type) : ThreadBase(true, "PPCThread") , m_type(type) - , DisAsmFrame(NULL) - , m_arg(0) - , m_dec(NULL) + , DisAsmFrame(nullptr) + , m_dec(nullptr) , stack_size(0) , stack_addr(0) , m_prio(0) , m_offset(0) + , m_sync_wait(false) + , m_wait_thread_id(-1) + , m_free_data(false) { } @@ -27,18 +29,28 @@ PPCThread::~PPCThread() void PPCThread::Close() { - Stop(); + if(IsAlive()) + { + m_free_data = true; + } + if(DisAsmFrame) { DisAsmFrame->Close(); DisAsmFrame = nullptr; } + + Stop(); } void PPCThread::Reset() { CloseStack(); + m_sync_wait = 0; + m_wait_thread_id = -1; + memset(m_args, 0, sizeof(u64) * 4); + SetPc(0); cycle = 0; @@ -83,8 +95,6 @@ void PPCThread::CloseStack() void PPCThread::SetId(const u32 id) { m_id = id; - ID& thread = Emu.GetIdManager().GetIDData(m_id); - thread.m_name = GetName(); } void PPCThread::SetName(const wxString& name) @@ -92,6 +102,46 @@ void PPCThread::SetName(const wxString& name) m_name = name; } +void PPCThread::Wait(bool wait) +{ + wxCriticalSectionLocker lock(m_cs_sync); + m_sync_wait = wait; +} + +void PPCThread::Wait(const PPCThread& thr) +{ + wxCriticalSectionLocker lock(m_cs_sync); + m_wait_thread_id = thr.GetId(); + m_sync_wait = true; +} + +bool PPCThread::Sync() +{ + wxCriticalSectionLocker lock(m_cs_sync); + + return m_sync_wait; +} + +int PPCThread::ThreadStatus() +{ + if(Emu.IsStopped()) + { + return PPCThread_Stopped; + } + + if(TestDestroy()) + { + return PPCThread_Break; + } + + if(Emu.IsPaused() || Sync()) + { + return PPCThread_Sleeping; + } + + return PPCThread_Running; +} + void PPCThread::NextBranchPc() { SetPc(nPC); @@ -127,9 +177,9 @@ void PPCThread::SetEntry(const u64 pc) void PPCThread::SetBranch(const u64 pc) { - if(!Memory.IsGoodAddr(pc)) + if(!Memory.IsGoodAddr(m_offset + pc)) { - ConLog.Error("%s branch error: bad address 0x%llx #pc: 0x%llx", GetFName(), pc, PC); + ConLog.Error("%s branch error: bad address 0x%llx #pc: 0x%llx", GetFName(), m_offset+ pc, m_offset + PC); Emu.Pause(); } nPC = pc; @@ -151,7 +201,7 @@ void PPCThread::SetError(const u32 error) wxArrayString PPCThread::ErrorToString(const u32 error) { wxArrayString earr; - earr.Clear(); + if(error == 0) return earr; earr.Add("Unknown error"); @@ -217,12 +267,11 @@ void PPCThread::Stop() wxGetApp().SendDbgCommand(DID_STOP_THREAD, this); m_status = Stopped; + ThreadBase::Stop(false); Reset(); DoStop(); Emu.CheckStatus(); - ThreadBase::Stop(); - wxGetApp().SendDbgCommand(DID_STOPED_THREAD, this); } @@ -230,6 +279,7 @@ void PPCThread::Exec() { wxGetApp().SendDbgCommand(DID_EXEC_THREAD, this); ThreadBase::Start(); + //std::thread thr(std::bind(std::mem_fn(&PPCThread::Task), this)); } void PPCThread::ExecOnce() @@ -240,7 +290,7 @@ void PPCThread::ExecOnce() void PPCThread::Task() { - ConLog.Write("%s enter", PPCThread::GetFName()); + //ConLog.Write("%s enter", PPCThread::GetFName()); const Array& bp = Emu.GetBreakPoints(); @@ -255,9 +305,16 @@ void PPCThread::Task() } } - while(!Emu.IsStopped() && !TestDestroy()) + while(true) { - if(Emu.IsPaused()) + int status = ThreadStatus(); + + if(status == PPCThread_Stopped || status == PPCThread_Break) + { + break; + } + + if(status == PPCThread_Sleeping) { Sleep(1); continue; @@ -285,5 +342,8 @@ void PPCThread::Task() ConLog.Error("Exception: %s", e); } - ConLog.Write("%s leave", PPCThread::GetFName()); + //ConLog.Write("%s leave", PPCThread::GetFName()); + + if(m_free_data) + free(this); } diff --git a/rpcs3/Emu/Cell/PPCThread.h b/rpcs3/Emu/Cell/PPCThread.h index 14abf1f17b..6fd153bbce 100644 --- a/rpcs3/Emu/Cell/PPCThread.h +++ b/rpcs3/Emu/Cell/PPCThread.h @@ -6,6 +6,17 @@ enum PPCThreadType { PPC_THREAD_PPU, PPC_THREAD_SPU, + PPC_THREAD_RAW_SPU, +}; + +enum PPCThreadStatus +{ + PPCThread_Ready, + PPCThread_Running, + PPCThread_Paused, + PPCThread_Stopped, + PPCThread_Sleeping, + PPCThread_Break, }; class PPCThread : public ThreadBase @@ -17,12 +28,14 @@ protected: wxWindow* DisAsmFrame; u32 m_id; PPCThreadType m_type; - u64 m_arg; + u64 m_args[4]; u64 m_prio; bool m_joinable; bool m_joining; Array argv_addr; u64 m_offset; + u32 m_exit_status; + bool m_free_data; public: u64 stack_size; @@ -37,13 +50,17 @@ public: virtual u64 GetStackAddr() const { return stack_addr; } virtual u64 GetStackSize() const { return stack_size; } virtual u64 GetFreeStackSize() const=0; - void SetArg(const u64 arg) { m_arg = arg; } + void SetArg(const uint pos, const u64 arg) { assert(pos < 4); m_args[pos] = arg; } + void SetId(const u32 id); void SetName(const wxString& name); void SetPrio(const u64 prio) { m_prio = prio; } void SetOffset(const u64 offset) { m_offset = offset; } + void SetExitStatus(const u32 status) { m_exit_status = status; } + u64 GetOffset() const { return m_offset; } + u32 GetExitStatus() const { return m_exit_status; } u64 GetPrio() const { return m_prio; } wxString GetName() const { return m_name; } wxString GetFName() const @@ -62,6 +79,7 @@ public: { case PPC_THREAD_PPU: return "PPU"; case PPC_THREAD_SPU: return "SPU"; + case PPC_THREAD_RAW_SPU: return "RawSPU"; } return "Unknown"; @@ -88,6 +106,25 @@ protected: public: ~PPCThread(); + u32 m_wait_thread_id; + + wxCriticalSection m_cs_sync; + bool m_sync_wait; + void Wait(bool wait); + void Wait(const PPCThread& thr); + bool Sync(); + + template + void WaitFor(T func) + { + while(func(ThreadStatus())) + { + Sleep(1); + } + } + + int ThreadStatus(); + void NextPc(); void NextBranchPc(); void PrevPc(); @@ -100,7 +137,6 @@ public: static wxArrayString ErrorToString(const u32 error); wxArrayString ErrorToString() { return ErrorToString(m_error); } - bool IsSPU() const { return m_type == PPC_THREAD_SPU; } bool IsOk() const { return m_error == 0; } bool IsRunned() const { return m_status == Runned; } bool IsPaused() const { return m_status == Paused; } @@ -113,6 +149,7 @@ public: u32 GetError() const { return m_error; } u32 GetId() const { return m_id; } + PPCThreadType GetType() const { return m_type; } void Reset(); void Close(); @@ -135,6 +172,7 @@ protected: virtual void DoResume()=0; virtual void DoStop()=0; +public: virtual void Task(); private: diff --git a/rpcs3/Emu/Cell/PPCThreadManager.cpp b/rpcs3/Emu/Cell/PPCThreadManager.cpp index dde13c534f..37580c518e 100644 --- a/rpcs3/Emu/Cell/PPCThreadManager.cpp +++ b/rpcs3/Emu/Cell/PPCThreadManager.cpp @@ -2,6 +2,7 @@ #include "PPCThreadManager.h" #include "PPUThread.h" #include "SPUThread.h" +#include "RawSPUThread.h" PPCThreadManager::PPCThreadManager() { @@ -17,13 +18,21 @@ void PPCThreadManager::Close() while(m_threads.GetCount()) RemoveThread(m_threads[0].GetId()); } -PPCThread& PPCThreadManager::AddThread(bool isPPU) +PPCThread& PPCThreadManager::AddThread(PPCThreadType type) { - PPCThread* new_thread = isPPU ? (PPCThread*)new PPUThread() : (PPCThread*)new SPUThread(); + std::lock_guard lock(m_mtx_thread); - new_thread->SetId(Emu.GetIdManager().GetNewID( - wxString::Format("%s Thread", isPPU ? "PPU" : "SPU"), new_thread, 0) - ); + PPCThread* new_thread; + char* name; + switch(type) + { + case PPC_THREAD_PPU: new_thread = new PPUThread(); name = "PPU"; break; + case PPC_THREAD_SPU: new_thread = new SPUThread(); name = "SPU"; break; + case PPC_THREAD_RAW_SPU: new_thread = new RawSPUThread(); name = "RawSPU"; break; + default: assert(0); + } + + new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", name), new_thread)); m_threads.Add(new_thread); wxGetApp().SendDbgCommand(DID_CREATE_THREAD, new_thread); @@ -33,30 +42,47 @@ PPCThread& PPCThreadManager::AddThread(bool isPPU) void PPCThreadManager::RemoveThread(const u32 id) { + std::lock_guard lock(m_mtx_thread); + for(u32 i=0; iIsAlive()) + { + thr->Close(); + } + else + { + thr->Close(); + delete thr; + } - break; + + m_threads.RemoveFAt(i); + i--; } Emu.GetIdManager().RemoveID(id, false); Emu.CheckStatus(); } -s32 PPCThreadManager::GetThreadNumById(bool isPPU, u32 id) +s32 PPCThreadManager::GetThreadNumById(PPCThreadType type, u32 id) { s32 num = 0; for(u32 i=0; i m_ppu_threads; //ArrayF m_spu_threads; ArrayF m_threads; + std::mutex m_mtx_thread; + wxSemaphore m_sem_task; + Stack m_delete_threads; public: PPCThreadManager(); @@ -14,13 +17,14 @@ public: void Close(); - PPCThread& AddThread(bool isPPU); + PPCThread& AddThread(PPCThreadType type); void RemoveThread(const u32 id); ArrayF& GetThreads() { return m_threads; } - s32 GetThreadNumById(bool isPPU, u32 id); + s32 GetThreadNumById(PPCThreadType type, u32 id); PPCThread* GetThread(u32 id); //IdManager& GetIDs() {return m_threads_id;} void Exec(); + void Task(); }; \ No newline at end of file diff --git a/rpcs3/Emu/Cell/PPUDisAsm.h b/rpcs3/Emu/Cell/PPUDisAsm.h index a413498113..2ac75b274e 100644 --- a/rpcs3/Emu/Cell/PPUDisAsm.h +++ b/rpcs3/Emu/Cell/PPUDisAsm.h @@ -274,9 +274,9 @@ private: { DisAsm_V2("vlogefp", vd, vb); } - void VMADDFP(u32 vd, u32 va, u32 vb, u32 vc) + void VMADDFP(u32 vd, u32 va, u32 vc, u32 vb) { - DisAsm_V4("vmaddfp", vd, va, vb, vc); + DisAsm_V4("vmaddfp", vd, va, vc, vb); } void VMAXFP(u32 vd, u32 va, u32 vb) { @@ -426,9 +426,9 @@ private: { DisAsm_V3("vmulouh", vd, va, vb); } - void VNMSUBFP(u32 vd, u32 va, u32 vb, u32 vc) + void VNMSUBFP(u32 vd, u32 va, u32 vc, u32 vb) { - DisAsm_V4("vnmsubfp", vd, va, vb, vc); + DisAsm_V4("vnmsubfp", vd, va, vc, vb); } void VNOR(u32 vd, u32 va, u32 vb) { @@ -1051,9 +1051,9 @@ private: { DisAsm_R3("lwarx", rd, ra, rb); } - void LDX(u32 ra, u32 rs, u32 rb) + void LDX(u32 rd, u32 ra, u32 rb) { - DisAsm_R3("ldx", ra, rs, rb); + DisAsm_R3("ldx", rd, ra, rb); } void LWZX(u32 rd, u32 ra, u32 rb) { @@ -1166,9 +1166,16 @@ private: { DisAsm_R3_OE_RC("adde", rd, ra, rb, oe, rc); } - void MTOCRF(u32 crm, u32 rs) + void MTOCRF(u32 l, u32 crm, u32 rs) { - DisAsm_INT1_R1("mtocrf", crm, rs); + if(l) + { + DisAsm_INT1_R1("mtocrf", crm, rs); + } + else + { + DisAsm_INT1_R1("mtcrf", crm, rs); + } } void STDX(u32 rs, u32 ra, u32 rb) { @@ -1284,10 +1291,6 @@ private: { DisAsm_V1_R2("lvxl", vd, ra, rb); } - void ABS(u32 rd, u32 ra, u32 oe, bool rc) - { - DisAsm_R2_OE_RC("abs", rd, ra, oe, rc); - } void MFTB(u32 rd, u32 spr) { const u32 n = (spr >> 5) | ((spr & 0x1f) << 5); diff --git a/rpcs3/Emu/Cell/PPUInstrTable.h b/rpcs3/Emu/Cell/PPUInstrTable.h index ebd8849ff7..82f3a6bc2a 100644 --- a/rpcs3/Emu/Cell/PPUInstrTable.h +++ b/rpcs3/Emu/Cell/PPUInstrTable.h @@ -70,18 +70,6 @@ namespace PPU_instr //This field is used to specify a bit in the CR, or in the FPSCR, as the destination of the result of an instruction static CodeField<6, 10> CRBD(FIELD_R_CR); - - // - static CodeField<6, 10> BT; - - // - static CodeField<11, 15> BA; - - // - static CodeField<16, 20> BB; - - // - static CodeField<6, 10> BF; //This field is used to specify options for the branch conditional instructions static CodeField<6, 10> BO; @@ -125,8 +113,10 @@ namespace PPU_instr */ static CodeField<30> AA; + static CodeFieldSignedOffset<6, 29, 2> LI(FIELD_BRANCH); + // - static CodeFieldSigned<6, 31> LL(FIELD_BRANCH); + static CodeFieldSignedOffset<6, 29, 2> LL(FIELD_BRANCH); /* Link bit. 0 Does not update the link register (LR). @@ -156,7 +146,7 @@ namespace PPU_instr static CodeField<6, 10> FRS; // - static CodeField<7, 14> FLM; + static CodeField<7, 14> FM; //This field is used to specify an FPR as a source static CodeField<11, 15> FRA(FIELD_R_FPR); @@ -177,36 +167,7 @@ namespace PPU_instr static CodeFieldSigned<16, 31> D; // - struct : public CodeFieldSigned<16, 31> - { - static __forceinline u32 decode(u32 data) - { - int res = sign((data & mask) >> shift); - if(res < 0) return res - 1; - return res; - } - - static __forceinline void encode(u32& data, u32 value) - { - if((s32)value < 0) - { - value++; - } - - data &= ~mask; - data |= (value << shift) & mask; - } - - virtual u32 operator ()(u32 data) const - { - return decode(data); - } - - virtual void operator ()(u32& data, u32 value) const - { - return encode(data, value); - } - } static DS; + static CodeFieldSignedOffset<16, 29, 2> DS; //This immediate field is used to specify a 16-bit signed integer static CodeFieldSigned<16, 31> simm16; @@ -269,7 +230,7 @@ namespace PPU_instr bind_instr(main_list, ADDIS, RD, RA, simm16); bind_instr(main_list, BC, BO, BI, BD, AA, LK); bind_instr(main_list, SC, SYS); - bind_instr(main_list, B, LL, AA, LK); + bind_instr(main_list, B, LI, AA, LK); bind_instr(main_list, RLWIMI, RA, RS, SH, MB, ME, RC); bind_instr(main_list, RLWINM, RA, RS, SH, MB, ME, RC); bind_instr(main_list, RLWNM, RA, RS, RB, MB, ME, RC); @@ -302,7 +263,7 @@ namespace PPU_instr bind_instr(main_list, STFD, FRS, RA, D); bind_instr(main_list, STFDU, FRS, RA, D); - bind_instr(g04_list, VMADDFP, VD, VA, VB, VC); + bind_instr(g04_list, VMADDFP, VD, VA, VC, VB); bind_instr(g04_list, VMHADDSHS, VD, VA, VB, VC); bind_instr(g04_list, VMHRADDSHS, VD, VA, VB, VC); bind_instr(g04_list, VMLADDUHM, VD, VA, VB, VC); @@ -312,7 +273,7 @@ namespace PPU_instr bind_instr(g04_list, VMSUMUBM, VD, VA, VB, VC); bind_instr(g04_list, VMSUMUHM, VD, VA, VB, VC); bind_instr(g04_list, VMSUMUHS, VD, VA, VB, VC); - bind_instr(g04_list, VNMSUBFP, VD, VA, VB, VC); + bind_instr(g04_list, VNMSUBFP, VD, VA, VC, VB); bind_instr(g04_list, VPERM, VD, VA, VB, VC); bind_instr(g04_list, VSEL, VD, VA, VB, VC); bind_instr(g04_list, VSLDOI, VD, VA, VB, VSH); @@ -489,7 +450,7 @@ namespace PPU_instr /*0x00b*/bind_instr(g1f_list, MULHWU, RD, RA, RB, RC); /*0x013*/bind_instr(g1f_list, MFOCRF, L_11, RD, CRM); /*0x014*/bind_instr(g1f_list, LWARX, RD, RA, RB); - /*0x015*/bind_instr(g1f_list, LDX, RA, RS, RB); + /*0x015*/bind_instr(g1f_list, LDX, RD, RA, RB); /*0x017*/bind_instr(g1f_list, LWZX, RD, RA, RB); /*0x018*/bind_instr(g1f_list, SLW, RA, RS, RB, RC); /*0x01a*/bind_instr(g1f_list, CNTLZW, RA, RS, RC); @@ -515,7 +476,7 @@ namespace PPU_instr /*0x087*/bind_instr(g1f_list, STVEBX, VS, RA, RB); /*0x088*/bind_instr(g1f_list, SUBFE, RD, RA, RB, OE, RC); /*0x08a*/bind_instr(g1f_list, ADDE, RD, RA, RB, OE, RC); - /*0x090*/bind_instr(g1f_list, MTOCRF, CRM, RS); + /*0x090*/bind_instr(g1f_list, MTOCRF, L_11, CRM, RS); /*0x095*/bind_instr(g1f_list, STDX, RS, RA, RB); /*0x096*/bind_instr(g1f_list, STWCX_, RS, RA, RB); /*0x097*/bind_instr(g1f_list, STWX, RS, RA, RB); @@ -541,7 +502,6 @@ namespace PPU_instr /*0x156*/bind_instr(g1f_list, DST, RA, RB, STRM, L_6); /*0x157*/bind_instr(g1f_list, LHAX, RD, RA, RB); /*0x167*/bind_instr(g1f_list, LVXL, VD, RA, RB); - /*0x168*/bind_instr(g1f_list, ABS, RD, RA, OE, RC); /*0x173*/bind_instr(g1f_list, MFTB, RD, SPR); /*0x176*/bind_instr(g1f_list, DSTST, RA, RB, STRM, L_6); /*0x177*/bind_instr(g1f_list, LHAUX, RD, RA, RB); @@ -554,7 +514,7 @@ namespace PPU_instr /*0x1d3*/bind_instr(g1f_list, MTSPR, SPR, RS); /*0x1d6*///DCBI /*0x1dc*/bind_instr(g1f_list, NAND, RA, RS, RB, RC); - /*0x1e7*/bind_instr(g1f_list, STVXL, RS, RA, RB); + /*0x1e7*/bind_instr(g1f_list, STVXL, VS, RA, RB); /*0x1e9*/bind_instr(g1f_list, DIVD, RD, RA, RB, OE, RC); /*0x1eb*/bind_instr(g1f_list, DIVW, RD, RA, RB, OE, RC); /*0x207*/bind_instr(g1f_list, LVLX, VD, RA, RB); @@ -568,9 +528,9 @@ namespace PPU_instr /*0x257*/bind_instr(g1f_list, LFDX, FRD, RA, RB); /*0x277*/bind_instr(g1f_list, LFDUX, FRD, RA, RB); /*0x287*/bind_instr(g1f_list, STVLX, VS, RA, RB); - /*0x297*/bind_instr(g1f_list, STFSX, RS, RA, RB); + /*0x297*/bind_instr(g1f_list, STFSX, FRS, RA, RB); /*0x2a7*/bind_instr(g1f_list, STVRX, VS, RA, RB); - /*0x2d7*/bind_instr(g1f_list, STFDX, RS, RA, RB); + /*0x2d7*/bind_instr(g1f_list, STFDX, FRS, RA, RB); /*0x307*/bind_instr(g1f_list, LVLXL, VD, RA, RB); /*0x316*/bind_instr(g1f_list, LHBRX, RD, RA, RB); /*0x318*/bind_instr(g1f_list, SRAW, RA, RS, RB, RC); @@ -581,14 +541,16 @@ namespace PPU_instr /*0x33a*/bind_instr(g1f_list, SRADI1, RA, RS, sh, RC); /*0x33b*/bind_instr(g1f_list, SRADI2, RA, RS, sh, RC); /*0x356*/bind_instr(g1f_list, EIEIO); + /*0x387*/bind_instr(g1f_list, STVLXL, VS, RA, RB); /*0x39a*/bind_instr(g1f_list, EXTSH, RA, RS, RC); + /*0x387*/bind_instr(g1f_list, STVRXL, VS, RA, RB); /*0x3ba*/bind_instr(g1f_list, EXTSB, RA, RS, RC); /*0x3d7*/bind_instr(g1f_list, STFIWX, FRS, RA, RB); /*0x3da*/bind_instr(g1f_list, EXTSW, RA, RS, RC); /*0x3d6*///ICBI /*0x3f6*/bind_instr(g1f_list, DCBZ, RA, RB); - bind_instr(g3a_list, LD, RD, RA, D); + bind_instr(g3a_list, LD, RD, RA, DS); bind_instr(g3a_list, LDU, RD, RA, DS); bind_instr(g3b_list, FDIVS, FRD, FRA, FRB, RC); @@ -602,7 +564,7 @@ namespace PPU_instr bind_instr(g3b_list, FNMSUBS, FRD, FRA, FRC, FRB, RC); bind_instr(g3b_list, FNMADDS, FRD, FRA, FRC, FRB, RC); - bind_instr(g3e_list, STD, RS, RA, D); + bind_instr(g3e_list, STD, RS, RA, DS); bind_instr(g3e_list, STDU, RS, RA, DS); bind_instr(g3f_list, FSEL, FRD, FRA, FRC, FRB, RC); @@ -630,12 +592,12 @@ namespace PPU_instr bind_instr(g3f_0_list, FCTID, FRD, FRB, RC); bind_instr(g3f_0_list, FCTIDZ, FRD, FRB, RC); - bind_instr(g3f_0_list, MTFSB1, BT, RC); - bind_instr(g3f_0_list, MCRFS, BF, BFA); - bind_instr(g3f_0_list, MTFSB0, BT, RC); + bind_instr(g3f_0_list, MTFSB1, CRBD, RC); + bind_instr(g3f_0_list, MCRFS, CRFD, CRFS); + bind_instr(g3f_0_list, MTFSB0, CRBD, RC); bind_instr(g3f_0_list, MTFSFI, CRFD, I, RC); bind_instr(g3f_0_list, MFFS, FRD, RC); - bind_instr(g3f_0_list, MTFSF, FLM, FRB, RC); + bind_instr(g3f_0_list, MTFSF, FM, FRB, RC); #undef bind_instr }; \ No newline at end of file diff --git a/rpcs3/Emu/Cell/PPUInterpreter.h b/rpcs3/Emu/Cell/PPUInterpreter.h index 8aeceb92b6..ce08c505fc 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.h +++ b/rpcs3/Emu/Cell/PPUInterpreter.h @@ -61,10 +61,10 @@ private: void SysCall() { - CPU.GPR[3] = CPU.DoSyscall(CPU.GPR[11]); + CPU.DoSyscall(CPU.GPR[11]); - //if((s32)CPU.GPR[3] < 0) - //ConLog.Warning("SysCall[%lld] done with code [0x%x]! #pc: 0x%llx", CPU.GPR[11], (u32)CPU.GPR[3], CPU.PC); + if(enable_log) + ConLog.Warning("SysCall[%lld] done with code [0x%llx]! #pc: 0x%llx", CPU.GPR[11], CPU.GPR[3], CPU.PC); #ifdef HLE_CALL_DEBUG ConLog.Write("SysCall[%lld] done with code [0x%llx]! #pc: 0x%llx", CPU.GPR[11], CPU.GPR[3], CPU.PC); #endif @@ -97,18 +97,12 @@ private: const u8 bo1 = (bo & 0x08) ? 1 : 0; const u8 bo2 = (bo & 0x04) ? 1 : 0; const u8 bo3 = (bo & 0x02) ? 1 : 0; - const u8 bo4 = (bo & 0x01) ? 1 : 0; if(!bo2) --CPU.CTR; const u8 ctr_ok = bo2 | ((CPU.CTR != 0) ^ bo3); const u8 cond_ok = bo0 | (CPU.IsCR(bi) ^ (~bo1 & 0x1)); - //if(bo1) CPU.SetCR(bi, bo4 ? 1 : 0); - //if(bo1) return !bo4; - - //ConLog.Write("bo0: 0x%x, bo1: 0x%x, bo2: 0x%x, bo3: 0x%x", bo0, bo1, bo2, bo3); - return ctr_ok && cond_ok; } @@ -805,7 +799,7 @@ private: CPU.VPR[vd]._f[w] = log(CPU.VPR[vb]._f[w]) / log(2.0f); } } - void VMADDFP(u32 vd, u32 va, u32 vb, u32 vc) + void VMADDFP(u32 vd, u32 va, u32 vc, u32 vb) { for (uint w = 0; w < 4; w++) { @@ -955,50 +949,56 @@ private: } void VMRGHB(u32 vd, u32 va, u32 vb) { + VPR_reg VA = CPU.VPR[va]; + VPR_reg VB = CPU.VPR[vb]; for (uint h = 0; h < 8; h++) { - CPU.VPR[vd]._u8[h*2] = CPU.VPR[va]._u8[h]; - CPU.VPR[vd]._u8[h*2 + 1] = CPU.VPR[vb]._u8[h]; + CPU.VPR[vd]._u8[15 - h*2] = VA._u8[15 - h]; + CPU.VPR[vd]._u8[15 - h*2 - 1] = VB._u8[15 - h]; } } void VMRGHH(u32 vd, u32 va, u32 vb) { + VPR_reg VA = CPU.VPR[va]; + VPR_reg VB = CPU.VPR[vb]; for (uint w = 0; w < 4; w++) { - CPU.VPR[vd]._u16[w*2] = CPU.VPR[va]._u16[w]; - CPU.VPR[vd]._u16[w*2 + 1] = CPU.VPR[vb]._u16[w]; + CPU.VPR[vd]._u16[7 - w*2] = VA._u16[7 - w]; + CPU.VPR[vd]._u16[7 - w*2 - 1] = VB._u16[7 - w]; } } void VMRGHW(u32 vd, u32 va, u32 vb) { + VPR_reg VA = CPU.VPR[va]; + VPR_reg VB = CPU.VPR[vb]; for (uint d = 0; d < 2; d++) { - CPU.VPR[vd]._u32[d*2] = CPU.VPR[va]._u32[d]; - CPU.VPR[vd]._u32[d*2 + 1] = CPU.VPR[vb]._u32[d]; + CPU.VPR[vd]._u32[3 - d*2] = VA._u32[3 - d]; + CPU.VPR[vd]._u32[3 - d*2 - 1] = VB._u32[3 - d]; } } void VMRGLB(u32 vd, u32 va, u32 vb) { for (uint h = 0; h < 8; h++) { - CPU.VPR[vd]._u8[h*2] = CPU.VPR[va]._u8[h + 8]; - CPU.VPR[vd]._u8[h*2 + 1] = CPU.VPR[vb]._u8[h + 8]; + CPU.VPR[vd]._u8[15 - h*2] = CPU.VPR[va]._u8[7 - h]; + CPU.VPR[vd]._u8[15 - h*2 - 1] = CPU.VPR[vb]._u8[7 - h]; } } void VMRGLH(u32 vd, u32 va, u32 vb) { for (uint w = 0; w < 4; w++) { - CPU.VPR[vd]._u16[w*2] = CPU.VPR[va]._u16[w + 4]; - CPU.VPR[vd]._u16[w*2 + 1] = CPU.VPR[vb]._u16[w + 4]; + CPU.VPR[vd]._u16[7 - w*2] = CPU.VPR[va]._u16[3 - w]; + CPU.VPR[vd]._u16[7 - w*2 - 1] = CPU.VPR[vb]._u16[3 - w]; } } void VMRGLW(u32 vd, u32 va, u32 vb) { for (uint d = 0; d < 2; d++) { - CPU.VPR[vd]._u32[d*2] = CPU.VPR[va]._u32[d + 2]; - CPU.VPR[vd]._u32[d*2 + 1] = CPU.VPR[vb]._u32[d + 2]; + CPU.VPR[vd]._u32[3 - d*2] = CPU.VPR[va]._u32[1 - d]; + CPU.VPR[vd]._u32[3 - d*2 - 1] = CPU.VPR[vb]._u32[1 - d]; } } void VMSUMMBM(u32 vd, u32 va, u32 vb, u32 vc) @@ -1172,11 +1172,11 @@ private: CPU.VPR[vd]._u32[w] = (u32)CPU.VPR[va]._u16[w*2] * (u32)CPU.VPR[vb]._u16[w*2]; } } - void VNMSUBFP(u32 vd, u32 va, u32 vb, u32 vc) + void VNMSUBFP(u32 vd, u32 va, u32 vc, u32 vb) { for (uint w = 0; w < 4; w++) { - CPU.VPR[vd]._f[w] = (double)CPU.VPR[vb]._f[w] - (double)CPU.VPR[va]._f[w] * (double)CPU.VPR[vc]._f[w]; + CPU.VPR[vd]._f[w] = -(CPU.VPR[va]._f[w] * CPU.VPR[vc]._f[w] - CPU.VPR[vb]._f[w]); } } void VNOR(u32 vd, u32 va, u32 vb) @@ -1617,7 +1617,7 @@ private: { assert(uimm5 < 4); - u32 word = CPU.VPR[vb]._u32[uimm5]; + u32 word = CPU.VPR[vb]._u32[3 - uimm5]; for (uint w = 0; w < 4; w++) { @@ -2028,11 +2028,11 @@ private: } void CMPLI(u32 crfd, u32 l, u32 ra, u32 uimm16) { - CPU.UpdateCRn(crfd, l ? CPU.GPR[ra] : (u32)CPU.GPR[ra], uimm16); + CPU.UpdateCRnU(l, crfd, CPU.GPR[ra], uimm16); } void CMPI(u32 crfd, u32 l, u32 ra, s32 simm16) { - CPU.UpdateCRn(crfd, l ? CPU.GPR[ra] : (s32)CPU.GPR[ra], simm16); + CPU.UpdateCRnS(l, crfd, CPU.GPR[ra], simm16); } void ADDIC(u32 rd, u32 ra, s32 simm16) { @@ -2086,48 +2086,48 @@ private: CPU.SetBranch(branchTarget(0, CPU.LR)); if(lk) CPU.LR = CPU.PC + 4; } - void CRNOR(u32 bt, u32 ba, u32 bb) + void CRNOR(u32 crbd, u32 crba, u32 crbb) { - const u8 v = 1 ^ (CPU.IsCR(ba) | CPU.IsCR(bb)); - CPU.SetCRBit2(bt, v & 0x1); + const u8 v = 1 ^ (CPU.IsCR(crba) | CPU.IsCR(crbb)); + CPU.SetCRBit2(crbd, v & 0x1); } - void CRANDC(u32 bt, u32 ba, u32 bb) + void CRANDC(u32 crbd, u32 crba, u32 crbb) { - const u8 v = CPU.IsCR(ba) & (1 ^ CPU.IsCR(bb)); - CPU.SetCRBit2(bt, v & 0x1); + const u8 v = CPU.IsCR(crba) & (1 ^ CPU.IsCR(crbb)); + CPU.SetCRBit2(crbd, v & 0x1); } void ISYNC() { } - void CRXOR(u32 bt, u32 ba, u32 bb) + void CRXOR(u32 crbd, u32 crba, u32 crbb) { - const u8 v = CPU.IsCR(ba) ^ CPU.IsCR(bb); - CPU.SetCRBit2(bt, v & 0x1); + const u8 v = CPU.IsCR(crba) ^ CPU.IsCR(crbb); + CPU.SetCRBit2(crbd, v & 0x1); } - void CRNAND(u32 bt, u32 ba, u32 bb) + void CRNAND(u32 crbd, u32 crba, u32 crbb) { - const u8 v = 1 ^ (CPU.IsCR(ba) & CPU.IsCR(bb)); - CPU.SetCRBit2(bt, v & 0x1); + const u8 v = 1 ^ (CPU.IsCR(crba) & CPU.IsCR(crbb)); + CPU.SetCRBit2(crbd, v & 0x1); } - void CRAND(u32 bt, u32 ba, u32 bb) + void CRAND(u32 crbd, u32 crba, u32 crbb) { - const u8 v = CPU.IsCR(ba) & CPU.IsCR(bb); - CPU.SetCRBit2(bt, v & 0x1); + const u8 v = CPU.IsCR(crba) & CPU.IsCR(crbb); + CPU.SetCRBit2(crbd, v & 0x1); } - void CREQV(u32 bt, u32 ba, u32 bb) + void CREQV(u32 crbd, u32 crba, u32 crbb) { - const u8 v = 1 ^ (CPU.IsCR(ba) ^ CPU.IsCR(bb)); - CPU.SetCRBit2(bt, v & 0x1); + const u8 v = 1 ^ (CPU.IsCR(crba) ^ CPU.IsCR(crbb)); + CPU.SetCRBit2(crbd, v & 0x1); } - void CRORC(u32 bt, u32 ba, u32 bb) + void CRORC(u32 crbd, u32 crba, u32 crbb) { - const u8 v = CPU.IsCR(ba) | (1 ^ CPU.IsCR(bb)); - CPU.SetCRBit2(bt, v & 0x1); + const u8 v = CPU.IsCR(crba) | (1 ^ CPU.IsCR(crbb)); + CPU.SetCRBit2(crbd, v & 0x1); } - void CROR(u32 bt, u32 ba, u32 bb) + void CROR(u32 crbd, u32 crba, u32 crbb) { - const u8 v = CPU.IsCR(ba) | CPU.IsCR(bb); - CPU.SetCRBit2(bt, v & 0x1); + const u8 v = CPU.IsCR(crba) | CPU.IsCR(crbb); + CPU.SetCRBit2(crbd, v & 0x1); } void BCCTR(u32 bo, u32 bi, u32 bh, u32 lk) { @@ -2172,12 +2172,12 @@ private: void ANDI_(u32 ra, u32 rs, u32 uimm16) { CPU.GPR[ra] = CPU.GPR[rs] & uimm16; - CPU.UpdateCR0(CPU.GPR[ra]); + CPU.UpdateCR0(CPU.GPR[ra]); } void ANDIS_(u32 ra, u32 rs, u32 uimm16) { CPU.GPR[ra] = CPU.GPR[rs] & (uimm16 << 16); - CPU.UpdateCR0(CPU.GPR[ra]); + CPU.UpdateCR0(CPU.GPR[ra]); } void RLDICL(u32 ra, u32 rs, u32 sh, u32 mb, bool rc) { @@ -2202,7 +2202,7 @@ private: } void CMP(u32 crfd, u32 l, u32 ra, u32 rb) { - CPU.UpdateCRn(crfd, l ? CPU.GPR[ra] : (s32)CPU.GPR[ra], l ? CPU.GPR[rb] : (s32)CPU.GPR[rb]); + CPU.UpdateCRnS(l, crfd, CPU.GPR[ra], CPU.GPR[rb]); } void TW(u32 to, u32 ra, u32 rb) { @@ -2256,7 +2256,7 @@ private: { const s64 RA = CPU.GPR[ra]; const s64 RB = CPU.GPR[rb]; - CPU.GPR[rd] = RB - RA; + CPU.GPR[rd] = ~RA + RB + 1; CPU.XER.CA = CPU.IsCarry(RA, RB); if(oe) UNK("subfco"); if(rc) CPU.UpdateCR0(CPU.GPR[rd]); @@ -2334,9 +2334,9 @@ private: CPU.reserve = true; CPU.GPR[rd] = Memory.Read32(addr); } - void LDX(u32 ra, u32 rs, u32 rb) + void LDX(u32 rd, u32 ra, u32 rb) { - CPU.GPR[ra] = Memory.Read64(rs ? CPU.GPR[rs] + CPU.GPR[rb] : CPU.GPR[rb]); + CPU.GPR[rd] = Memory.Read64(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]); } void LWZX(u32 rd, u32 ra, u32 rb) { @@ -2362,11 +2362,16 @@ private: CPU.GPR[ra] = i; - if(rc) CPU.UpdateCR0(CPU.GPR[ra]); + if(rc) CPU.UpdateCR0(CPU.GPR[ra]); } void SLD(u32 ra, u32 rs, u32 rb, bool rc) { - CPU.GPR[ra] = CPU.GPR[rb] & 0x40 ? 0 : CPU.GPR[rs] << (CPU.GPR[rb] & 0x3f); + const u32 n = CPU.GPR[rb] & 0x3f; + const u64 r = rotl64(CPU.GPR[rs], n); + const u64 m = (CPU.GPR[rb] & 0x30) ? 0 : rotate_mask[0][63 - n]; + + CPU.GPR[ra] = r & m; + if(rc) CPU.UpdateCR0(CPU.GPR[ra]); } void AND(u32 ra, u32 rs, u32 rb, bool rc) @@ -2376,7 +2381,7 @@ private: } void CMPL(u32 crfd, u32 l, u32 ra, u32 rb) { - CPU.UpdateCRn(crfd, l ? CPU.GPR[ra] : (u32)CPU.GPR[ra], l ? CPU.GPR[rb] : (u32)CPU.GPR[rb]); + CPU.UpdateCRnU(l, crfd, CPU.GPR[ra], CPU.GPR[rb]); } void LVSR(u32 vd, u32 ra, u32 rb) { @@ -2544,24 +2549,38 @@ private: if(rc) CPU.UpdateCR0(CPU.GPR[rd]); if(oe) UNK("addeo"); } - void MTOCRF(u32 crm, u32 rs) + void MTOCRF(u32 l, u32 crm, u32 rs) { - u32 n = 0, count = 0; - for(u32 i=0; i<8; ++i) + if(l) { - if(crm & (1 << i)) + u32 n = 0, count = 0; + for(u32 i=0; i<8; ++i) { - n = i; - count++; + if(crm & (1 << i)) + { + n = i; + count++; + } + } + + if(count == 1) + { + //CR[4*n : 4*n+3] = RS[32+4*n : 32+4*n+3]; + CPU.SetCR(n, (CPU.GPR[rs] >> (4*n)) & 0xf); + } + else + CPU.CR.CR = 0; + } + else + { + for(u32 i=0; i<8; ++i) + { + if(crm & (1 << i)) + { + CPU.SetCR(i, CPU.GPR[rs] & (0xf << i)); + } } } - - if(count == 1) - { - //CR[4*n : 4*n+3] = RS[32+4*n : 32+4*n+3]; - CPU.SetCR(n, (CPU.GPR[rs] >> (4*n)) & 0xf); - } - else CPU.CR.CR = 0; } void STDX(u32 rs, u32 ra, u32 rb) { @@ -2570,21 +2589,24 @@ private: void STWCX_(u32 rs, u32 ra, u32 rb) { CPU.SetCR(0, CPU.XER.SO ? CR_SO : 0); - if(!CPU.reserve) return; - - const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - - if(addr == CPU.reserve_addr) + + if(CPU.reserve) { - Memory.Write32(addr, CPU.GPR[rs]); - CPU.SetCR_EQ(0, true); - } - else - { - static const bool u = 0; - if(u) Memory.Write32(addr, CPU.GPR[rs]); - CPU.SetCR_EQ(0, u); - CPU.reserve = false; + const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; + + if(addr == CPU.reserve_addr) + { + Memory.Write32(addr, CPU.GPR[rs]); + CPU.SetCR_EQ(0, true); + CPU.reserve = false; + } + else + { + static const bool u = 0; + if(u) Memory.Write32(addr, CPU.GPR[rs]); + CPU.SetCR_EQ(0, u); + CPU.reserve = false; + } } } void STWX(u32 rs, u32 ra, u32 rb) @@ -2621,21 +2643,22 @@ private: void STDCX_(u32 rs, u32 ra, u32 rb) { CPU.SetCR(0, CPU.XER.SO ? CR_SO : 0); - if(!CPU.reserve) return; - - const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; - - if(addr == CPU.reserve_addr) + if(!CPU.reserve) { - Memory.Write64(addr, CPU.GPR[rs]); - CPU.SetCR_EQ(0, true); - } - else - { - static const bool u = 0; - if(u) Memory.Write64(addr, CPU.GPR[rs]); - CPU.SetCR_EQ(0, u); - CPU.reserve = false; + const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]; + + if(addr == CPU.reserve_addr) + { + Memory.Write64(addr, CPU.GPR[rs]); + CPU.SetCR_EQ(0, true); + } + else + { + static const bool u = 0; + if(u) Memory.Write64(addr, CPU.GPR[rs]); + CPU.SetCR_EQ(0, u); + CPU.reserve = false; + } } } void STBX(u32 rs, u32 ra, u32 rb) @@ -2724,12 +2747,6 @@ private: { CPU.VPR[vd]._u128 = Memory.Read128((ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfULL); } - void ABS(u32 rd, u32 ra, u32 oe, bool rc) - { - CPU.GPR[rd] = abs((s64)CPU.GPR[ra]); - if(oe) UNK("abso"); - if(rc) CPU.UpdateCR0(CPU.GPR[rd]); - } void MFTB(u32 rd, u32 spr) { const u32 n = (spr >> 5) | ((spr & 0x1f) << 5); @@ -2824,10 +2841,10 @@ private: const s64 RA = CPU.GPR[ra]; const s64 RB = CPU.GPR[rb]; - if (RB == 0 || ((u64)RA == 0x8000000000000000 && RB == -1)) + if (RB == 0 || ((u64)RA == (1ULL << 63) && RB == -1)) { if(oe) UNK("divdo"); - CPU.GPR[rd] = (((u64)RA & 0x8000000000000000) && RB == 0) ? -1 : 0; + CPU.GPR[rd] = (((u64)RA & (1ULL << 63)) && RB == 0) ? -1 : 0; } else { @@ -2841,10 +2858,10 @@ private: const s32 RA = CPU.GPR[ra]; const s32 RB = CPU.GPR[rb]; - if (RB == 0 || ((u32)RA == 0x80000000 && RB == -1)) + if (RB == 0 || ((u32)RA == (1 << 31) && RB == -1)) { if(oe) UNK("divwo"); - CPU.GPR[rd] = (((u32)RA & 0x80000000) && RB == 0) ? -1 : 0; + CPU.GPR[rd] = (((u32)RA & (1 << 31)) && RB == 0) ? -1 : 0; } else { @@ -2871,12 +2888,20 @@ private: } void SRW(u32 ra, u32 rs, u32 rb, bool rc) { - CPU.GPR[ra] = CPU.GPR[rb] & 0x20 ? 0 : (u32)CPU.GPR[rs] >> (CPU.GPR[rb] & 0x1f); + u32 n = CPU.GPR[rb] & 0x1f; + u64 r = rotl32((u32)CPU.GPR[rs], 64 - n); + u64 m = CPU.GPR[rb] & 0x20 ? 0 : rotate_mask[32 + n][63]; + CPU.GPR[ra] = r & m; + if(rc) CPU.UpdateCR0(CPU.GPR[ra]); } void SRD(u32 ra, u32 rs, u32 rb, bool rc) { - CPU.GPR[ra] = CPU.GPR[rb] & 0x40 ? 0 : CPU.GPR[rs] >> (CPU.GPR[rb] & 0x3f); + u32 n = CPU.GPR[rb] & 0x3f; + u64 r = rotl64(CPU.GPR[rs], 64 - n); + u64 m = CPU.GPR[rb] & 0x40 ? 0 : rotate_mask[n][63]; + CPU.GPR[ra] = r & m; + if(rc) CPU.UpdateCR0(CPU.GPR[ra]); } void LVRX(u32 vd, u32 ra, u32 rb) @@ -2915,7 +2940,7 @@ private: } void STFSX(u32 frs, u32 ra, u32 rb) { - Memory.Write32((ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]), PPCdouble(CPU.FPR[frs]).To32()); + Memory.Write32((ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]), CPU.FPR[frs].To32()); } void STVRX(u32 vs, u32 ra, u32 rb) { @@ -2940,7 +2965,7 @@ private: CPU.GPR[rd] = (u16&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]]; } void SRAW(u32 ra, u32 rs, u32 rb, bool rc) - { + { s32 RS = CPU.GPR[rs]; s32 RB = CPU.GPR[rb]; CPU.GPR[ra] = RS >> RB; @@ -3128,12 +3153,12 @@ private: } void STFS(u32 frs, u32 ra, s32 d) { - Memory.Write32(ra ? CPU.GPR[ra] + d : d, PPCdouble(CPU.FPR[frs]).To32()); + Memory.Write32(ra ? CPU.GPR[ra] + d : d, CPU.FPR[frs].To32()); } void STFSU(u32 frs, u32 ra, s32 d) { const u64 addr = CPU.GPR[ra] + d; - Memory.Write32(addr, PPCdouble(CPU.FPR[frs]).To32()); + Memory.Write32(addr, CPU.FPR[frs].To32()); CPU.GPR[ra] = addr; } void STFD(u32 frs, u32 ra, s32 d) @@ -3159,32 +3184,116 @@ private: } void FDIVS(u32 frd, u32 fra, u32 frb, bool rc) { - if(CPU.FPR[frb] == 0.0) CPU.SetFPSCRException(FPSCR_ZX); - CPU.FPR[frd] = static_cast(CPU.FPR[fra] / CPU.FPR[frb]); - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + if(FPRdouble::IsNaN(CPU.FPR[fra])) + { + CPU.FPR[frd] = CPU.FPR[fra]; + } + else if(FPRdouble::IsNaN(CPU.FPR[frb])) + { + CPU.FPR[frd] = CPU.FPR[frb]; + } + else + { + if(CPU.FPR[frb] == 0.0) + { + if(CPU.FPR[fra] == 0.0) + { + CPU.FPSCR.VXZDZ = true; + CPU.FPR[frd] = FPR_NAN; + } + else + { + CPU.FPR[frd] = (float)(CPU.FPR[fra] / CPU.FPR[frb]); + } + + CPU.FPSCR.ZX = true; + } + else if(FPRdouble::IsINF(CPU.FPR[fra]) && FPRdouble::IsINF(CPU.FPR[frb])) + { + CPU.FPSCR.VXIDI = true; + CPU.FPR[frd] = FPR_NAN; + } + else + { + CPU.FPR[frd] = (float)(CPU.FPR[fra] / CPU.FPR[frb]); + } + } + + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fdivs.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FSUBS(u32 frd, u32 fra, u32 frb, bool rc) { CPU.FPR[frd] = static_cast(CPU.FPR[fra] - CPU.FPR[frb]); - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fsubs.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FADDS(u32 frd, u32 fra, u32 frb, bool rc) { CPU.FPR[frd] = static_cast(CPU.FPR[fra] + CPU.FPR[frb]); - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fadds.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FSQRTS(u32 frd, u32 frb, bool rc) { - CPU.FPR[frd] = static_cast(sqrt((float)CPU.FPR[frb])); + CPU.FPR[frd] = static_cast(sqrt(CPU.FPR[frb])); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fsqrts.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FRES(u32 frd, u32 frb, bool rc) { - if(CPU.FPR[frb] == 0.0) CPU.SetFPSCRException(FPSCR_ZX); - CPU.FPR[frd] = static_cast(1.0f/CPU.FPR[frb]); + double res; + + if(_fpclass(CPU.FPR[frb]) >= _FPCLASS_NZ) + { + res = static_cast(1.0 / CPU.FPR[frb]); + if(FPRdouble::IsINF(res) && CPU.FPR[frb] != 0.0) + { + if(res > 0.0) + { + (u64&)res = 0x47EFFFFFE0000000ULL; + } + else + { + (u64&)res = 0xC7EFFFFFE0000000ULL; + } + } + } + else + { + u64 v = CPU.FPR[frb]; + + if(v == 0ULL) + { + v = 0x7FF0000000000000ULL; + } + else if(v == 0x8000000000000000ULL) + { + v = 0xFFF0000000000000ULL; + } + else if(FPRdouble::IsNaN(CPU.FPR[frb])) + { + v = 0x7FF8000000000000ULL; + } + else if(CPU.FPR[frb] < 0.0) + { + v = 0x8000000000000000ULL; + } + else + { + v = 0ULL; + } + + res = (double&)v; + } + + if(CPU.FPR[frb] == 0.0) + { + CPU.SetFPSCRException(FPSCR_ZX); + } + + CPU.FPR[frd] = res; + if(rc) UNK("fres.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FMULS(u32 frd, u32 fra, u32 frc, bool rc) @@ -3192,31 +3301,31 @@ private: CPU.FPR[frd] = static_cast(CPU.FPR[fra] * CPU.FPR[frc]); CPU.FPSCR.FI = 0; CPU.FPSCR.FR = 0; - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fmuls.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FMADDS(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) { CPU.FPR[frd] = static_cast(CPU.FPR[fra] * CPU.FPR[frc] + CPU.FPR[frb]); - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fmadds.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FMSUBS(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) { CPU.FPR[frd] = static_cast(CPU.FPR[fra] * CPU.FPR[frc] - CPU.FPR[frb]); - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fmsubs.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FNMSUBS(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) { CPU.FPR[frd] = static_cast(-(CPU.FPR[fra] * CPU.FPR[frc] - CPU.FPR[frb])); - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fnmsubs.");////CPU.UpdateCR1(CPU.FPR[frd]); } void FNMADDS(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) { CPU.FPR[frd] = static_cast(-(CPU.FPR[fra] * CPU.FPR[frc] + CPU.FPR[frb])); - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fnmadds.");//CPU.UpdateCR1(CPU.FPR[frd]); } void STD(u32 rs, u32 ra, s32 d) @@ -3230,26 +3339,45 @@ private: Memory.Write64(addr, CPU.GPR[rs]); CPU.GPR[ra] = addr; } - void MTFSB1(u32 bt, bool rc) + void MTFSB1(u32 crbd, bool rc) { - UNIMPLEMENTED(); + u64 mask = (1ULL << crbd); + CPU.FPSCR.FPSCR |= mask; + + if(rc) UNIMPLEMENTED(); } - void MCRFS(u32 bf, u32 bfa) + void MCRFS(u32 crbd, u32 crbs) { - UNIMPLEMENTED(); + u64 mask = (1ULL << crbd); + CPU.CR.CR &= ~mask; + CPU.CR.CR |= CPU.FPSCR.FPSCR & mask; } - void MTFSB0(u32 bt, bool rc) + void MTFSB0(u32 crbd, bool rc) { - UNIMPLEMENTED(); + u64 mask = (1ULL << crbd); + CPU.FPSCR.FPSCR &= ~mask; + + if(rc) UNIMPLEMENTED(); } void MTFSFI(u32 crfd, u32 i, bool rc) { - UNIMPLEMENTED(); + u64 mask = (0x1ULL << crfd); + + if(i) + { + CPU.FPSCR.FPSCR |= mask; + } + else + { + CPU.FPSCR.FPSCR &= ~mask; + } + + if(rc) UNIMPLEMENTED(); } void MFFS(u32 frd, bool rc) { (u64&)CPU.FPR[frd] = CPU.FPSCR.FPSCR; - if(rc) UNK("mffs."); + if(rc) UNIMPLEMENTED(); } void MTFSF(u32 flm, u32 frb, bool rc) { @@ -3264,7 +3392,9 @@ private: } void FCMPU(u32 crfd, u32 fra, u32 frb) { - if((CPU.FPSCR.FPRF = FPRdouble::Cmp(CPU.FPR[fra], CPU.FPR[frb])) == 1) + int cmp_res = FPRdouble::Cmp(CPU.FPR[fra], CPU.FPR[frb]); + + if(cmp_res == CR_SO) { if(FPRdouble::IsSNaN(CPU.FPR[fra]) || FPRdouble::IsSNaN(CPU.FPR[frb])) { @@ -3272,7 +3402,8 @@ private: } } - CPU.SetCR(crfd, CPU.FPSCR.FPRF); + CPU.FPSCR.FPRF = cmp_res; + CPU.SetCR(crfd, cmp_res); } void FRSP(u32 frd, u32 frb, bool rc) { @@ -3392,39 +3523,63 @@ private: } void FDIV(u32 frd, u32 fra, u32 frb, bool rc) { - if(FPRdouble::IsINF(CPU.FPR[fra]) == 0.0 && CPU.FPR[frb] == 0.0) + double res; + + if(FPRdouble::IsNaN(CPU.FPR[fra])) { - CPU.FPSCR.VXZDZ = 1; + res = CPU.FPR[fra]; } - else if(FPRdouble::IsINF(CPU.FPR[fra]) && FPRdouble::IsINF(CPU.FPR[frb])) + else if(FPRdouble::IsNaN(CPU.FPR[frb])) { - CPU.FPSCR.VXIDI = 1; + res = CPU.FPR[frb]; } - else if(CPU.FPR[fra] != 0.0 && CPU.FPR[frb] == 0.0) + else { - CPU.SetFPSCRException(FPSCR_ZX); + if(CPU.FPR[frb] == 0.0) + { + if(CPU.FPR[fra] == 0.0) + { + CPU.FPSCR.VXZDZ = 1; + res = FPR_NAN; + } + else + { + res = CPU.FPR[fra] / CPU.FPR[frb]; + } + + CPU.SetFPSCRException(FPSCR_ZX); + } + else if(FPRdouble::IsINF(CPU.FPR[fra]) && FPRdouble::IsINF(CPU.FPR[frb])) + { + CPU.FPSCR.VXIDI = 1; + res = FPR_NAN; + } + else + { + res = CPU.FPR[fra] / CPU.FPR[frb]; + } } - CPU.FPR[frd] = CPU.FPR[fra] / CPU.FPR[frb]; - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPR[frd] = res; + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fdiv.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FSUB(u32 frd, u32 fra, u32 frb, bool rc) { CPU.FPR[frd] = CPU.FPR[fra] - CPU.FPR[frb]; - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fsub.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FADD(u32 frd, u32 fra, u32 frb, bool rc) { CPU.FPR[frd] = CPU.FPR[fra] + CPU.FPR[frb]; - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fadd.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FSQRT(u32 frd, u32 frb, bool rc) { CPU.FPR[frd] = sqrt(CPU.FPR[frb]); - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fsqrt.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FSEL(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) @@ -3434,50 +3589,68 @@ private: } void FMUL(u32 frd, u32 fra, u32 frc, bool rc) { - CPU.FPR[frd] = CPU.FPR[fra] * CPU.FPR[frc]; - CPU.FPSCR.FI = 0; - CPU.FPSCR.FR = 0; - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + if((FPRdouble::IsINF(CPU.FPR[fra]) && CPU.FPR[frc] == 0.0) || (FPRdouble::IsINF(CPU.FPR[frc]) && CPU.FPR[fra] == 0.0)) + { + CPU.SetFPSCRException(FPSCR_VXIMZ); + CPU.FPR[frd] = FPR_NAN; + CPU.FPSCR.FI = 0; + CPU.FPSCR.FR = 0; + CPU.FPSCR.FPRF = FPR_QNAN; + } + else + { + if(FPRdouble::IsSNaN(CPU.FPR[fra]) || FPRdouble::IsSNaN(CPU.FPR[frc])) + { + CPU.SetFPSCRException(FPSCR_VXSNAN); + } + + CPU.FPR[frd] = CPU.FPR[fra] * CPU.FPR[frc]; + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); + } + if(rc) UNK("fmul.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FRSQRTE(u32 frd, u32 frb, bool rc) { UNIMPLEMENTED(); + //CPU.FPR[frd] = 1.0f / (float)sqrt(CPU.FPR[frb]); } void FMSUB(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) { CPU.FPR[frd] = CPU.FPR[fra] * CPU.FPR[frc] - CPU.FPR[frb]; - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fmsub.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FMADD(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) { CPU.FPR[frd] = CPU.FPR[fra] * CPU.FPR[frc] + CPU.FPR[frb]; - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fmadd.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FNMSUB(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) { CPU.FPR[frd] = -(CPU.FPR[fra] * CPU.FPR[frc] - CPU.FPR[frb]); - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fnmsub.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FNMADD(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) { CPU.FPR[frd] = -(CPU.FPR[fra] * CPU.FPR[frc] + CPU.FPR[frb]); - CPU.FPSCR.FPRF = PPCdouble(CPU.FPR[frd]).GetType(); + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fnmadd.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FCMPO(u32 crfd, u32 fra, u32 frb) { - if((CPU.FPSCR.FPRF = FPRdouble::Cmp(CPU.FPR[fra], CPU.FPR[frb])) == 1) + int cmp_res = FPRdouble::Cmp(CPU.FPR[fra], CPU.FPR[frb]); + + if(cmp_res == CR_SO) { if(FPRdouble::IsSNaN(CPU.FPR[fra]) || FPRdouble::IsSNaN(CPU.FPR[frb])) { CPU.SetFPSCRException(FPSCR_VXSNAN); if(!CPU.FPSCR.VE) CPU.SetFPSCRException(FPSCR_VXVC); } - else if(FPRdouble::IsQNaN(CPU.FPR[fra]) || FPRdouble::IsQNaN(CPU.FPR[frb])) + else { CPU.SetFPSCRException(FPSCR_VXVC); } @@ -3485,7 +3658,8 @@ private: CPU.FPSCR.FX = 1; } - CPU.SetCR(crfd, CPU.FPSCR.FPRF); + CPU.FPSCR.FPRF = cmp_res; + CPU.SetCR(crfd, cmp_res); } void FNEG(u32 frd, u32 frb, bool rc) { @@ -3499,7 +3673,7 @@ private: } void FNABS(u32 frd, u32 frb, bool rc) { - (u64&)CPU.FPR[frd] = (u64&)CPU.FPR[frb] | 0x8000000000000000ULL; + CPU.FPR[frd] = -fabs(CPU.FPR[frb]); if(rc) UNK("fnabs.");//CPU.UpdateCR1(CPU.FPR[frd]); } void FABS(u32 frd, u32 frb, bool rc) @@ -3610,7 +3784,24 @@ private: } void FCFID(u32 frd, u32 frb, bool rc) { - CPU.FPR[frd] = (double)(u64&)CPU.FPR[frb]; + s64 bi = (s64&)CPU.FPR[frb]; + double bf = (double)bi; + s64 bfi = (s64)bf; + + if(bi == bfi) + { + CPU.SetFPSCR_FI(0); + CPU.FPSCR.FR = 0; + } + else + { + CPU.SetFPSCR_FI(1); + CPU.FPSCR.FR = abs(bfi) > abs(bi); + } + + CPU.FPR[frd] = bf; + + CPU.FPSCR.FPRF = CPU.FPR[frd].GetType(); if(rc) UNK("fcfid.");//CPU.UpdateCR1(CPU.FPR[frd]); } diff --git a/rpcs3/Emu/Cell/PPUOpcodes.h b/rpcs3/Emu/Cell/PPUOpcodes.h index bd25e4025a..21e5fbf7c3 100644 --- a/rpcs3/Emu/Cell/PPUOpcodes.h +++ b/rpcs3/Emu/Cell/PPUOpcodes.h @@ -318,7 +318,6 @@ namespace PPU_opcodes DST = 0x156, //Data Stream Touch LHAX = 0x157, LVXL = 0x167, //Load Vector Indexed Last - ABS = 0x168, MFTB = 0x173, DSTST = 0x176, //Data Stream Touch for Store LHAUX = 0x177, @@ -436,8 +435,8 @@ public: static u64 branchTarget(const u64 pc, const u64 imm) { - return pc + (imm & ~0x3); - } + return pc + (imm & ~0x3ULL); + } virtual void NULL_OP() = 0; virtual void NOP() = 0; @@ -498,7 +497,7 @@ public: virtual void VCTUXS(u32 vd, u32 uimm5, u32 vb) = 0; virtual void VEXPTEFP(u32 vd, u32 vb) = 0; virtual void VLOGEFP(u32 vd, u32 vb) = 0; - virtual void VMADDFP(u32 vd, u32 va, u32 vb, u32 vc) = 0; + virtual void VMADDFP(u32 vd, u32 va, u32 vc, u32 vb) = 0; virtual void VMAXFP(u32 vd, u32 va, u32 vb) = 0; virtual void VMAXSB(u32 vd, u32 va, u32 vb) = 0; virtual void VMAXSH(u32 vd, u32 va, u32 vb) = 0; @@ -536,7 +535,7 @@ public: virtual void VMULOSH(u32 vd, u32 va, u32 vb) = 0; virtual void VMULOUB(u32 vd, u32 va, u32 vb) = 0; virtual void VMULOUH(u32 vd, u32 va, u32 vb) = 0; - virtual void VNMSUBFP(u32 vd, u32 va, u32 vb, u32 vc) = 0; + virtual void VNMSUBFP(u32 vd, u32 va, u32 vc, u32 vb) = 0; virtual void VNOR(u32 vd, u32 va, u32 vb) = 0; virtual void VOR(u32 vd, u32 va, u32 vb) = 0; virtual void VPERM(u32 vd, u32 va, u32 vb, u32 vc) = 0; @@ -675,7 +674,7 @@ public: virtual void STVEBX(u32 vs, u32 ra, u32 rb) = 0; virtual void SUBFE(u32 rd, u32 ra, u32 rb, u32 oe, bool rc) = 0; virtual void ADDE(u32 rd, u32 ra, u32 rb, u32 oe, bool rc) = 0; - virtual void MTOCRF(u32 crm, u32 rs) = 0; + virtual void MTOCRF(u32 l, u32 crm, u32 rs) = 0; virtual void STDX(u32 rs, u32 ra, u32 rb) = 0; virtual void STWCX_(u32 rs, u32 ra, u32 rb) = 0; virtual void STWX(u32 rs, u32 ra, u32 rb) = 0; @@ -701,7 +700,6 @@ public: virtual void DST(u32 ra, u32 rb, u32 strm, u32 t) = 0; virtual void LHAX(u32 rd, u32 ra, u32 rb) = 0; virtual void LVXL(u32 vd, u32 ra, u32 rb) = 0; - virtual void ABS(u32 rd, u32 ra, u32 oe, bool rc) = 0; virtual void MFTB(u32 rd, u32 spr) = 0; virtual void DSTST(u32 ra, u32 rb, u32 strm, u32 t) = 0; virtual void LHAUX(u32 rd, u32 ra, u32 rb) = 0; @@ -741,7 +739,7 @@ public: virtual void SRADI1(u32 ra, u32 rs, u32 sh, bool rc) = 0; virtual void SRADI2(u32 ra, u32 rs, u32 sh, bool rc) = 0; virtual void EIEIO() = 0; - virtual void STVLXL(u32 sd, u32 ra, u32 rb) = 0; + virtual void STVLXL(u32 vs, u32 ra, u32 rb) = 0; virtual void EXTSH(u32 ra, u32 rs, bool rc) = 0; virtual void STVRXL(u32 sd, u32 ra, u32 rb) = 0; virtual void EXTSB(u32 ra, u32 rs, bool rc) = 0; diff --git a/rpcs3/Emu/Cell/PPUProgramCompiler.cpp b/rpcs3/Emu/Cell/PPUProgramCompiler.cpp index 8733ab4a36..c645a2cf7f 100644 --- a/rpcs3/Emu/Cell/PPUProgramCompiler.cpp +++ b/rpcs3/Emu/Cell/PPUProgramCompiler.cpp @@ -72,7 +72,7 @@ SectionInfo::SectionInfo(const wxString& _name) : name(_name) shdr.sh_offset = section_offs; shdr.sh_name = section_name_offs; - section_name_offs += name.Len() + 1; + section_name_offs += name.GetCount() + 1; } void SectionInfo::SetDataSize(u32 size, u32 align) @@ -107,11 +107,11 @@ SectionInfo::~SectionInfo() for(u32 i=section_num + 1; i= 0) return m_text_addr + m_branches[i].m_pos * 4; return m_branches[i].m_addr; @@ -664,7 +664,7 @@ CompilePPUProgram::Branch& CompilePPUProgram::GetBranch(const wxString& name) { for(u32 i=0; i> 16)); //oris r12,r12,addr>>16 - Write32(f, ToOpcode(LWZ) | ToRD(12) | ToRA(12) | ToIMM16(addr)); //lwz r12,addr&0xffff(r12) - Write32(f, 0xf8410028); //std r2,40(r1) - Write32(f, ToOpcode(LWZ) | ToRD(0) | ToRA(12) | ToIMM16(0)); //lwz r0,0(r12) - Write32(f, ToOpcode(LWZ) | ToRD(2) | ToRA(12) | ToIMM16(4)); //lwz r2,4(r12) - Write32(f, 0x7c0903a6); //mtctr r0 - Write32(f, 0x4e800420); //bctr - */ } f.Seek(s_lib_stub_top.sh_offset); diff --git a/rpcs3/Emu/Cell/PPUProgramCompiler.h b/rpcs3/Emu/Cell/PPUProgramCompiler.h index b86d4f7a3e..23b92e43d6 100644 --- a/rpcs3/Emu/Cell/PPUProgramCompiler.h +++ b/rpcs3/Emu/Cell/PPUProgramCompiler.h @@ -19,7 +19,7 @@ enum ArgType struct Arg { - wxString string; + ArrayString string; u32 value; ArgType type; @@ -34,7 +34,7 @@ struct Arg struct SectionInfo { Elf64_Shdr shdr; - wxString name; + ArrayString name; Array code; u32 section_num; @@ -62,7 +62,7 @@ class CompilePPUProgram { struct Branch { - wxString m_name; + ArrayString m_name; s32 m_pos; s32 m_id; s32 m_addr; @@ -101,7 +101,7 @@ class CompilePPUProgram struct SpData { - wxString m_data; + ArrayString m_data; u32 m_addr; SpData(const wxString& data, u32 addr) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 0b8eb74234..548d8ca9ba 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -3,14 +3,14 @@ #include "Emu/Cell/PPUDecoder.h" #include "Emu/Cell/PPUInterpreter.h" #include "Emu/Cell/PPUDisAsm.h" - +#include extern gcmInfo gcm_info; PPUThread& GetCurrentPPUThread() { PPCThread* thread = GetCurrentPPCThread(); - if(!thread || thread->IsSPU()) throw wxString("GetCurrentPPUThread: bad thread"); + if(!thread || thread->GetType() != PPC_THREAD_PPU) throw wxString("GetCurrentPPUThread: bad thread"); return *(PPUThread*)thread; } @@ -60,28 +60,15 @@ void PPUThread::AddArgv(const wxString& arg) void PPUThread::InitRegs() { - const u32 entry = Memory.Read32(PC); - const u32 rtoc = Memory.Read32(PC + 4); + const u32 pc = Memory.Read32(entry); + const u32 rtoc = Memory.Read32(entry + 4); - ConLog.Write("entry = 0x%x", entry); - ConLog.Write("rtoc = 0x%x", rtoc); + //ConLog.Write("entry = 0x%x", entry); + //ConLog.Write("rtoc = 0x%x", rtoc); - SetPc(entry); - - u64 argc = m_arg; - u64 argv = 0; + SetPc(pc); - if(argv_addr.GetCount()) - { - argc = argv_addr.GetCount(); - stack_point -= 0xc + 4 * argc; - argv = stack_point; - - mem64_t argv_list(argv); - for(int i=0; i 220) { @@ -195,7 +217,7 @@ void PPUThread::DoCode(const s32 code) bool FPRdouble::IsINF(PPCdouble d) { - return wxFinite(d) ? 1 : 0; + return ((u64&)d & 0x7FFFFFFFFFFFFFFFULL) == 0x7FF0000000000000ULL; } bool FPRdouble::IsNaN(PPCdouble d) @@ -205,12 +227,18 @@ bool FPRdouble::IsNaN(PPCdouble d) bool FPRdouble::IsQNaN(PPCdouble d) { - return d.GetType() == FPR_QNAN; + return + ((u64&)d & 0x7FF0000000000000ULL) == 0x7FF0000000000000ULL && + ((u64&)d & 0x0007FFFFFFFFFFFULL) == 0ULL && + ((u64&)d & 0x000800000000000ULL) != 0ULL; } bool FPRdouble::IsSNaN(PPCdouble d) { - return d.GetType() == FPR_SNAN; + return + ((u64&)d & 0x7FF0000000000000ULL) == 0x7FF0000000000000ULL && + ((u64&)d & 0x000FFFFFFFFFFFFFULL) != 0ULL && + ((u64&)d & 0x0008000000000000ULL) == 0ULL; } int FPRdouble::Cmp(PPCdouble a, PPCdouble b) diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index 7e1c150632..6954c31412 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -18,6 +18,18 @@ enum CR_SO = 0x1, }; +enum +{ + PPU_THREAD_STATUS_IDLE = (1 << 0), + PPU_THREAD_STATUS_RUNNABLE = (1 << 1), + PPU_THREAD_STATUS_ONPROC = (1 << 2), + PPU_THREAD_STATUS_SLEEP = (1 << 3), + PPU_THREAD_STATUS_STOP = (1 << 4), + PPU_THREAD_STATUS_ZOMBIE = (1 << 5), + PPU_THREAD_STATUS_DELETED = (1 << 6), + PPU_THREAD_STATUS_UNKNOWN = (1 << 7), +}; + enum FPSCR_EXP { FPSCR_FX = 0x80000000, @@ -286,11 +298,11 @@ union VSCRhdr enum FPRType { - FPR_NORM, - FPR_ZERO, - FPR_SNAN, + //FPR_NORM, + //FPR_ZERO, + //FPR_SNAN, //FPR_QNAN, - FPR_INF, + //FPR_INF, FPR_PZ = 0x2, FPR_PN = 0x4, FPR_PINF = 0x5, @@ -302,6 +314,9 @@ enum FPRType FPR_ND = 0x18, }; +static const u64 FPR_NAN_I = 0x7FF8000000000000ULL; +static const double& FPR_NAN = (double&)FPR_NAN_I; + struct PPCdouble { union @@ -342,7 +357,7 @@ struct PPCdouble switch(fpc) { - case _FPCLASS_SNAN: return FPR_SNAN; + case _FPCLASS_SNAN:// return FPR_SNAN; case _FPCLASS_QNAN: return FPR_QNAN; case _FPCLASS_NINF: return FPR_NINF; case _FPCLASS_NN: return FPR_NN; @@ -652,6 +667,30 @@ public: SetCR_SO(n, XER.SO); } + void UpdateCRnU(const u8 l, const u8 n, const u64 a, const u64 b) + { + if(l) + { + UpdateCRn(n, a, b); + } + else + { + UpdateCRn(n, a, b); + } + } + + void UpdateCRnS(const u8 l, const u8 n, const u64 a, const u64 b) + { + if(l) + { + UpdateCRn(n, a, b); + } + else + { + UpdateCRn(n, a, b); + } + } + template void UpdateCR0(const T val) { UpdateCRn(0, val, 0); @@ -683,7 +722,7 @@ public: void SetFPSCR_FI(const u32 val) { if(val) SetFPSCRException(FPSCR_XX); - FPSCR.FI = val; + FPSCR.FI = val; } virtual wxString RegsToString() diff --git a/rpcs3/Emu/Cell/RawSPUThread.cpp b/rpcs3/Emu/Cell/RawSPUThread.cpp new file mode 100644 index 0000000000..370550cea7 --- /dev/null +++ b/rpcs3/Emu/Cell/RawSPUThread.cpp @@ -0,0 +1,131 @@ +#include "stdafx.h" +#include "Emu/Cell/RawSPUThread.h" + +RawSPUThread::RawSPUThread(PPCThreadType type) : SPUThread(type) +{ + Reset(); +} + +RawSPUThread::~RawSPUThread() +{ +} + +void RawSPUThread::InitRegs() +{ + GPR[3]._u64[1] = m_args[0]; + GPR[4]._u64[1] = m_args[1]; + GPR[5]._u64[1] = m_args[2]; + GPR[6]._u64[1] = m_args[3]; + + u32 num = Emu.GetCPU().GetThreadNumById(GetType(), GetId()); + + m_offset = RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * num + RAW_SPU_LS_OFFSET; + mfc.dmac.ls_offset = m_offset; + mfc.dmac.proxy_pos = 0; + mfc.dmac.queue_pos = 0; + mfc.MFC_LSA.SetAddr(GetRawSPURegAddrByNum(num, MFC_LSA_offs)); + mfc.MFC_EAH.SetAddr(GetRawSPURegAddrByNum(num, MFC_EAH_offs)); + mfc.MFC_EAL.SetAddr(GetRawSPURegAddrByNum(num, MFC_EAL_offs)); + mfc.MFC_Size_Tag.SetAddr(GetRawSPURegAddrByNum(num, MFC_Size_Tag_offs)); + mfc.MFC_CMDStatus.SetAddr(GetRawSPURegAddrByNum(num, MFC_CMDStatus_offs)); + mfc.MFC_QStatus.SetAddr(GetRawSPURegAddrByNum(num, MFC_QStatus_offs)); + mfc.Prxy_QueryType.SetAddr(GetRawSPURegAddrByNum(num, Prxy_QueryType_offs)); + mfc.Prxy_QueryMask.SetAddr(GetRawSPURegAddrByNum(num, Prxy_QueryMask_offs)); + mfc.Prxy_TagStatus.SetAddr(GetRawSPURegAddrByNum(num, Prxy_TagStatus_offs)); + mfc.SPU_Out_MBox.SetAddr(GetRawSPURegAddrByNum(num, SPU_Out_MBox_offs)); + mfc.SPU_In_MBox.SetAddr(GetRawSPURegAddrByNum(num, SPU_In_MBox_offs)); + mfc.SPU_MBox_Status.SetAddr(GetRawSPURegAddrByNum(num, SPU_MBox_Status_offs)); + mfc.SPU_RunCntl.SetAddr(GetRawSPURegAddrByNum(num, SPU_RunCntl_offs)); + mfc.SPU_Status.SetAddr(GetRawSPURegAddrByNum(num, SPU_Status_offs)); + mfc.SPU_NPC.SetAddr(GetRawSPURegAddrByNum(num, SPU_NPC_offs)); + mfc.SPU_RdSigNotify1.SetAddr(GetRawSPURegAddrByNum(num, SPU_RdSigNotify1_offs)); + mfc.SPU_RdSigNotify2.SetAddr(GetRawSPURegAddrByNum(num, SPU_RdSigNotify2_offs)); + + mfc.SPU_RunCntl.SetValue(SPU_RUNCNTL_STOP); + mfc.SPU_Status.SetValue(SPU_STATUS_RUNNING); + mfc.Prxy_QueryType.SetValue(0); + mfc.MFC_CMDStatus.SetValue(0); + PC = mfc.SPU_NPC.GetValue(); +} + +void RawSPUThread::Task() +{ + ConLog.Write("%s enter", PPCThread::GetFName()); + + const Array& bp = Emu.GetBreakPoints(); + + try + { + for(uint i=0; i(10 - (int)op.Len(), 0)); + return op; + } + void DisAsm(const char* op) + { + Write(op); + } + void DisAsm(wxString op, u32 a1) + { + Write(wxString::Format("%s 0x%x", FixOp(op), a1)); + } + void DisAsm(wxString op, const char* a1) + { + Write(wxString::Format("%s %s", FixOp(op), a1)); + } + void DisAsm(wxString op, const char* a1, const char* a2) + { + Write(wxString::Format("%s %s,%s", FixOp(op), a1, a2)); + } + void DisAsm(wxString op, int a1, const char* a2) + { + Write(wxString::Format("%s 0x%x,%s", FixOp(op), a1, a2)); + } + void DisAsm(wxString op, const char* a1, int a2) + { + Write(wxString::Format("%s %s,0x%x", FixOp(op), a1, a2)); + } + void DisAsm(wxString op, int a1, int a2) + { + Write(wxString::Format("%s 0x%x,0x%x", FixOp(op), a1, a2)); + } + void DisAsm(wxString op, const char* a1, const char* a2, const char* a3) + { + Write(wxString::Format("%s %s,%s,%s", FixOp(op), a1, a2, a3)); + } + void DisAsm(wxString op, const char* a1, int a2, const char* a3) + { + Write(wxString::Format("%s %s,0x%x(%s)", FixOp(op), a1, a2, a3)); + } + void DisAsm(wxString op, const char* a1, const char* a2, int a3) + { + Write(wxString::Format("%s %s,%s,0x%x", FixOp(op), a1, a2, a3)); + } + void DisAsm(wxString op, const char* a1, const char* a2, const char* a3, const char* a4) + { + Write(wxString::Format("%s %s,%s,%s,%s", FixOp(op), a1, a2, a3, a4)); + } //0 - 10 void STOP(u32 code) { - Write(wxString::Format("stop 0x%x", code)); + DisAsm("stop", code); } void LNOP() { - Write("lnop"); + DisAsm("lnop"); } void SYNC(u32 Cbit) { - Write(wxString::Format("sync %d", Cbit)); + DisAsm("sync", Cbit); } void DSYNC() { - Write("dsync"); + DisAsm("dsync"); } void MFSPR(u32 rt, u32 sa) { - Write(wxString::Format("mfspr %s,%s", spu_reg_name[rt], spu_reg_name[sa])); // Are SPR mapped on the GPR or are there 128 additional registers ? + DisAsm("mfspr", spu_reg_name[rt], spu_reg_name[sa]); // Are SPR mapped on the GPR or are there 128 additional registers ? } void RDCH(u32 rt, u32 ra) { - Write(wxString::Format("rdch %s,%s", spu_reg_name[rt], spu_ch_name[ra])); + DisAsm("rdch", spu_reg_name[rt], spu_ch_name[ra]); } void RCHCNT(u32 rt, u32 ra) { - Write(wxString::Format("rchcnt %s,%s", spu_reg_name[rt], spu_ch_name[ra])); + DisAsm("rchcnt", spu_reg_name[rt], spu_ch_name[ra]); } void SF(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("sf %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("sf", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void OR(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("or %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("or", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void BG(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("bg %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("bg", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void SFH(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("sfh %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("sfh", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void NOR(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("nor %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("nor", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ABSDB(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("absdb %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("absdb", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROT(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rot %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rot", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTM(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rotm %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rotm", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTMA(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rotma %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rotma", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void SHL(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("shl %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("shl", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTH(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("roth %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("roth", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTHM(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rothm %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rothm", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTMAH(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rotmah %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rotmah", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void SHLH(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("shlh %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("shlh", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("roti %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("roti", spu_reg_name[rt], spu_reg_name[ra], i7); } void ROTMI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("rotmi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("rotmi", spu_reg_name[rt], spu_reg_name[ra], i7); } void ROTMAI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("rotmai %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("rotmai", spu_reg_name[rt], spu_reg_name[ra], i7); } void SHLI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("shli %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("shli", spu_reg_name[rt], spu_reg_name[ra], i7); } void ROTHI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("rothi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("rothi", spu_reg_name[rt], spu_reg_name[ra], i7); } void ROTHMI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("rothmi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("rothmi", spu_reg_name[rt], spu_reg_name[ra], i7); } void ROTMAHI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("rotmahi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("rotmahi", spu_reg_name[rt], spu_reg_name[ra], i7); } void SHLHI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("shlhi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("shlhi", spu_reg_name[rt], spu_reg_name[ra], i7); } void A(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("a %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("a", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void AND(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("and %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("and", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CG(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("cg %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("cg", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void AH(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("ah %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("ah", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void NAND(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("nand %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("nand", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void AVGB(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("avgb %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("avgb", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void MTSPR(u32 rt, u32 sa) { - Write(wxString::Format("mtspr %s,%s", spu_reg_name[rt], spu_reg_name[sa])); + DisAsm("mtspr", spu_reg_name[rt], spu_reg_name[sa]); } void WRCH(u32 ra, u32 rt) { - Write(wxString::Format("wrch %s,%s", spu_ch_name[ra], spu_reg_name[rt])); + DisAsm("wrch", spu_ch_name[ra], spu_reg_name[rt]); } void BIZ(u32 rt, u32 ra) { - Write(wxString::Format("biz %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("biz", spu_reg_name[rt], spu_reg_name[ra]); } void BINZ(u32 rt, u32 ra) { - Write(wxString::Format("binz %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("binz", spu_reg_name[rt], spu_reg_name[ra]); } void BIHZ(u32 rt, u32 ra) { - Write(wxString::Format("bihz %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("bihz", spu_reg_name[rt], spu_reg_name[ra]); } void BIHNZ(u32 rt, u32 ra) { - Write(wxString::Format("bihnz %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("bihnz", spu_reg_name[rt], spu_reg_name[ra]); } void STOPD(u32 rc, u32 ra, u32 rb) { - Write(wxString::Format("bihnz %s,%s,%s", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("bihnz", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb]); } void STQX(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("stqx %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("stqx", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void BI(u32 ra) { - Write(wxString::Format("bi %s", spu_reg_name[ra])); + DisAsm("bi", spu_reg_name[ra]); } void BISL(u32 rt, u32 ra) { - Write(wxString::Format("bisl %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("bisl", spu_reg_name[rt], spu_reg_name[ra]); } void IRET(u32 ra) { - Write(wxString::Format("iret %s", spu_reg_name[ra])); + DisAsm("iret", spu_reg_name[ra]); } void BISLED(u32 rt, u32 ra) { - Write(wxString::Format("bisled %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("bisled", spu_reg_name[rt], spu_reg_name[ra]); } void HBR(u32 p, u32 ro, u32 ra) { - Write(wxString::Format("hbr 0x%x,%s", DisAsmBranchTarget(ro), spu_reg_name[ra])); + DisAsm("hbr", DisAsmBranchTarget(ro), spu_reg_name[ra]); } void GB(u32 rt, u32 ra) { - Write(wxString::Format("gb %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("gb", spu_reg_name[rt], spu_reg_name[ra]); } void GBH(u32 rt, u32 ra) { - Write(wxString::Format("gbh %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("gbh", spu_reg_name[rt], spu_reg_name[ra]); } void GBB(u32 rt, u32 ra) { - Write(wxString::Format("gbb %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("gbb", spu_reg_name[rt], spu_reg_name[ra]); } void FSM(u32 rt, u32 ra) { - Write(wxString::Format("fsm %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("fsm", spu_reg_name[rt], spu_reg_name[ra]); } void FSMH(u32 rt, u32 ra) { - Write(wxString::Format("fsmh %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("fsmh", spu_reg_name[rt], spu_reg_name[ra]); } void FSMB(u32 rt, u32 ra) { - Write(wxString::Format("fsmb %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("fsmb", spu_reg_name[rt], spu_reg_name[ra]); } void FREST(u32 rt, u32 ra) { - Write(wxString::Format("frest %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("frest", spu_reg_name[rt], spu_reg_name[ra]); } void FRSQEST(u32 rt, u32 ra) { - Write(wxString::Format("frsqest %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("frsqest", spu_reg_name[rt], spu_reg_name[ra]); } void LQX(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("lqx %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("lqx", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTQBYBI(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rotqbybi %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rotqbybi", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTQMBYBI(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rotqmbybi %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rotqmbybi", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void SHLQBYBI(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("shlqbybi %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("shlqbybi", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CBX(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("cbx %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("cbx", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CHX(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("chx %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("chx", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CWX(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("cwx %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("cwx", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CDX(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("cdx %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("cdx", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTQBI(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rotqbi %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rotqbi", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTQMBI(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rotqmbi %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rotqmbi", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void SHLQBI(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("shlqbi %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("shlqbi", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTQBY(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rotqby %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rotqby", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ROTQMBY(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("rotqmby %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("rotqmby", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void SHLQBY(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("shlqby %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("shlqby", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ORX(u32 rt, u32 ra) { - Write(wxString::Format("orx %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("orx", spu_reg_name[rt], spu_reg_name[ra]); } void CBD(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("cbd %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("cbd", spu_reg_name[rt], spu_reg_name[ra], i7); } void CHD(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("chd %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("chd", spu_reg_name[rt], spu_reg_name[ra], i7); } void CWD(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("cwd %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("cwd", spu_reg_name[rt], spu_reg_name[ra], i7); } void CDD(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("cdd %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("cdd", spu_reg_name[rt], spu_reg_name[ra], i7); } void ROTQBII(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("rotqbii %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("rotqbii", spu_reg_name[rt], spu_reg_name[ra], i7); } void ROTQMBII(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("rotqmbii %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("rotqmbii", spu_reg_name[rt], spu_reg_name[ra], i7); } void SHLQBII(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("shlqbii %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("shlqbii", spu_reg_name[rt], spu_reg_name[ra], i7); } void ROTQBYI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("rotqbyi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("rotqbyi", spu_reg_name[rt], spu_reg_name[ra], i7); } void ROTQMBYI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("rotqmbyi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("rotqmbyi", spu_reg_name[rt], spu_reg_name[ra], i7); } void SHLQBYI(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("shlqbyi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("shlqbyi", spu_reg_name[rt], spu_reg_name[ra], i7); } void NOP(u32 rt) { - Write(wxString::Format("nop %s", spu_reg_name[rt])); + DisAsm("nop", spu_reg_name[rt]); } void CGT(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("cgt %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("cgt", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void XOR(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("xor %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("xor", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CGTH(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("cgth %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("cgth", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void EQV(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("eqv %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("eqv", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CGTB(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("cgtb %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("cgtb", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void SUMB(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("sumb %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("sumb", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void HGT(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("hgt %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("hgt", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CLZ(u32 rt, u32 ra) { - Write(wxString::Format("clz %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("clz", spu_reg_name[rt], spu_reg_name[ra]); } void XSWD(u32 rt, u32 ra) { - Write(wxString::Format("xswd %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("xswd", spu_reg_name[rt], spu_reg_name[ra]); } void XSHW(u32 rt, u32 ra) { - Write(wxString::Format("xshw %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("xshw", spu_reg_name[rt], spu_reg_name[ra]); } void CNTB(u32 rt, u32 ra) { - Write(wxString::Format("cntb %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("cntb", spu_reg_name[rt], spu_reg_name[ra]); } void XSBH(u32 rt, u32 ra) { - Write(wxString::Format("xsbh %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("xsbh", spu_reg_name[rt], spu_reg_name[ra]); } void CLGT(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("clgt %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("clgt", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ANDC(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("andc %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("andc", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void FCGT(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("fcgt %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("fcgt", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFCGT(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfcgt %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfcgt", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void FA(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("fa %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("fa", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void FS(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("fs %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("fs", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void FM(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("fm %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("fm", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CLGTH(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("clgth %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("clgth", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ORC(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("orc %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("orc", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void FCMGT(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("fcmgt %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("fcmgt", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFCMGT(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfcmgt %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfcmgt", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFA(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfa %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfa", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFS(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfs %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfs", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFM(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfm %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfm", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CLGTB(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("clgtb %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("clgtb", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void HLGT(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("hlgt %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("hlgt", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFMA(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfma %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfma", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFMS(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfms %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfms", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFNMS(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfnms %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfnms", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFNMA(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfnma %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfnma", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CEQ(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("ceq %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("ceq", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void MPYHHU(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("mpyhhu %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("mpyhhu", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void ADDX(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("addx %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("addx", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void SFX(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("sfx %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("sfx", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CGX(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("cgx %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("cgx", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void BGX(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("bgx %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("bgx", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void MPYHHA(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("mpyhha %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("mpyhha", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void MPYHHAU(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("mpyhhau %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("mpyhhau", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void FSCRRD(u32 rt) { - Write(wxString::Format("fscrrd %s", spu_reg_name[rt])); + DisAsm("fscrrd", spu_reg_name[rt]); } void FESD(u32 rt, u32 ra) { - Write(wxString::Format("fesd %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("fesd", spu_reg_name[rt], spu_reg_name[ra]); } void FRDS(u32 rt, u32 ra) { - Write(wxString::Format("frds %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("frds", spu_reg_name[rt], spu_reg_name[ra]); } void FSCRWR(u32 rt, u32 ra) { - Write(wxString::Format("fscrwr %s,%s", spu_reg_name[rt], spu_reg_name[ra])); + DisAsm("fscrwr", spu_reg_name[rt], spu_reg_name[ra]); } void DFTSV(u32 rt, u32 ra, s32 i7) { - Write(wxString::Format("dftsv %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i7)); + DisAsm("dftsv", spu_reg_name[rt], spu_reg_name[ra], i7); } void FCEQ(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("fceq %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("fceq", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFCEQ(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfceq %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfceq", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void MPY(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("mpy %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("mpy", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void MPYH(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("mpyh %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("mpyh", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void MPYHH(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("mpyhh %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("mpyhh", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void MPYS(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("mpys %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("mpys", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CEQH(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("ceqh %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("ceqh", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void FCMEQ(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("fcmeq %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("fcmeq", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void DFCMEQ(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("dfcmeq %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("dfcmeq", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void MPYU(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("mpyu %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("mpyu", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void CEQB(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("ceqb %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("ceqb", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void FI(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("fi %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("fi", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } void HEQ(u32 rt, u32 ra, u32 rb) { - Write(wxString::Format("heq %s,%s,%s", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb])); + DisAsm("heq", spu_reg_name[rt], spu_reg_name[ra], spu_reg_name[rb]); } //0 - 9 void CFLTS(u32 rt, u32 ra, s32 i8) { - Write(wxString::Format("cflts %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i8)); + DisAsm("cflts", spu_reg_name[rt], spu_reg_name[ra], i8); } void CFLTU(u32 rt, u32 ra, s32 i8) { - Write(wxString::Format("cfltu %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i8)); + DisAsm("cfltu", spu_reg_name[rt], spu_reg_name[ra], i8); } void CSFLT(u32 rt, u32 ra, s32 i8) { - Write(wxString::Format("csflt %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i8)); + DisAsm("csflt", spu_reg_name[rt], spu_reg_name[ra], i8); } void CUFLT(u32 rt, u32 ra, s32 i8) { - Write(wxString::Format("cuflt %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i8)); + DisAsm("cuflt", spu_reg_name[rt], spu_reg_name[ra], i8); } //0 - 8 void BRZ(u32 rt, s32 i16) { - Write(wxString::Format("brz %s,0x%x", spu_reg_name[rt], DisAsmBranchTarget(i16))); + DisAsm("brz", spu_reg_name[rt], DisAsmBranchTarget(i16)); } void STQA(u32 rt, s32 i16) { - Write(wxString::Format("stqa %s,0x%x", spu_reg_name[rt], DisAsmBranchTarget(i16))); + DisAsm("stqa", spu_reg_name[rt], DisAsmBranchTarget(i16)); } void BRNZ(u32 rt, s32 i16) { - Write(wxString::Format("brnz %s,0x%x", spu_reg_name[rt], DisAsmBranchTarget(i16))); + DisAsm("brnz", spu_reg_name[rt], DisAsmBranchTarget(i16)); } void BRHZ(u32 rt, s32 i16) { - Write(wxString::Format("brhz %s,0x%x", spu_reg_name[rt], DisAsmBranchTarget(i16))); + DisAsm("brhz", spu_reg_name[rt], DisAsmBranchTarget(i16)); } void BRHNZ(u32 rt, s32 i16) { - Write(wxString::Format("brhnz %s,0x%x", spu_reg_name[rt], DisAsmBranchTarget(i16))); + DisAsm("brhnz", spu_reg_name[rt], DisAsmBranchTarget(i16)); } void STQR(u32 rt, s32 i16) { - Write(wxString::Format("stqr %s,0x%x", spu_reg_name[rt], DisAsmBranchTarget(i16))); + DisAsm("stqr", spu_reg_name[rt], DisAsmBranchTarget(i16)); } void BRA(s32 i16) { - Write(wxString::Format("bra 0x%x", DisAsmBranchTarget(i16))); + DisAsm("bra", DisAsmBranchTarget(i16)); } void LQA(u32 rt, s32 i16) { - Write(wxString::Format("lqa %s,0x%x", spu_reg_name[rt], DisAsmBranchTarget(i16))); + DisAsm("lqa", spu_reg_name[rt], DisAsmBranchTarget(i16)); } void BRASL(u32 rt, s32 i16) { - Write(wxString::Format("brasl %s,0x%x", spu_reg_name[rt], DisAsmBranchTarget(i16))); + DisAsm("brasl", spu_reg_name[rt], DisAsmBranchTarget(i16)); } void BR(s32 i16) { - Write(wxString::Format("br 0x%x", DisAsmBranchTarget(i16))); + DisAsm("br", DisAsmBranchTarget(i16)); } void FSMBI(u32 rt, s32 i16) { - Write(wxString::Format("fsmbi %s,%d", spu_reg_name[rt], i16)); + DisAsm("fsmbi", spu_reg_name[rt], i16); } void BRSL(u32 rt, s32 i16) { - Write(wxString::Format("brsl %s,0x%x", spu_reg_name[rt], DisAsmBranchTarget(i16))); + DisAsm("brsl", spu_reg_name[rt], DisAsmBranchTarget(i16)); } void LQR(u32 rt, s32 i16) { - Write(wxString::Format("lqr %s,0x%x", spu_reg_name[rt], DisAsmBranchTarget(i16))); + DisAsm("lqr", spu_reg_name[rt], DisAsmBranchTarget(i16)); } void IL(u32 rt, s32 i16) { - Write(wxString::Format("il %s,%d", spu_reg_name[rt], i16)); + DisAsm("il", spu_reg_name[rt], i16); } void ILHU(u32 rt, s32 i16) { - Write(wxString::Format("ilhu %s,%d", spu_reg_name[rt], i16)); + DisAsm("ilhu", spu_reg_name[rt], i16); } void ILH(u32 rt, s32 i16) { - Write(wxString::Format("ilh %s,%d", spu_reg_name[rt], i16)); + DisAsm("ilh", spu_reg_name[rt], i16); } void IOHL(u32 rt, s32 i16) { - Write(wxString::Format("iolh %s,%d", spu_reg_name[rt], i16)); + DisAsm("iolh", spu_reg_name[rt], i16); } - //0 - 7 void ORI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("ori %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("ori", spu_reg_name[rt], spu_reg_name[ra], i10); } void ORHI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("orhi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("orhi", spu_reg_name[rt], spu_reg_name[ra], i10); } void ORBI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("orbi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("orbi", spu_reg_name[rt], spu_reg_name[ra], i10); } void SFI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("sfi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("sfi", spu_reg_name[rt], spu_reg_name[ra], i10); } void SFHI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("sfhi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("sfhi", spu_reg_name[rt], spu_reg_name[ra], i10); } void ANDI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("andi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("andi", spu_reg_name[rt], spu_reg_name[ra], i10); } void ANDHI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("andhi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("andhi", spu_reg_name[rt], spu_reg_name[ra], i10); } void ANDBI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("andbi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("andbi", spu_reg_name[rt], spu_reg_name[ra], i10); } void AI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("ai %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("ai", spu_reg_name[rt], spu_reg_name[ra], i10); } void AHI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("ahi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("ahi", spu_reg_name[rt], spu_reg_name[ra], i10); } void STQD(u32 rt, s32 i10, u32 ra) { - Write(wxString::Format("stqd %s,%d(%s)", spu_reg_name[rt], i10, spu_reg_name[ra])); + DisAsm("stqd", spu_reg_name[rt], i10, spu_reg_name[ra]); } void LQD(u32 rt, s32 i10, u32 ra) { - Write(wxString::Format("lqd %s,%d(%s)", spu_reg_name[rt], i10, spu_reg_name[ra])); + DisAsm("lqd", spu_reg_name[rt], i10, spu_reg_name[ra]); } void XORI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("xori %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("xori", spu_reg_name[rt], spu_reg_name[ra], i10); } void XORHI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("xorhi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("xorhi", spu_reg_name[rt], spu_reg_name[ra], i10); } void XORBI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("xorbi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("xorbi", spu_reg_name[rt], spu_reg_name[ra], i10); } void CGTI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("cgti %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("cgti", spu_reg_name[rt], spu_reg_name[ra], i10); } void CGTHI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("cgthi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("cgthi", spu_reg_name[rt], spu_reg_name[ra], i10); } void CGTBI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("cgtbi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("cgtbi", spu_reg_name[rt], spu_reg_name[ra], i10); } void HGTI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("hgti %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("hgti", spu_reg_name[rt], spu_reg_name[ra], i10); } void CLGTI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("clgti %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("clgti", spu_reg_name[rt], spu_reg_name[ra], i10); } void CLGTHI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("clgthi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("clgthi", spu_reg_name[rt], spu_reg_name[ra], i10); } void CLGTBI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("clgtbi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("clgtbi", spu_reg_name[rt], spu_reg_name[ra], i10); } void HLGTI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("hlgti %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("hlgti", spu_reg_name[rt], spu_reg_name[ra], i10); } void MPYI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("mpyi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("mpyi", spu_reg_name[rt], spu_reg_name[ra], i10); } void MPYUI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("mpyui %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("mpyui", spu_reg_name[rt], spu_reg_name[ra], i10); } void CEQI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("ceqi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("ceqi", spu_reg_name[rt], spu_reg_name[ra], i10); } void CEQHI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("ceqhi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("ceqhi", spu_reg_name[rt], spu_reg_name[ra], i10); } void CEQBI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("ceqbi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("ceqbi", spu_reg_name[rt], spu_reg_name[ra], i10); } void HEQI(u32 rt, u32 ra, s32 i10) { - Write(wxString::Format("heqi %s,%s,%d", spu_reg_name[rt], spu_reg_name[ra], i10)); + DisAsm("heqi", spu_reg_name[rt], spu_reg_name[ra], i10); } //0 - 6 void HBRA(s32 ro, s32 i16) { - Write(wxString::Format("hbra 0x%x,0x%x", DisAsmBranchTarget(ro), DisAsmBranchTarget(i16))); + DisAsm("hbra", DisAsmBranchTarget(ro), DisAsmBranchTarget(i16)); } void HBRR(s32 ro, s32 i16) { - Write(wxString::Format("hbrr 0x%x,0x%x", DisAsmBranchTarget(ro), DisAsmBranchTarget(i16))); + DisAsm("hbrr", DisAsmBranchTarget(ro), DisAsmBranchTarget(i16)); } void ILA(u32 rt, s32 i18) { - Write(wxString::Format("ila %s,%d", spu_reg_name[rt], i18)); + DisAsm("ila", spu_reg_name[rt], i18); } //0 - 3 void SELB(u32 rc, u32 ra, u32 rb, u32 rt) { - Write(wxString::Format("selb %s,%s,%s,%s", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt])); + DisAsm("selb", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt]); } void SHUFB(u32 rc, u32 ra, u32 rb, u32 rt) { - Write(wxString::Format("shufb %s,%s,%s,%s", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt])); + DisAsm("shufb", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt]); } void MPYA(u32 rc, u32 ra, u32 rb, u32 rt) { - Write(wxString::Format("mpya %s,%s,%s,%s", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt])); + DisAsm("mpya", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt]); } void FNMS(u32 rc, u32 ra, u32 rb, u32 rt) { - Write(wxString::Format("fnms %s,%s,%s,%s", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt])); + DisAsm("fnms", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt]); } void FMA(u32 rc, u32 ra, u32 rb, u32 rt) { - Write(wxString::Format("fma %s,%s,%s,%s", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt])); + DisAsm("fma", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt]); } void FMS(u32 rc, u32 ra, u32 rb, u32 rt) { - Write(wxString::Format("fms %s,%s,%s,%s", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt])); + DisAsm("fms", spu_reg_name[rc], spu_reg_name[ra], spu_reg_name[rb], spu_reg_name[rt]); } void UNK(u32 code, u32 opcode, u32 gcode) @@ -860,6 +908,3 @@ private: Write(wxString::Format("Unknown/Illegal opcode! (0x%08x, 0x%x, 0x%x)", code, opcode, gcode)); } }; - -#undef START_OPCODES_GROUP -#undef END_OPCODES_GROUP \ No newline at end of file diff --git a/rpcs3/Emu/Cell/SPUInterpreter.h b/rpcs3/Emu/Cell/SPUInterpreter.h index 39952916ee..d34c42512f 100644 --- a/rpcs3/Emu/Cell/SPUInterpreter.h +++ b/rpcs3/Emu/Cell/SPUInterpreter.h @@ -27,18 +27,22 @@ private: //0 - 10 void STOP(u32 code) { - Emu.Pause(); + if(code & 0x2000) + { + CPU.SetExitStatus(code & 0xfff); + CPU.Stop(); + } } void LNOP() { } void SYNC(u32 Cbit) { - UNIMPLEMENTED(); + //UNIMPLEMENTED(); } void DSYNC() { - UNIMPLEMENTED(); + //UNIMPLEMENTED(); } void MFSPR(u32 rt, u32 sa) { @@ -51,7 +55,7 @@ private: void RCHCNT(u32 rt, u32 ra) { CPU.GPR[rt].Reset(); - CPU.GPR[rt]._u32[0] = CPU.GetChannelCount(ra); + CPU.GPR[rt]._u32[3] = CPU.GetChannelCount(ra); } void SF(u32 rt, u32 ra, u32 rb) { @@ -280,16 +284,15 @@ private: } void STQX(u32 rt, u32 ra, u32 rb) { - CPU.LSA = CPU.GPR[ra]._u32[0] + CPU.GPR[rb]._u32[0]; - CPU.WriteLSA128(CPU.GPR[rt]._u128); + CPU.WriteLS128(CPU.GPR[ra]._u32[0] + CPU.GPR[rb]._u32[0], CPU.GPR[rt]._u128); } void BI(u32 ra) { - CPU.SetBranch(CPU.GPR[ra]._u32[0] & 0xfffffffc); + CPU.SetBranch(CPU.GPR[ra]._u32[3] & 0xfffffffc); } void BISL(u32 rt, u32 ra) { - CPU.SetBranch(CPU.GPR[ra]._u32[0] & 0xfffffffc); + CPU.SetBranch(CPU.GPR[ra]._u32[3] & 0xfffffffc); CPU.GPR[rt].Reset(); CPU.GPR[rt]._u32[0] = CPU.PC + 4; } @@ -353,8 +356,7 @@ private: } void LQX(u32 rt, u32 ra, u32 rb) { - CPU.LSA = CPU.GPR[ra]._u32[0] + CPU.GPR[rb]._u32[0]; - CPU.GPR[rt]._u128 = CPU.ReadLSA128(); + CPU.GPR[rt]._u128 = CPU.ReadLS128(CPU.GPR[ra]._u32[0] + CPU.GPR[rb]._u32[0]); } void ROTQBYBI(u32 rt, u32 ra, u32 rb) { @@ -870,8 +872,6 @@ private: UNIMPLEMENTED(); } - - //0 - 9 void CFLTS(u32 rt, u32 ra, s32 i8) { @@ -890,35 +890,31 @@ private: UNIMPLEMENTED(); } - - //0 - 8 void BRZ(u32 rt, s32 i16) { - if(!CPU.GPR[rt]._u32[0]) CPU.SetBranch(branchTarget(CPU.PC, i16)); + if(!CPU.GPR[rt]._u32[3]) CPU.SetBranch(branchTarget(CPU.PC, i16)); } void STQA(u32 rt, s32 i16) { - CPU.LSA = i16 << 2; - CPU.WriteLSA128(CPU.GPR[rt]._u128); + CPU.WriteLS128(i16 << 2, CPU.GPR[rt]._u128); } void BRNZ(u32 rt, s32 i16) { - if(CPU.GPR[rt]._u32[0] != 0) + if(CPU.GPR[rt]._u32[3] != 0) CPU.SetBranch(branchTarget(CPU.PC, i16)); } void BRHZ(u32 rt, s32 i16) { - if(!CPU.GPR[rt]._u16[0]) CPU.SetBranch(branchTarget(CPU.PC, i16)); + if(!CPU.GPR[rt]._u16[7]) CPU.SetBranch(branchTarget(CPU.PC, i16)); } void BRHNZ(u32 rt, s32 i16) { - if(CPU.GPR[rt]._u16[0]) CPU.SetBranch(branchTarget(CPU.PC, i16)); + if(CPU.GPR[rt]._u16[7]) CPU.SetBranch(branchTarget(CPU.PC, i16)); } void STQR(u32 rt, s32 i16) { - CPU.LSA = branchTarget(CPU.PC, i16); - CPU.WriteLSA128(CPU.GPR[rt]._u128); + CPU.WriteLS128(branchTarget(CPU.PC, i16), CPU.GPR[rt]._u128); } void BRA(s32 i16) { @@ -926,14 +922,7 @@ private: } void LQA(u32 rt, s32 i16) { - CPU.LSA = i16 << 2; - if(!Memory.IsGoodAddr(CPU.LSA)) - { - ConLog.Warning("LQA: Bad addr: 0x%x", CPU.LSA); - return; - } - - CPU.GPR[rt]._u128 = CPU.ReadLSA128(); + CPU.GPR[rt]._u128 = CPU.ReadLS128(i16 << 2); } void BRASL(u32 rt, s32 i16) { @@ -964,19 +953,12 @@ private: void BRSL(u32 rt, s32 i16) { CPU.GPR[rt].Reset(); - CPU.GPR[rt]._u32[0] = CPU.PC + 4; + CPU.GPR[rt]._u32[3] = CPU.PC + 4; CPU.SetBranch(branchTarget(CPU.PC, i16)); } void LQR(u32 rt, s32 i16) { - CPU.LSA = branchTarget(CPU.PC, i16); - if(!Memory.IsGoodAddr(CPU.LSA)) - { - ConLog.Warning("LQR: Bad addr: 0x%x", CPU.LSA); - return; - } - - CPU.GPR[rt]._u128 = CPU.ReadLSA128(); + CPU.GPR[rt]._u128 = CPU.ReadLS128(branchTarget(CPU.PC, i16)); } void IL(u32 rt, s32 i16) { @@ -988,7 +970,7 @@ private: void ILHU(u32 rt, s32 i16) { for (int w = 0; w < 4; w++) - CPU.GPR[rt]._u16[w*2] = i16; + CPU.GPR[rt]._u16[w*2 + 1] = i16; } void ILH(u32 rt, s32 i16) { @@ -1061,13 +1043,11 @@ private: } void STQD(u32 rt, s32 i10, u32 ra) { - CPU.LSA = branchTarget(0, i10 + CPU.GPR[ra]._u32[0]); - CPU.WriteLSA128(CPU.GPR[rt]._u128); + CPU.WriteLS128(CPU.GPR[ra]._u32[3] + i10, CPU.GPR[rt]._u128); } void LQD(u32 rt, s32 i10, u32 ra) { - CPU.LSA = branchTarget(0, i10 + CPU.GPR[ra]._u32[0]); - CPU.GPR[rt]._u128 = CPU.ReadLSA128(); + CPU.GPR[rt]._u128 = CPU.ReadLS128(CPU.GPR[ra]._u32[3] + i10); } void XORI(u32 rt, u32 ra, s32 i10) { @@ -1167,10 +1147,6 @@ private: } void HBRR(s32 ro, s32 i16) { - UNIMPLEMENTED(); - //CHECK ME - //CPU.GPR[0]._u64[0] = branchTarget(CPU.PC, i16); - //CPU.SetBranch(branchTarget(CPU.PC, ro)); } void ILA(u32 rt, s32 i18) { @@ -1189,14 +1165,8 @@ private: ( CPU.GPR[rc]._u32[i] & CPU.GPR[rb]._u32[i]) | (~CPU.GPR[rc]._u32[i] & CPU.GPR[ra]._u32[i]); } - /* - CPU.GPR[rt] = _mm_or_si128( - _mm_and_si128(CPU.GPR[rc], CPU.GPR[rb]), - _mm_andnot_si128(CPU.GPR[rc], CPU.GPR[ra]) - ); - */ } - void SHUFB(u32 rc, u32 ra, u32 rb, u32 rt) + void SHUFB(u32 rt, u32 ra, u32 rb, u32 rc) { ConLog.Warning("SHUFB"); } @@ -1205,7 +1175,7 @@ private: for (int w = 0; w < 4; w++) CPU.GPR[rt]._i32[w] = CPU.GPR[ra]._i16[w*2 + 1] * CPU.GPR[rb]._i16[w*2 + 1] + CPU.GPR[rc]._i32[w]; } - void FNMS(u32 rc, u32 ra, u32 rb, u32 rt) + void FNMS(u32 rt, u32 ra, u32 rb, u32 rc) { UNIMPLEMENTED(); } diff --git a/rpcs3/Emu/Cell/SPUOpcodes.h b/rpcs3/Emu/Cell/SPUOpcodes.h index 1b56e9281b..e3bff38d3e 100644 --- a/rpcs3/Emu/Cell/SPUOpcodes.h +++ b/rpcs3/Emu/Cell/SPUOpcodes.h @@ -231,8 +231,8 @@ class SPU_Opcodes public: static u32 branchTarget(const u64 pc, const s32 imm) { - return (pc + ((imm << 2) & ~0x3)) & 0x3fff0; - } + return (pc + (imm << 2)) & 0x3fffc; + } virtual void Exit()=0; diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index fcac328f20..badacc7256 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -8,12 +8,12 @@ SPUThread& GetCurrentSPUThread() { PPCThread* thread = GetCurrentPPCThread(); - if(!thread || !thread->IsSPU()) throw wxString("GetCurrentSPUThread: bad thread"); + if(!thread || thread->GetType() == PPC_THREAD_PPU) throw wxString("GetCurrentSPUThread: bad thread"); return *(SPUThread*)thread; } -SPUThread::SPUThread() : PPCThread(PPC_THREAD_SPU) +SPUThread::SPUThread(PPCThreadType type) : PPCThread(type) { Reset(); } @@ -26,13 +26,15 @@ void SPUThread::DoReset() { //reset regs for(u32 i=0; i<128; ++i) GPR[i].Reset(); - - LSA = 0; } void SPUThread::InitRegs() { - GPR[1]._u64[0] = stack_point; + //GPR[1]._u64[0] = stack_point; + GPR[3]._u64[1] = m_args[0]; + GPR[4]._u64[1] = m_args[1]; + GPR[5]._u64[1] = m_args[2]; + GPR[6]._u64[1] = m_args[3]; } u64 SPUThread::GetFreeStackSize() const diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index 54e46e85f6..26775a6ec9 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -1,29 +1,31 @@ #pragma once #include "PPCThread.h" +#include "Emu/event.h" +#include "MFC.h" static const wxString spu_reg_name[128] = { - "$LR", "$SP", "$3", "$4", "$5", "$6", "$7", "$8", - "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$16", - "$17", "$18", "$19", "$20", "$21", "$22", "$23", "$24", - "$25", "$26", "$27", "$28", "$29", "$30", "$31", "$32", - "$33", "$34", "$35", "$36", "$37", "$38", "$39", "$40", - "$41", "$42", "$43", "$44", "$45", "$46", "$47", "$48", - "$49", "$50", "$51", "$52", "$53", "$54", "$55", "$56", - "$57", "$58", "$59", "$60", "$61", "$62", "$63", "$64", - "$65", "$66", "$67", "$68", "$69", "$70", "$71", "$72", - "$73", "$74", "$75", "$76", "$77", "$78", "$79", "$80", - "$81", "$82", "$83", "$84", "$85", "$86", "$87", "$88", - "$89", "$90", "$91", "$92", "$93", "$94", "$95", "$96", - "$97", "$98", "$99", "$100", "$101", "$102", "$103", "$104", - "$105", "$106", "$107", "$108", "$109", "$110", "$111", "$112", - "$113", "$114", "$115", "$116", "$117", "$118", "$119", "$120", - "$121", "$122", "$123", "$124", "$125", "$126", "$127", + "$LR", "$SP", "$2", "$3", "$4", "$5", "$6", "$7", + "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", + "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23", + "$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31", + "$32", "$33", "$34", "$35", "$36", "$37", "$38", "$39", + "$40", "$41", "$42", "$43", "$44", "$45", "$46", "$47", + "$48", "$49", "$50", "$51", "$52", "$53", "$54", "$55", + "$56", "$57", "$58", "$59", "$60", "$61", "$62", "$63", + "$64", "$65", "$66", "$67", "$68", "$69", "$70", "$71", + "$72", "$73", "$74", "$75", "$76", "$77", "$78", "$79", + "$80", "$81", "$82", "$83", "$84", "$85", "$86", "$87", + "$88", "$89", "$90", "$91", "$92", "$93", "$94", "$95", + "$96", "$97", "$98", "$99", "$100", "$101", "$102", "$103", + "$104", "$105", "$106", "$107", "$108", "$109", "$110", "$111", + "$112", "$113", "$114", "$115", "$116", "$117", "$118", "$119", + "$120", "$121", "$122", "$123", "$124", "$125", "$126", "$127", }; static const wxString spu_ch_name[128] = { - "$SPU_RdEventStat", "$SPU_WrEventMask", "$SPU_RdSigNotify1", + "$SPU_RdEventStat", "$SPU_WrEventMask", "$SPU_WrEventAck", "$SPU_RdSigNotify1", "$SPU_RdSigNotify2", "$ch5", "$ch6", "$SPU_WrDec", "$SPU_RdDec", "$MFC_WrMSSyncReq", "$ch10", "$SPU_RdEventMask", "$MFC_RdTagMask", "$SPU_RdMachStat", "$SPU_WrSRR0", "$SPU_RdSRR0", "$MFC_LSA", "$MFC_EAH", "$MFC_EAL", "$MFC_Size", @@ -80,10 +82,24 @@ enum MFCchannels MFC_RdAtomicStat = 27, //Read completion status of last completed immediate MFC atomic update command }; +enum +{ + SPU_RUNCNTL_STOP = 0, + SPU_RUNCNTL_RUNNABLE = 1, +}; + +enum +{ + SPU_STATUS_STOPPED = 0x0, + SPU_STATUS_RUNNING = 0x1, + SPU_STATUS_STOPPED_BY_STOP = 0x2, + SPU_STATUS_STOPPED_BY_HALT = 0x4, + SPU_STATUS_WAITING_FOR_CHANNEL = 0x8, + SPU_STATUS_SINGLE_STEP = 0x10, +}; + union SPU_GPR_hdr { - //__m128i _m128i; - u128 _u128; s128 _i128; u64 _u64[2]; @@ -96,19 +112,6 @@ union SPU_GPR_hdr s8 _i8[16]; SPU_GPR_hdr() {} - /* - SPU_GPR_hdr(const __m128i val){_u128._u64[0] = val.m128i_u64[0]; _u128._u64[1] = val.m128i_u64[1];} - SPU_GPR_hdr(const u128 val) { _u128 = val; } - SPU_GPR_hdr(const u64 val) { Reset(); _u64[0] = val; } - SPU_GPR_hdr(const u32 val) { Reset(); _u32[0] = val; } - SPU_GPR_hdr(const u16 val) { Reset(); _u16[0] = val; } - SPU_GPR_hdr(const u8 val) { Reset(); _u8[0] = val; } - SPU_GPR_hdr(const s128 val) { _i128 = val; } - SPU_GPR_hdr(const s64 val) { Reset(); _i64[0] = val; } - SPU_GPR_hdr(const s32 val) { Reset(); _i32[0] = val; } - SPU_GPR_hdr(const s16 val) { Reset(); _i16[0] = val; } - SPU_GPR_hdr(const s8 val) { Reset(); _i8[0] = val; } - */ wxString ToString() const { @@ -119,41 +122,34 @@ union SPU_GPR_hdr { memset(this, 0, sizeof(*this)); } - - //operator __m128i() { __m128i ret; ret.m128i_u64[0]=_u128._u64[0]; ret.m128i_u64[1]=_u128._u64[1]; return ret; } - /* - SPU_GPR_hdr operator ^ (__m128i right) { return _mm_xor_si128(*this, right); } - SPU_GPR_hdr operator | (__m128i right) { return _mm_or_si128 (*this, right); } - SPU_GPR_hdr operator & (__m128i right) { return _mm_and_si128(*this, right); } - SPU_GPR_hdr operator << (int right) { return _mm_slli_epi32(*this, right); } - SPU_GPR_hdr operator << (__m128i right) { return _mm_sll_epi32(*this, right); } - SPU_GPR_hdr operator >> (int right) { return _mm_srai_epi32(*this, right); } - SPU_GPR_hdr operator >> (__m128i right) { return _mm_sra_epi32(*this, right); } - - SPU_GPR_hdr operator | (__m128i right) { return _mm_or_si128 (*this, right); } - SPU_GPR_hdr operator & (__m128i right) { return _mm_and_si128(*this, right); } - SPU_GPR_hdr operator << (int right) { return _mm_slli_epi32(*this, right); } - SPU_GPR_hdr operator << (__m128i right) { return _mm_sll_epi32(*this, right); } - SPU_GPR_hdr operator >> (int right) { return _mm_srai_epi32(*this, right); } - SPU_GPR_hdr operator >> (__m128i right) { return _mm_sra_epi32(*this, right); } - - SPU_GPR_hdr operator ^= (__m128i right) { return *this = *this ^ right; } - SPU_GPR_hdr operator |= (__m128i right) { return *this = *this | right; } - SPU_GPR_hdr operator &= (__m128i right) { return *this = *this & right; } - SPU_GPR_hdr operator <<= (int right) { return *this = *this << right; } - SPU_GPR_hdr operator <<= (__m128i right){ return *this = *this << right; } - SPU_GPR_hdr operator >>= (int right) { return *this = *this >> right; } - SPU_GPR_hdr operator >>= (__m128i right){ return *this = *this >> right; } - */ }; class SPUThread : public PPCThread { public: SPU_GPR_hdr GPR[128]; //General-Purpose Register - Stack Mbox; - - u32 LSA; //local storage address + /* + SPUReg<1> MFC_LSA; + SPUReg<1> MFC_EAH; + SPUReg<1> MFC_EAL; + SPUReg<1> MFC_Size_Tag; + SPUReg<1> MFC_CMDStatus; + SPUReg<1> MFC_QStatus; + SPUReg<1> Prxy_QueryType; + SPUReg<1> Prxy_QueryMask; + SPUReg<1> Prxy_TagStatus; + SPUReg<1> SPU_Out_MBox; + SPUReg<4> SPU_In_MBox; + SPUReg<1> SPU_MBox_Status; + SPUReg<1> SPU_RunCntl; + SPUReg<1> SPU_Status; + SPUReg<1> SPU_NPC; + SPUReg<1> SPU_RdSigNotify1; + SPUReg<1> SPU_RdSigNotify2; + */ + SizedStack SPU_OutIntr_Mbox; + u32 LSA; + MFC mfc; union { @@ -165,11 +161,14 @@ public: { switch(ch) { + case SPU_WrOutMbox: + return mfc.SPU_Out_MBox.GetFreeCount(); + case SPU_RdInMbox: - return 1; + return mfc.SPU_In_MBox.GetCount(); case SPU_WrOutIntrMbox: - return 0; + return 0;//return SPU_OutIntr_Mbox.GetFreeCount(); default: ConLog.Error("%s error: unknown/illegal channel (%d).", __FUNCTION__, ch); @@ -181,12 +180,25 @@ public: void WriteChannel(u32 ch, const SPU_GPR_hdr& r) { - const u32 v = r._u32[0]; + const u32 v = r._u32[3]; switch(ch) { case SPU_WrOutIntrMbox: - Mbox.Push(v); + ConLog.Warning("SPU_WrOutIntrMbox = 0x%x", v); + if(!SPU_OutIntr_Mbox.Push(v)) + { + ConLog.Warning("Not enought free rooms."); + } + break; + + case SPU_WrOutMbox: + ConLog.Warning("SPU_WrOutMbox = 0x%x", v); + if(!mfc.SPU_Out_MBox.Push(v)) + { + ConLog.Warning("Not enought free rooms."); + } + mfc.SPU_Status.SetValue((mfc.SPU_Status.GetValue() & ~0xff) | 1); break; default: @@ -198,12 +210,13 @@ public: void ReadChannel(SPU_GPR_hdr& r, u32 ch) { r.Reset(); - u32& v = r._u32[0]; + u32& v = r._u32[3]; switch(ch) { case SPU_RdInMbox: - v = Mbox.Pop(); + if(!mfc.SPU_In_MBox.Pop(v)) v = 0; + mfc.SPU_Status.SetValue((mfc.SPU_Status.GetValue() & ~0xff00) | (mfc.SPU_In_MBox.GetCount() << 8)); break; default: @@ -212,20 +225,21 @@ public: } } - u8 ReadLSA8 () { return Memory.Read8 (LSA + m_offset); } - u16 ReadLSA16 () { return Memory.Read16 (LSA + m_offset); } - u32 ReadLSA32 () { return Memory.Read32 (LSA + m_offset); } - u64 ReadLSA64 () { return Memory.Read64 (LSA + m_offset); } - u128 ReadLSA128() { return Memory.Read128(LSA + m_offset); } + bool IsGoodLSA(const u32 lsa) const { return Memory.IsGoodAddr(lsa + m_offset); } + virtual u8 ReadLS8 (const u32 lsa) const { return Memory.Read8 (lsa + (m_offset & 0x3fffc)); } + virtual u16 ReadLS16 (const u32 lsa) const { return Memory.Read16 (lsa + m_offset); } + virtual u32 ReadLS32 (const u32 lsa) const { return Memory.Read32 (lsa + m_offset); } + virtual u64 ReadLS64 (const u32 lsa) const { return Memory.Read64 (lsa + m_offset); } + virtual u128 ReadLS128(const u32 lsa) const { return Memory.Read128(lsa + m_offset); } - void WriteLSA8 (const u8& data) { Memory.Write8 (LSA + m_offset, data); } - void WriteLSA16 (const u16& data) { Memory.Write16 (LSA + m_offset, data); } - void WriteLSA32 (const u32& data) { Memory.Write32 (LSA + m_offset, data); } - void WriteLSA64 (const u64& data) { Memory.Write64 (LSA + m_offset, data); } - void WriteLSA128(const u128& data) { Memory.Write128(LSA + m_offset, data); } + virtual void WriteLS8 (const u32 lsa, const u8& data) const { Memory.Write8 (lsa + m_offset, data); } + virtual void WriteLS16 (const u32 lsa, const u16& data) const { Memory.Write16 (lsa + m_offset, data); } + virtual void WriteLS32 (const u32 lsa, const u32& data) const { Memory.Write32 (lsa + m_offset, data); } + virtual void WriteLS64 (const u32 lsa, const u64& data) const { Memory.Write64 (lsa + m_offset, data); } + virtual void WriteLS128(const u32 lsa, const u128& data) const { Memory.Write128(lsa + m_offset, data); } public: - SPUThread(); + SPUThread(PPCThreadType type = PPC_THREAD_SPU); ~SPUThread(); virtual wxString RegsToString() @@ -246,7 +260,7 @@ protected: virtual void DoResume(); virtual void DoStop(); -private: +protected: virtual void DoCode(const s32 code); }; diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index 3aa909ffd6..0a162f9f2c 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "VFS.h" +#include "Emu\HDD\HDD.h" int sort_devices(const void* _a, const void* _b) { @@ -31,13 +32,23 @@ void VFS::UnMount(const wxString& ps3_path) { if(!m_devices[i].GetPs3Path().Cmp(ps3_path)) { - m_devices.RemoveAt(i); + delete &m_devices[i]; + m_devices.RemoveFAt(i); return; } } } +void VFS::UnMountAll() +{ + for(u32 i=0; i entries; + SaveLoadDevices(entries, true); + + for(uint i=0; i& res, bool is_load) +{ + IniEntry entries_count; + entries_count.Init("count", "VFSManager"); + + int count = 0; + if(is_load) + { + count = entries_count.LoadValue(count); + + if(!count) + { + int idx; + idx = res.Move(new VFSManagerEntry()); + res[idx].path = "$(EmulatorDir)\\dev_hdd0\\"; + res[idx].mount = "/dev_hdd0/"; + res[idx].device = vfsDevice_LocalFile; + + idx = res.Move(new VFSManagerEntry()); + res[idx].path = "$(GameDir)"; + res[idx].mount = ""; + res[idx].device = vfsDevice_LocalFile; + + idx = res.Move(new VFSManagerEntry()); + res[idx].path = "$(GameDir)"; + res[idx].mount = "/"; + res[idx].device = vfsDevice_LocalFile; + + idx = res.Move(new VFSManagerEntry()); + res[idx].path = "$(GameDir)"; + res[idx].mount = "/app_home/"; + res[idx].device = vfsDevice_LocalFile; + return; + } + + res.SetCount(count); + } + else + { + count = res.GetCount(); + entries_count.SaveValue(res.GetCount()); + } + + for(int i=0; i entry_path; + IniEntry entry_device_path; + IniEntry entry_mount; + IniEntry entry_device; + + entry_path.Init(wxString::Format("path[%d]", i), "VFSManager"); + entry_device_path.Init(wxString::Format("device_path[%d]", i), "VFSManager"); + entry_mount.Init(wxString::Format("mount[%d]", i), "VFSManager"); + entry_device.Init(wxString::Format("device[%d]", i), "VFSManager"); + + if(is_load) + { + new (res + i) VFSManagerEntry(); + res[i].path = entry_path.LoadValue(wxEmptyString); + res[i].device_path = entry_device_path.LoadValue(wxEmptyString); + res[i].mount = entry_mount.LoadValue(wxEmptyString); + res[i].device = (vfsDeviceType)entry_device.LoadValue(vfsDevice_LocalFile); + } + else + { + entry_path.SaveValue(res[i].path.GetPtr()); + entry_device_path.SaveValue(res[i].device_path.GetPtr()); + entry_mount.SaveValue(res[i].mount.GetPtr()); + entry_device.SaveValue(res[i].device); + } + } +} \ No newline at end of file diff --git a/rpcs3/Emu/FS/VFS.h b/rpcs3/Emu/FS/VFS.h index 75e0f2dc49..798e951142 100644 --- a/rpcs3/Emu/FS/VFS.h +++ b/rpcs3/Emu/FS/VFS.h @@ -1,15 +1,42 @@ #pragma once #include "vfsDevice.h" +enum vfsDeviceType +{ + vfsDevice_LocalFile, + vfsDevice_HDD, +}; + +static const char* vfsDeviceTypeNames[] = +{ + "Local", + "HDD", +}; + +struct VFSManagerEntry +{ + ArrayString device_path; + ArrayString path; + ArrayString mount; + vfsDeviceType device; + + VFSManagerEntry() : device(vfsDevice_LocalFile) + { + } +}; + struct VFS { ArrayF m_devices; - void Mount(const wxString& ps3_path, const wxString& local_path, vfsDevice* device); void UnMount(const wxString& ps3_path); + void UnMountAll(); vfsStream* Open(const wxString& ps3_path, vfsOpenMode mode); void Create(const wxString& ps3_path); void Close(vfsStream*& device); vfsDevice* GetDevice(const wxString& ps3_path, wxString& path); + + void Init(const wxString& path); + void SaveLoadDevices(Array& res, bool is_load); }; \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsDevice.cpp b/rpcs3/Emu/FS/vfsDevice.cpp index 1560fa647b..2a05018c11 100644 --- a/rpcs3/Emu/FS/vfsDevice.cpp +++ b/rpcs3/Emu/FS/vfsDevice.cpp @@ -198,4 +198,19 @@ wxString vfsDevice::GetPs3Path(const wxString& l, const wxString& r) if(r.IsEmpty()) return GetPs3Path(l); return GetPs3Path(l + '/' + r, false); +} + +void vfsDevice::Lock() const +{ + m_mtx_lock.lock(); +} + +void vfsDevice::Unlock() const +{ + m_mtx_lock.unlock(); +} + +bool vfsDevice::TryLock() const +{ + return m_mtx_lock.try_lock(); } \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsDevice.h b/rpcs3/Emu/FS/vfsDevice.h index 47e7269dc5..a0545b113b 100644 --- a/rpcs3/Emu/FS/vfsDevice.h +++ b/rpcs3/Emu/FS/vfsDevice.h @@ -1,19 +1,23 @@ #pragma once #include "vfsStream.h" +#include enum vfsOpenMode { - vfsRead, - vfsWrite, - vfsReadWrite, - vfsWriteExcl, - vfsWriteAppend, + vfsRead = 0x1, + vfsWrite = 0x2, + vfsExcl = 0x4, + vfsAppend = 0x8, + vfsReadWrite = vfsRead | vfsWrite, + vfsWriteExcl = vfsWrite | vfsExcl, + vfsWriteAppend = vfsWrite | vfsAppend, }; class vfsDevice : public vfsStream { wxString m_ps3_path; wxString m_local_path; + mutable std::mutex m_mtx_lock; public: vfsDevice(const wxString& ps3_path, const wxString& local_path); @@ -36,4 +40,24 @@ public: static wxString GetWinPath(const wxString& l, const wxString& r); static wxString GetPs3Path(const wxString& p, bool is_dir = true); static wxString GetPs3Path(const wxString& l, const wxString& r); + + void Lock() const; + void Unlock() const; + bool TryLock() const; +}; + +class vfsDeviceLocker +{ + vfsDevice& m_device; + +public: + vfsDeviceLocker(vfsDevice& device) : m_device(device) + { + m_device.Lock(); + } + + ~vfsDeviceLocker() + { + m_device.Unlock(); + } }; \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsFileBase.cpp b/rpcs3/Emu/FS/vfsFileBase.cpp index 5606491d37..ed4afc0b1b 100644 --- a/rpcs3/Emu/FS/vfsFileBase.cpp +++ b/rpcs3/Emu/FS/vfsFileBase.cpp @@ -40,4 +40,4 @@ wxString vfsFileBase::GetPath() const vfsOpenMode vfsFileBase::GetOpenMode() const { return m_mode; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/FS/vfsFileBase.h b/rpcs3/Emu/FS/vfsFileBase.h index 0b33913dc2..da776df4ec 100644 --- a/rpcs3/Emu/FS/vfsFileBase.h +++ b/rpcs3/Emu/FS/vfsFileBase.h @@ -21,4 +21,4 @@ public: */ wxString GetPath() const; vfsOpenMode GetOpenMode() const; -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/FS/vfsLocalFile.cpp b/rpcs3/Emu/FS/vfsLocalFile.cpp index 244cb68e8a..ec30d24ed0 100644 --- a/rpcs3/Emu/FS/vfsLocalFile.cpp +++ b/rpcs3/Emu/FS/vfsLocalFile.cpp @@ -92,4 +92,4 @@ u64 vfsLocalFile::Tell() const bool vfsLocalFile::IsOpened() const { return m_file.IsOpened() && vfsFileBase::IsOpened(); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/GS/GL/FragmentProgram.cpp b/rpcs3/Emu/GS/GL/FragmentProgram.cpp index a2678419ff..36878810d0 100644 --- a/rpcs3/Emu/GS/GL/FragmentProgram.cpp +++ b/rpcs3/Emu/GS/GL/FragmentProgram.cpp @@ -1,26 +1,64 @@ #include "stdafx.h" #include "FragmentProgram.h" -void FragmentDecompilerThread::AddCode(wxString code) +void FragmentDecompilerThread::AddCode(wxString code, bool append_mask) { - if(!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_le) return; - if(!src0.exec_if_eq || !src0.exec_if_gr || !src0.exec_if_le) + if(!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt) return; + + const wxString mask = GetMask(); + wxString cond = wxEmptyString; + + if(!src0.exec_if_gr || !src0.exec_if_lt || !src0.exec_if_eq) { - ConLog.Error("Bad cond! eq: %d gr: %d le: %d", src0.exec_if_eq, src0.exec_if_gr, src0.exec_if_le); - Emu.Pause(); - return; + static const char f[4] = {'x', 'y', 'z', 'w'}; + + wxString swizzle = wxEmptyString; + swizzle += f[src0.cond_swizzle_x]; + swizzle += f[src0.cond_swizzle_y]; + swizzle += f[src0.cond_swizzle_z]; + swizzle += f[src0.cond_swizzle_w]; + + if(src0.exec_if_gr && src0.exec_if_eq) + { + cond = "greaterThanEqual"; + } + else if(src0.exec_if_lt && src0.exec_if_eq) + { + cond = "lessThanEqual"; + } + else if(src0.exec_if_gr && src0.exec_if_lt) + { + cond = "notEqual"; + } + else if(src0.exec_if_gr) + { + cond = "greaterThan"; + } + else if(src0.exec_if_lt) + { + cond = "lessThan"; + } + else //if(src0.exec_if_eq) + { + cond = "equal"; + } + + cond = wxString::Format("if(all(%s(%s.%s, vec4(0, 0, 0, 0)))) ", cond, AddCond(dst.no_dest), swizzle); + //ConLog.Error("cond! [eq: %d gr: %d lt: %d] (%s)", src0.exec_if_eq, src0.exec_if_gr, src0.exec_if_lt, cond); + //Emu.Pause(); + //return; } if(src1.scale) { switch(src1.scale) { - case 1: code = "(" + code + ") * 2"; break; - case 2: code = "(" + code + ") * 4"; break; - case 3: code = "(" + code + ") * 8"; break; - case 5: code = "(" + code + ") / 2"; break; - case 6: code = "(" + code + ") / 4"; break; - case 7: code = "(" + code + ") / 8"; break; + case 1: code = "(" + code + " * 2)"; break; + case 2: code = "(" + code + " * 4)"; break; + case 3: code = "(" + code + " * 8)"; break; + case 5: code = "(" + code + " / 2)"; break; + case 6: code = "(" + code + " / 4)"; break; + case 7: code = "(" + code + " / 8)"; break; default: ConLog.Error("Bad scale: %d", src1.scale); @@ -29,7 +67,13 @@ void FragmentDecompilerThread::AddCode(wxString code) } } - code = AddReg(dst.dest_reg) + GetMask() + " = " + code + GetMask(); + if(dst.saturate) + { + code = "clamp(" + code + ", 0.0, 1.0)"; + } + + code = cond + (dst.set_cond ? AddCond(dst.fp16) : AddReg(dst.dest_reg, dst.fp16)) + mask + + " = " + code + (append_mask ? mask : wxEmptyString); main += "\t" + code + ";\n"; } @@ -38,28 +82,53 @@ wxString FragmentDecompilerThread::GetMask() { wxString ret = wxEmptyString; - if(dst.mask_x) ret += 'x'; - if(dst.mask_y) ret += 'y'; - if(dst.mask_z) ret += 'z'; - if(dst.mask_w) ret += 'w'; + static const char dst_mask[4] = + { + 'x', 'y', 'z', 'w', + }; - return ret.IsEmpty() || ret == "xyzw" ? wxEmptyString : ("." + ret); + if(dst.mask_x) ret += dst_mask[0]; + if(dst.mask_y) ret += dst_mask[1]; + if(dst.mask_z) ret += dst_mask[2]; + if(dst.mask_w) ret += dst_mask[3]; + + return ret.IsEmpty() || strncmp(ret, dst_mask, 4) == 0 ? wxEmptyString : ("." + ret); } -wxString FragmentDecompilerThread::AddReg(u32 index) +wxString FragmentDecompilerThread::AddReg(u32 index, int fp16) { - //if(!index) return "gl_FragColor"; - return m_parr.AddParam(index ? PARAM_NONE : PARAM_OUT, "vec4", wxString::Format("r%d", index), index ? -1 : 0); + //if(!index && !fp16) return "gl_FragColor"; + return m_parr.AddParam((index || fp16) ? PARAM_NONE : PARAM_OUT, "vec4", + wxString::Format((fp16 ? "h%u" : "r%u"), index), (index || fp16) ? -1 : 0); +} + +bool FragmentDecompilerThread::HasReg(u32 index, int fp16) +{ + return m_parr.HasParam((index || fp16) ? PARAM_NONE : PARAM_OUT, "vec4", + wxString::Format((fp16 ? "h%u" : "r%u"), index)); +} + +wxString FragmentDecompilerThread::AddCond(int fp16) +{ + return m_parr.AddParam(PARAM_NONE , "vec4", (fp16 ? "hc" : "rc"), -1); } wxString FragmentDecompilerThread::AddConst() { - return m_parr.AddParam(PARAM_CONST, "vec4", wxString::Format("fc%d", m_const_index++)); + mem32_t data(m_addr + m_size + m_offset); + + m_offset += 4 * 4; + u32 x = GetData(data[0]); + u32 y = GetData(data[1]); + u32 z = GetData(data[2]); + u32 w = GetData(data[3]); + return m_parr.AddParam(PARAM_UNIFORM, "vec4", wxString::Format("fc%u", m_size + 4 * 4), + wxString::Format("vec4(%f, %f, %f, %f)", (float&)x, (float&)y, (float&)z, (float&)w)); } wxString FragmentDecompilerThread::AddTex() { - return m_parr.AddParam(PARAM_CONST, "sampler2D", wxString::Format("tex_%d", dst.tex_num)); + return m_parr.AddParam(PARAM_UNIFORM, "sampler2D", wxString::Format("tex%d", dst.tex_num)); } template wxString FragmentDecompilerThread::GetSRC(T src) @@ -69,7 +138,7 @@ template wxString FragmentDecompilerThread::GetSRC(T src) switch(src.reg_type) { case 0: //tmp - ret += AddReg(src.tmp_reg_index); + ret += AddReg(src.tmp_reg_index, src.fp16); break; case 1: //input @@ -102,7 +171,6 @@ template wxString FragmentDecompilerThread::GetSRC(T src) break; case 2: //const - ConLog.Write("reg index = %d", src.tmp_reg_index); ret += AddConst(); break; @@ -113,13 +181,14 @@ template wxString FragmentDecompilerThread::GetSRC(T src) } static const char f[4] = {'x', 'y', 'z', 'w'}; + wxString swizzle = wxEmptyString; swizzle += f[src.swizzle_x]; swizzle += f[src.swizzle_y]; swizzle += f[src.swizzle_z]; swizzle += f[src.swizzle_w]; - if(swizzle != "xyzw") ret += "." + swizzle; + if(strncmp(swizzle, f, 4) != 0) ret += "." + swizzle; if(src.abs) ret = "abs(" + ret + ")"; if(src.neg) ret = "-" + ret; @@ -131,6 +200,11 @@ wxString FragmentDecompilerThread::BuildCode() { wxString p = wxEmptyString; + if(!m_parr.HasParam(PARAM_OUT, "vec4", "r0") && m_parr.HasParam(PARAM_NONE, "vec4", "h0")) + { + main += "\t" + m_parr.AddParam(PARAM_OUT, "vec4", "r0", 0) + " = " + "h0;\n"; + } + for(u32 i=0; i m_id; + +public: + GLrbo(); + ~GLrbo(); + + void Create(u32 count = 1); + void Bind(u32 num = 0) const; + void Storage(u32 format, u32 width, u32 height); + static void Unbind(); + void Delete(); + bool IsCreated() const; + u32 GetId(u32 num) const; +}; + +class GLfbo +{ +protected: + GLuint m_id; + GLuint m_type; + +public: + GLfbo(); + ~GLfbo(); + + void Create(); + void Bind(u32 type = GL_FRAMEBUFFER, int id = -1); + void Texture1D(u32 attachment, u32 texture, int level = 0); + void Texture2D(u32 attachment, u32 texture, int level = 0); + void Texture3D(u32 attachment, u32 texture, int zoffset = 0, int level = 0); + void Renderbuffer(u32 attachment, u32 renderbuffer); + void Blit(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, u32 mask, u32 filter); + void Unbind(); + static void Unbind(u32 type); void Delete(); bool IsCreated() const; }; \ No newline at end of file diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index 335f834fb7..b7d15d2323 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "GLGSRender.h" +#include "Emu/Cell/PPCInstrTable.h" #define CMD_DEBUG 0 #define DUMP_VERTEX_DATA 1 @@ -10,11 +11,10 @@ #define CMD_LOG(...) #endif -gcmBuffer gcmBuffers[2]; +gcmBuffer gcmBuffers[8]; -void checkForGlError(const char* situation) +void printGlError(GLenum err, const char* situation) { - GLenum err = glGetError(); if(err != GL_NO_ERROR) { ConLog.Error("%s: opengl error 0x%04x", situation, err); @@ -22,12 +22,17 @@ void checkForGlError(const char* situation) } } +void checkForGlError(const char* situation) +{ + printGlError(glGetError(), situation); +} + #if 0 #define checkForGlError(x) /*x*/ #endif GLGSFrame::GLGSFrame() - : GSFrame(NULL, "GSFrame[OpenGL]") + : GSFrame(nullptr, "GSFrame[OpenGL]") , m_frames(0) { canvas = new wxGLCanvas(this, wxID_ANY, NULL); @@ -75,8 +80,9 @@ void GLGSFrame::SetViewport(int x, int y, u32 w, u32 h) } GLGSRender::GLGSRender() - : m_frame(NULL) - , m_rsx_thread(NULL) + : GSRender() + , m_frame(nullptr) + , m_rsx_thread(nullptr) , m_fp_buf_num(-1) , m_vp_buf_num(-1) { @@ -120,6 +126,7 @@ void GLRSXThread::Task() InitProcTable(); glEnable(GL_TEXTURE_2D); + glEnable(GL_SCISSOR_TEST); glSwapInterval(Ini.GSVSyncEnable.GetValue() ? 1 : 0); bool draw = true; @@ -132,68 +139,44 @@ void GLRSXThread::Task() { wxCriticalSectionLocker lock(p.m_cs_main); - if(p.m_ctrl->get == p.m_ctrl->put || !Emu.IsRunned()) + const u32 get = re(p.m_ctrl->get); + const u32 put = re(p.m_ctrl->put); + if(put == get || !Emu.IsRunned()) { - SemaphorePostAndWait(p.m_sem_flush); - - if(p.m_draw) - { - p.m_draw = false; - - if(p.m_skip_frames) - { - if(!draw) - { - if(skipped++ >= p.m_skip_frames) - { - skipped = 0; - draw = true; - } - } - else - { - if(drawed++ >= p.m_draw_frames) - { - drawed = 0; - draw = false; - } - } - } - - if(draw) p.m_frame->Flip(); - - p.m_flip_status = 0; - if(SemaphorePostAndWait(p.m_sem_flip)) continue; - } + if(put == get) + SemaphorePostAndWait(p.m_sem_flush); Sleep(1); continue; } - const u32 get = re(p.m_ctrl->get); + //ConLog.Write("addr = 0x%x", p.m_ioAddress + get); const u32 cmd = Memory.Read32(p.m_ioAddress + get); const u32 count = (cmd >> 18) & 0x7ff; + //if(cmd == 0) continue; if(cmd & CELL_GCM_METHOD_FLAG_JUMP) { u32 addr = cmd & ~(CELL_GCM_METHOD_FLAG_JUMP | CELL_GCM_METHOD_FLAG_NON_INCREMENT); - p.m_ctrl->get = re32(addr); - ConLog.Warning("rsx jump(0x%x)", addr); + //ConLog.Warning("rsx jump(0x%x) #addr=0x%x, cmd=0x%x, get=0x%x, put=0x%x", addr, p.m_ioAddress + get, cmd, get, put); + re(p.m_ctrl->get, addr); continue; } if(cmd & CELL_GCM_METHOD_FLAG_CALL) { call_stack.Push(get + 4); - u32 addr = cmd & ~CELL_GCM_METHOD_FLAG_CALL; - p.m_ctrl->get = re32(addr); - ConLog.Warning("rsx call(0x%x)", addr); + u32 offs = cmd & ~CELL_GCM_METHOD_FLAG_CALL; + u32 addr = p.m_ioAddress + offs; + //ConLog.Warning("rsx call(0x%x) #0x%x - 0x%x - 0x%x", offs, addr, cmd, get); + p.m_ctrl->get = re32(offs); continue; } - if(cmd & CELL_GCM_METHOD_FLAG_RETURN) + if(cmd == CELL_GCM_METHOD_FLAG_RETURN) { - u32 addr = call_stack.Pop(); - p.m_ctrl->get = re32(addr); - ConLog.Warning("rsx return(0x%x)", addr); + //ConLog.Warning("rsx return!"); + u32 get = call_stack.Pop(); + //ConLog.Warning("rsx return(0x%x)", get); + p.m_ctrl->get = re32(get); continue; } if(cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT) @@ -238,15 +221,21 @@ void GLGSRender::Init(const u32 ioAddress, const u32 ioSize, const u32 ctrlAddre m_draw_frames = 1; m_skip_frames = 0; + m_width = 720; + m_height = 576; m_frame->Show(); m_ioAddress = ioAddress; m_ioSize = ioSize; m_ctrlAddress = ctrlAddress; - m_localAddress = localAddress; + m_local_mem_addr = localAddress; m_ctrl = (CellGcmControl*)Memory.GetMemFromAddr(m_ctrlAddress); + m_cur_vertex_prog = nullptr; + m_cur_shader_prog = nullptr; + m_cur_shader_prog_num = 0; + (m_rsx_thread = new GLRSXThread(this))->Start(); } @@ -265,23 +254,23 @@ void GLGSRender::Close() } if(m_frame->IsShown()) m_frame->Hide(); - m_ctrl = NULL; + m_ctrl = nullptr; } void GLGSRender::EnableVertexData(bool indexed_draw) { - Array offset_list; + static u32 offset_list[16]; u32 cur_offset = 0; for(u32 i=0; i<16; ++i) { - offset_list.AddCpy(cur_offset); + offset_list[i] = cur_offset; - if(!m_vertex_data[i].IsEnabled()) continue; + if(!m_vertex_data[i].IsEnabled() || !m_vertex_data[i].addr) continue; cur_offset += m_vertex_data[i].data.GetCount(); const u32 pos = m_vdata.GetCount(); - m_vdata.SetCount(pos + m_vertex_data[i].data.GetCount()); + m_vdata.InsertRoomEnd(m_vertex_data[i].data.GetCount()); memcpy(&m_vdata[pos], &m_vertex_data[i].data[0], m_vertex_data[i].data.GetCount()); } @@ -305,7 +294,7 @@ void GLGSRender::EnableVertexData(bool indexed_draw) wxFile dump("VertexDataArray.dump", wxFile::write); #endif - for(u32 i=0; i<16; ++i) + for(u32 i=0; i= 1 && m_vertex_data[i].type <= 7) { - u32 gltype = gl_types[m_vertex_data[i].type - 1]; - bool normalized = gl_normalized[m_vertex_data[i].type - 1]; + if(!m_vertex_data[i].addr) + { + switch(m_vertex_data[i].type) + { + case 5: + case 1: + switch(m_vertex_data[i].size) + { + case 1: glVertexAttrib1s(i, (GLshort&)m_vertex_data[i].data[0]); break; + case 2: glVertexAttrib2sv(i, (GLshort*)&m_vertex_data[i].data[0]); break; + case 3: glVertexAttrib3sv(i, (GLshort*)&m_vertex_data[i].data[0]); break; + case 4: glVertexAttrib4sv(i, (GLshort*)&m_vertex_data[i].data[0]); break; + } + break; - glEnableVertexAttribArray(i); - checkForGlError("glEnableVertexAttribArray"); - glVertexAttribPointer(i, m_vertex_data[i].size, gltype, normalized, 0, (void*)offset_list[i]); - checkForGlError("glVertexAttribPointer"); + case 2: + switch(m_vertex_data[i].size) + { + case 1: glVertexAttrib1f(i, (GLfloat&)m_vertex_data[i].data[0]); break; + case 2: glVertexAttrib2fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break; + case 3: glVertexAttrib3fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break; + case 4: glVertexAttrib4fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break; + } + break; + + case 6: + case 4: + glVertexAttrib4ubv(i, (GLubyte*)&m_vertex_data[i].data[0]); + break; + } + + checkForGlError("glVertexAttrib"); + } + else + { + u32 gltype = gl_types[m_vertex_data[i].type - 1]; + bool normalized = gl_normalized[m_vertex_data[i].type - 1]; + + glEnableVertexAttribArray(i); + checkForGlError("glEnableVertexAttribArray"); + glVertexAttribPointer(i, m_vertex_data[i].size, gltype, normalized, 0, (void*)offset_list[i]); + checkForGlError("glVertexAttribPointer"); + } } } } @@ -405,17 +430,19 @@ void GLGSRender::EnableVertexData(bool indexed_draw) void GLGSRender::DisableVertexData() { m_vdata.Clear(); - for(u32 i=0; i<16; ++i) + for(u32 i=0; iconstants4.GetCount(); ++i) + for(u32 i=0; iconstants4[i]; - const wxString& name = wxString::Format("vc%d", c.id); - //const int l = glGetUniformLocation(m_program.id, name); + const TransformConstant& c = m_transform_constants[i]; + const wxString name = wxString::Format("vc%u", c.id); const int l = m_program.GetLocation(name); checkForGlError("glGetUniformLocation " + name); //ConLog.Write(name + " x: %.02f y: %.02f z: %.02f w: %.02f", c.x, c.y, c.z, c.w); glUniform4f(l, c.x, c.y, c.z, c.w); - checkForGlError("glUniform4f " + name); + checkForGlError("glUniform4f " + name + wxString::Format(" %d [%f %f %f %f]", l, c.x, c.y, c.z, c.w)); + } +} + +void GLGSRender::InitFragmentData() +{ + if(!m_cur_shader_prog) + { + ConLog.Error("InitFragmentData: m_cur_shader_prog == NULL"); + return; + } + + for(u32 i=0; ioffset; + if(id < 32) + id = 32; + + const wxString name = wxString::Format("fc%u", id); + const int l = m_program.GetLocation(name); + checkForGlError("glGetUniformLocation " + name); + + //ConLog.Write(name + " x: %.02f y: %.02f z: %.02f w: %.02f", c.x, c.y, c.z, c.w); + glUniform4f(l, c.x, c.y, c.z, c.w); + checkForGlError("glUniform4f " + name + wxString::Format(" %d [%f %f %f %f]", l, c.x, c.y, c.z, c.w)); } } @@ -461,21 +513,79 @@ void GLGSRender::InitVertexData() void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 count) { #if CMD_DEBUG - wxString debug = getMethodName(cmd); + wxString debug = GetMethodName(cmd); debug += "("; for(u32 i=0; i= m_skip_frames) + { + skipped = 0; + draw = true; + } + } + else + { + if(drawed++ >= m_draw_frames) + { + drawed = 0; + draw = false; + } + } + }*/ + + //if(draw) + { + //if(m_frame->GetClientSize() != wxSize(m_viewport_w, m_viewport_h)) + // m_frame->SetClientSize(m_viewport_w, m_viewport_h); + + if(m_fbo.IsCreated()) + { + m_fbo.Bind(GL_READ_FRAMEBUFFER); + m_fbo.Bind(GL_DRAW_FRAMEBUFFER, 0); + m_fbo.Blit( + 0, 0, m_width, m_height, + 0, 0, m_width, m_height, + GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); + m_fbo.Bind(); + } + + m_frame->Flip(); + } + + m_gcm_current_buffer = args[0]; + + m_flip_status = 0; + if(m_flip_handler) + { + m_flip_handler.Handle(1, 0, 0); + m_flip_handler.Branch(false); + } + + SemaphorePostAndWait(m_sem_flip); + } + } + break; + case NV4097_NO_OPERATION: break; @@ -487,15 +597,23 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c { GLTexture& tex = m_frame->GetTexture(index); const u32 offset = args[0]; - const u8 location = args[1] & 0x3 - 1; - const bool cubemap = (args[1] >> 2) & 0x1; - const u8 dimension = (args[1] >> 4) & 0xf; - const u8 format = (args[1] >> 8) & 0xff; - const u16 mipmap = (args[1] >> 16) & 0xffff; + u32 a1 = args[1]; + u8 location = (a1 & 0x3) - 1; + const bool cubemap = (a1 >> 2) & 0x1; + const u8 dimension = (a1 >> 4) & 0xf; + const u8 format = (a1 >> 8) & 0xff; + const u16 mipmap = (a1 >> 16) & 0xffff; CMD_LOG("index = %d, offset=0x%x, location=0x%x, cubemap=0x%x, dimension=0x%x, format=0x%x, mipmap=0x%x", index, offset, location, cubemap, dimension, format, mipmap); - tex.SetOffset(GetAddress(offset, location)); + if(location == 2) + { + ConLog.Error("Bad texture location."); + location = 1; + } + u32 tex_addr = GetAddress(offset, location); + //ConLog.Warning("texture addr = 0x%x #offset = 0x%x, location=%d", tex_addr, offset, location); + tex.SetOffset(tex_addr); tex.SetFormat(cubemap, dimension, format, mipmap); } break; @@ -503,10 +621,15 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c case_16(NV4097_SET_TEXTURE_CONTROL0, 0x20): { GLTexture& tex = m_frame->GetTexture(index); - tex.Enable(args[0] >> 31 ? true : false); + u32 a0 = args[0]; + bool enable = a0 >> 31 ? true : false; + u16 minlod = (a0 >> 19) & 0xfff; + u16 maxlod = (a0 >> 7) & 0xfff; + u8 maxaniso = (a0 >> 2) & 0x7; + tex.SetControl0(enable, minlod, maxlod, maxaniso); } break; - + case_16(NV4097_SET_VERTEX_DATA4UB_M, 4): { u32 v = args[0]; @@ -515,21 +638,73 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c u8 v2 = v >> 16; u8 v3 = v >> 24; - m_vertex_data[index].type = 7; + m_vertex_data[index].size = 4; + m_vertex_data[index].type = 4; m_vertex_data[index].data.AddCpy(v0); m_vertex_data[index].data.AddCpy(v1); m_vertex_data[index].data.AddCpy(v2); m_vertex_data[index].data.AddCpy(v3); - ConLog.Warning("index = %d, v0 = 0x%x, v1 = 0x%x, v2 = 0x%x, v3 = 0x%x", index, v0, v1, v2, v3); + //ConLog.Warning("index = %d, v0 = 0x%x, v1 = 0x%x, v2 = 0x%x, v3 = 0x%x", index, v0, v1, v2, v3); + } + break; + + case_16(NV4097_SET_VERTEX_DATA2F_M, 8): + { + u32 a0 = args[0]; + u32 a1 = args[1]; + + float v0 = (float&)a0; + float v1 = (float&)a1; + + m_vertex_data[index].type = 2; + m_vertex_data[index].size = 2; + m_vertex_data[index].data.SetCount(sizeof(float) * 2); + (float&)m_vertex_data[index].data[sizeof(float)*0] = v0; + (float&)m_vertex_data[index].data[sizeof(float)*1] = v1; + + //ConLog.Warning("index = %d, v0 = %f, v1 = %f", index, v0, v1); + } + break; + + case_16(NV4097_SET_VERTEX_DATA4F_M, 16): + { + u32 a0 = args[0]; + u32 a1 = args[1]; + u32 a2 = args[2]; + u32 a3 = args[3]; + + float v0 = (float&)a0; + float v1 = (float&)a1; + float v2 = (float&)a2; + float v3 = (float&)a3; + + m_vertex_data[index].type = 2; + m_vertex_data[index].size = 4; + m_vertex_data[index].data.SetCount(sizeof(float) * 4); + (float&)m_vertex_data[index].data[sizeof(float)*0] = v0; + (float&)m_vertex_data[index].data[sizeof(float)*1] = v1; + (float&)m_vertex_data[index].data[sizeof(float)*2] = v2; + (float&)m_vertex_data[index].data[sizeof(float)*3] = v3; + + //ConLog.Warning("index = %d, v0 = %f, v1 = %f, v2 = %f, v3 = %f", index, v0, v1, v2, v3); } break; case_16(NV4097_SET_TEXTURE_CONTROL1, 0x20): - //TODO + { + GLTexture& tex = m_frame->GetTexture(index); + tex.SetControl1(args[0]); + } break; case_16(NV4097_SET_TEXTURE_CONTROL3, 4): - //TODO + { + GLTexture& tex = m_frame->GetTexture(index); + u32 a0 = args[0]; + u32 pitch = a0 & 0xFFFFF; + u16 depth = a0 >> 20; + tex.SetControl3(pitch, depth); + } break; case_16(NV4097_SET_TEXTURE_FILTER, 0x20): @@ -537,7 +712,21 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c break; case_16(NV4097_SET_TEXTURE_ADDRESS, 0x20): - //TODO + { + GLTexture& tex = m_frame->GetTexture(index); + + u32 a0 = args[0]; + u8 wraps = a0 & 0xf; + u8 aniso_bias = (a0 >> 4) & 0xf; + u8 wrapt = (a0 >> 8) & 0xf; + u8 unsigned_remap = (a0 >> 12) & 0xf; + u8 wrapr = (a0 >> 16) & 0xf; + u8 gamma = (a0 >> 20) & 0xf; + u8 signed_remap = (a0 >> 24) & 0xf; + u8 zfunc = a0 >> 28; + + tex.SetAddress(wraps, wrapt, wrapr, unsigned_remap, zfunc, gamma, aniso_bias, signed_remap); + } break; case_16(NV4097_SET_TEX_COORD_CONTROL, 4): @@ -557,20 +746,81 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c case NV4097_SET_SURFACE_FORMAT: { - const u32 color_format = args[0] & 0x1f; - const u32 depth_format = (args[0] >> 5) & 0x7; - const u32 type = (args[0] >> 8) & 0xf; - const u32 antialias = (args[0] >> 12) & 0xf; - const u32 width = (args[0] >> 16) & 0xff; - const u32 height = (args[0] >> 24) & 0xff; - const u32 pitch_a = args[1]; - const u32 offset_a = args[2]; - const u32 offset_z = args[3]; - const u32 offset_b = args[4]; - const u32 pitch_b = args[5]; + u32 a0 = args[0]; + m_set_surface_format = true; + m_surface_color_format = a0 & 0x1f; + m_surface_depth_format = (a0 >> 5) & 0x7; + m_surface_type = (a0 >> 8) & 0xf; + m_surface_antialias = (a0 >> 12) & 0xf; + m_surface_width = (a0 >> 16) & 0xff; + m_surface_height = (a0 >> 24) & 0xff; + m_surface_pitch_a = args[1]; + m_surface_offset_a = args[2]; + m_surface_offset_z = args[3]; + m_surface_offset_b = args[4]; + m_surface_pitch_b = args[5]; - CMD_LOG("color_format=%d, depth_format=%d, type=%d, antialias=%d, width=%d, height=%d, pitch_a=%d, offset_a=0x%x, offset_z=0x%x, offset_b=0x%x, pitch_b=%d", - color_format, depth_format, type, antialias, width, height, pitch_a, offset_a, offset_z, offset_b, pitch_b); + /* + ConLog.Write("surface color format: 0x%x", m_surface_color_format); + ConLog.Write("surface depth format: 0x%x", m_surface_depth_format); + ConLog.Write("surface type: 0x%x", m_surface_type); + ConLog.Write("surface antialias: 0x%x", m_surface_antialias); + ConLog.Write("surface width: 0x%x", m_surface_width); + ConLog.Write("surface height: 0x%x", m_surface_height); + ConLog.Write("surface pitch a: 0x%x", m_surface_pitch_a); + ConLog.Write("surface offset a: 0x%x", m_surface_offset_a); + ConLog.Write("surface offset z: 0x%x", m_surface_offset_z); + ConLog.Write("surface offset b: 0x%x", m_surface_offset_b); + ConLog.Write("surface pitch b: 0x%x", m_surface_pitch_b); + if(m_surface_offset_a && m_set_context_dma_color_a) + { + u32 surface_addr = GetAddress(m_surface_offset_a, (m_context_dma_color_a - 0xfeed0000)); + auto& surface = (const CellGcmSurface&)Memory[surface_addr]; + ConLog.Write("context_dma_color_a=0x%x", m_context_dma_color_a); + ConLog.Write("context a: color format: 0x%x", surface.color_format); + ConLog.Write("context a: depth format: 0x%x", surface.depth_format); + ConLog.Write("context a: type: 0x%x", surface.type); + ConLog.Write("context a: antialias: 0x%x", surface.antialias); + ConLog.Write("context a: width: 0x%x", surface.width); + ConLog.Write("context a: height: 0x%x", surface.height); + } + else if(m_surface_offset_z && m_set_context_dma_z) + { + u32 surface_addr = GetAddress(m_surface_offset_z, m_context_dma_z); + auto& surface = (const CellGcmSurface&)Memory[surface_addr]; + ConLog.Write("m_surface_offset_z=0x%x", m_surface_offset_z); + ConLog.Write("context x: color format: 0x%x", surface.color_format); + ConLog.Write("context z: depth format: 0x%x", surface.depth_format); + ConLog.Write("context z: type: 0x%x", surface.type); + ConLog.Write("context z: antialias: 0x%x", surface.antialias); + ConLog.Write("context z: width: 0x%x", surface.width); + ConLog.Write("context z: height: 0x%x", surface.height); + + m_width = surface.width; + m_height = surface.height; + } + */ + + if(0) + { + m_rbo.Create(2); + checkForGlError("m_rbo.Create"); + m_rbo.Bind(0); + m_rbo.Storage(GL_RGBA, m_width, m_height); + checkForGlError("m_rbo.Storage(GL_RGBA)"); + m_rbo.Bind(1); + m_rbo.Storage(GL_DEPTH_STENCIL, m_width, m_height); + checkForGlError("m_rbo.Storage(GL_DEPTH24_STENCIL8)"); + m_fbo.Create(); + checkForGlError("m_fbo.Create"); + m_fbo.Bind(); + m_fbo.Renderbuffer(GL_COLOR_ATTACHMENT0, m_rbo.GetId(0)); + checkForGlError("m_fbo.Renderbuffer(GL_COLOR_ATTACHMENT0)"); + m_fbo.Renderbuffer(GL_DEPTH_STENCIL_ATTACHMENT, m_rbo.GetId(1)); + checkForGlError("m_fbo.Renderbuffer(GL_DEPTH_STENCIL_ATTACHMENT)"); + } + //CMD_LOG("color_format=%d, depth_format=%d, type=%d, antialias=%d, width=%d, height=%d, pitch_a=%d, offset_a=0x%x, offset_z=0x%x, offset_b=0x%x, pitch_b=%d", + // color_format, depth_format, type, antialias, width, height, pitch_a, offset_a, offset_z, offset_b, pitch_b); } break; @@ -593,17 +843,22 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c case NV4097_SET_ALPHA_TEST_ENABLE: m_set_alpha_test = args[0] ? true : false; - //Enable(args[0] ? true : false, GL_ALPHA_TEST); break; case NV4097_SET_BLEND_ENABLE: m_set_blend = args[0] ? true : false; - //Enable(args[0] ? true : false, GL_BLEND); break; case NV4097_SET_DEPTH_BOUNDS_TEST_ENABLE: m_set_depth_bounds_test = args[0] ? true : false; - //Enable(args[0] ? true : false, GL_DEPTH_CLAMP); + break; + + case NV4097_SET_ALPHA_FUNC: + glAlphaFunc(args[0], args[1]); + break; + + case NV4097_SET_CULL_FACE: + glCullFace(args[0]); break; case NV4097_SET_VIEWPORT_VERTICAL: @@ -628,9 +883,6 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c } CMD_LOG("x=%d, y=%d, w=%d, h=%d", m_viewport_x, m_viewport_y, m_viewport_w, m_viewport_h); - - //m_frame->SetViewport(m_viewport_x, m_viewport_y, m_viewport_w, m_viewport_h); - //glViewport(x, y, w, h); } break; @@ -644,47 +896,66 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c m_clip_max = (float&)clip_max; CMD_LOG("clip_min=%.01f, clip_max=%.01f", m_clip_min, m_clip_max); - - //glDepthRangef(m_clip_min, m_clip_max); } break; case NV4097_SET_DEPTH_FUNC: m_set_depth_func = true; m_depth_func = args[0]; - //glDepthFunc(m_depth_func); break; case NV4097_SET_DEPTH_TEST_ENABLE: m_depth_test_enable = args[0] ? true : false; - //Enable(args[0] ? true : false, GL_DEPTH_TEST); break; case NV4097_SET_FRONT_POLYGON_MODE: - glPolygonMode(GL_FRONT, args[0]); + m_set_front_polygon_mode = true; + m_front_polygon_mode = args[0]; + //glPolygonMode(GL_FRONT, args[0]); break; case NV4097_CLEAR_SURFACE: { - const u32 mask = args[0]; + u32 a0 = args[0]; GLbitfield f = 0; - if (mask & 0x1) f |= GL_DEPTH_BUFFER_BIT; - if (mask & 0x2) f |= GL_STENCIL_BUFFER_BIT; - if (mask & 0x10) f |= GL_COLOR_BUFFER_BIT; + if (a0 & 0x1) f |= GL_DEPTH_BUFFER_BIT; + if (a0 & 0x2) f |= GL_STENCIL_BUFFER_BIT; + if (a0 & 0xF0) f |= GL_COLOR_BUFFER_BIT; glClear(f); + /* + if(m_set_clear_surface) + { + m_clear_surface_mask |= args[0]; + } + else + { + m_clear_surface_mask = args[0]; + m_set_clear_surface = true; + } + */ } break; case NV4097_SET_BLEND_FUNC_SFACTOR: { - const u16 src_rgb = args[0] & 0xffff; - const u16 dst_rgb = args[0] >> 16; - const u16 src_alpha = args[1] & 0xffff; - const u16 dst_alpha = args[1] >> 16; - CMD_LOG("src_rgb=0x%x, dst_rgb=0x%x, src_alpha=0x%x, dst_alpha=0x%x", - src_rgb, dst_rgb, src_alpha, dst_alpha); + m_set_blend_sfactor = true; + m_blend_sfactor_rgb = args[0] & 0xffff; + m_blend_sfactor_alpha = args[0] >> 16; - glBlendFuncSeparate(src_rgb, dst_rgb, src_alpha, dst_alpha); + if(count >= 2) + { + m_set_blend_dfactor = true; + m_blend_dfactor_rgb = args[1] & 0xffff; + m_blend_dfactor_alpha = args[1] >> 16; + } + } + break; + + case NV4097_SET_BLEND_FUNC_DFACTOR: + { + m_set_blend_dfactor = true; + m_blend_dfactor_rgb = args[0] & 0xffff; + m_blend_dfactor_alpha = args[0] >> 16; } break; @@ -692,23 +963,22 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c { const u32 addr = GetAddress(args[0] & 0x7fffffff, args[0] >> 31); CMD_LOG("num=%d, addr=0x%x", index, addr); - m_vertex_data[index].addr = addr; } break; case_16(NV4097_SET_VERTEX_DATA_ARRAY_FORMAT, 4): { - const u16 frequency = args[0] >> 16; - const u8 stride = (args[0] >> 8) & 0xff; - const u8 size = (args[0] >> 4) & 0xf; - const u8 type = args[0] & 0xf; + u32 a0 = args[0]; + const u16 frequency = a0 >> 16; + const u8 stride = (a0 >> 8) & 0xff; + const u8 size = (a0 >> 4) & 0xf; + const u8 type = a0 & 0xf; CMD_LOG("index=%d, frequency=%d, stride=%d, size=%d, type=%d", index, frequency, stride, size, type); VertexData& cv = m_vertex_data[index]; - cv.frequency = frequency; cv.stride = stride; cv.size = size; @@ -757,7 +1027,7 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c m_indexed_array.m_data.InsertRoomEnd(4); index = Memory.Read32(m_indexed_array.m_addr + i * 4); *(u32*)&m_indexed_array.m_data[pos] = index; - ConLog.Warning("index 4: %d", *(u32*)&m_indexed_array.m_data[pos]); + //ConLog.Warning("index 4: %d", *(u32*)&m_indexed_array.m_data[pos]); } break; @@ -766,8 +1036,8 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c int pos = m_indexed_array.m_data.GetCount(); m_indexed_array.m_data.InsertRoomEnd(2); index = Memory.Read16(m_indexed_array.m_addr + i * 2); - ConLog.Warning("index 2: %d", index); - *(u32*)&m_indexed_array.m_data[pos] = index; + //ConLog.Warning("index 2: %d", index); + *(u16*)&m_indexed_array.m_data[pos] = index; } break; } @@ -786,36 +1056,48 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c if(args[0]) { //begin + if(Emu.GetCallbackManager().m_exit_callback.m_callbacks.GetCount()) + { + //Emu.GetCallbackManager().m_exit_callback.Handle(0x0121, 0); + } m_draw_mode = args[0] - 1; } else { //end ExecCMD(); + if(Emu.GetCallbackManager().m_exit_callback.m_callbacks.GetCount()) + { + //Emu.GetCallbackManager().m_exit_callback.Handle(0x0122, 0); + } } } break; case NV4097_SET_COLOR_CLEAR_VALUE: { - const u8 a = (args[0] >> 24) & 0xff; - const u8 r = (args[0] >> 16) & 0xff; - const u8 g = (args[0] >> 8) & 0xff; - const u8 b = args[0] & 0xff; - CMD_LOG("a=%d, r=%d, g=%d, b=%d", a, r, g, b); + const u32 color = args[0]; + //m_set_clear_color = true; + m_clear_color_a = (color >> 24) & 0xff; + m_clear_color_r = (color >> 16) & 0xff; + m_clear_color_g = (color >> 8) & 0xff; + m_clear_color_b = color & 0xff; + glClearColor( - (float)r / 255.0f, - (float)g / 255.0f, - (float)b / 255.0f, - (float)a / 255.0f); + m_clear_color_r / 255.0f, + m_clear_color_g / 255.0f, + m_clear_color_b / 255.0f, + m_clear_color_a / 255.0f); } break; case NV4097_SET_SHADER_PROGRAM: { - m_shader_prog.Delete(); - m_shader_prog.addr = GetAddress(args[0] & ~0x3, (args[0] & 0x3) - 1); - //m_program.Delete(); + m_cur_shader_prog = &m_shader_progs[m_cur_shader_prog_num++]; + m_cur_shader_prog->Delete(); + u32 a0 = args[0]; + m_cur_shader_prog->offset = a0 & ~0x3; + m_cur_shader_prog->addr = GetAddress(m_cur_shader_prog->offset, (a0 & 0x3) - 1); } break; @@ -838,13 +1120,14 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c case NV4097_SET_TRANSFORM_PROGRAM_LOAD: { - //m_program.Delete(); m_cur_vertex_prog = &m_vertex_progs[args[0]]; m_cur_vertex_prog->Delete(); if(count == 2) { const u32 start = args[1]; + if(start) + ConLog.Warning("NV4097_SET_TRANSFORM_PROGRAM_LOAD: start = %d", start); } } break; @@ -887,12 +1170,6 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c break; } - if(!m_cur_vertex_prog) - { - ConLog.Warning("NV4097_SET_TRANSFORM_CONSTANT_LOAD: m_cur_vertex_prog == NULL"); - break; - } - for(u32 id = args[0], i = 1; iconstants4.AddCpy(c); + m_transform_constants.AddCpy(c); } } break; case NV4097_SET_LOGIC_OP_ENABLE: - Enable(args[0] ? true : false, GL_LOGIC_OP); + m_set_logic_op = args[0] ? true : false; break; case NV4097_SET_CULL_FACE_ENABLE: - Enable(args[0] ? true : false, GL_CULL_FACE); + m_set_cull_face = args[0] ? true : false; break; case NV4097_SET_DITHER_ENABLE: - Enable(args[0] ? true : false, GL_DITHER); + m_set_dither = args[0] ? true : false; break; case NV4097_SET_STENCIL_TEST_ENABLE: - Enable(args[0] ? true : false, GL_STENCIL_TEST); + m_set_stencil_test = args[0] ? true : false; + break; + + case NV4097_SET_STENCIL_MASK: + m_set_stencil_mask = true; + m_stencil_mask = args[0]; + break; + + case NV4097_SET_STENCIL_FUNC: + m_set_stencil_func = true; + m_stencil_func = args[0]; + if(count >= 2) + { + m_set_stencil_func_ref = true; + m_stencil_func_ref = args[1]; + + if(count >= 3) + { + m_set_stencil_func_mask = true; + m_stencil_func_mask = args[2]; + } + } + break; + + case NV4097_SET_STENCIL_FUNC_REF: + m_set_stencil_func_ref = true; + m_stencil_func_ref = args[0]; + break; + + case NV4097_SET_STENCIL_FUNC_MASK: + m_set_stencil_func_mask = true; + m_stencil_func_mask = args[0]; + break; + + case NV4097_SET_STENCIL_OP_FAIL: + m_set_stencil_fail = true; + m_stencil_fail = args[0]; + if(count >= 2) + { + m_set_stencil_zfail = true; + m_stencil_zfail = args[1]; + + if(count >= 3) + { + m_set_stencil_zpass = true; + m_stencil_zpass = args[2]; + } + } break; case NV4097_SET_TWO_SIDED_STENCIL_TEST_ENABLE: - if(args[0]) ConLog.Error("NV4097_SET_TWO_SIDED_STENCIL_TEST_ENABLE"); + m_set_two_sided_stencil_test_enable = args[0] ? true : false; + break; + + case NV4097_SET_BACK_STENCIL_MASK: + m_set_back_stencil_mask = true; + m_back_stencil_mask = args[0]; + break; + + case NV4097_SET_BACK_STENCIL_FUNC: + m_set_back_stencil_func = true; + m_back_stencil_func = args[0]; + if(count >= 2) + { + m_set_back_stencil_func_ref = true; + m_back_stencil_func_ref = args[1]; + + if(count >= 3) + { + m_set_back_stencil_func_mask = true; + m_back_stencil_func_mask = args[2]; + } + } + break; + + case NV4097_SET_BACK_STENCIL_FUNC_REF: + m_set_back_stencil_func_ref = true; + m_back_stencil_func_ref = args[0]; + break; + + case NV4097_SET_BACK_STENCIL_FUNC_MASK: + m_set_back_stencil_func_mask = true; + m_back_stencil_func_mask = args[0]; + break; + + case NV4097_SET_BACK_STENCIL_OP_FAIL: + m_set_stencil_fail = true; + m_stencil_fail = args[0]; + if(count >= 2) + { + m_set_back_stencil_zfail = true; + m_back_stencil_zfail = args[1]; + + if(count >= 3) + { + m_set_back_stencil_zpass = true; + m_back_stencil_zpass = args[2]; + } + } break; case NV4097_SET_POLY_OFFSET_FILL_ENABLE: @@ -953,12 +1319,15 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c break; case NV4097_SET_POLY_SMOOTH_ENABLE: - if(args[0]) ConLog.Error("NV4097_SET_POLY_SMOOTH_ENABLE"); + m_set_poly_smooth = args[0] ? true : false; break; case NV4097_SET_BLEND_COLOR: - glBlendColor(args[0] & 0xff, (args[0] >> 8) & 0xff, - (args[0] >> 16) & 0xff, (args[0] >> 24) & 0xff); + m_set_blend_color = true; + m_blend_color_r = args[0] & 0xff; + m_blend_color_g = (args[0] >> 8) & 0xff; + m_blend_color_b = (args[0] >> 16) & 0xff; + m_blend_color_a = (args[0] >> 24) & 0xff; break; case NV4097_SET_BLEND_COLOR2: @@ -966,8 +1335,9 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c break; case NV4097_SET_BLEND_EQUATION: - glBlendEquationSeparate(args[0] & 0xffff, args[0] >> 16); - //glBlendEquation + m_set_blend_equation = true; + m_blend_equation_rgb = args[0] & 0xffff; + m_blend_equation_alpha = args[0] >> 16; break; case NV4097_SET_REDUCE_DST_COLOR: @@ -975,7 +1345,8 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c break; case NV4097_SET_DEPTH_MASK: - glDepthMask(args[0]); + m_set_depth_mask = true; + m_depth_mask = args[0]; break; case NV4097_SET_SCISSOR_VERTICAL: @@ -998,10 +1369,6 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c m_scissor_y = args[1] & 0xffff; m_scissor_h = args[1] >> 16; } - - CMD_LOG("x=%d, y=%d, w=%d, h=%d", m_scissor_x, m_scissor_y, m_scissor_w, m_scissor_h); - - //glScissor(m_scissor_x, m_scissor_y, m_scissor_w, m_scissor_h); } break; @@ -1013,19 +1380,36 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c } break; - case NV4097_BACK_END_WRITE_SEMAPHORE_RELEASE: - { - //TODO - } - break; - case NV4097_SET_SEMAPHORE_OFFSET: case NV406E_SEMAPHORE_OFFSET: { - semaphore_offset = args[0]; + m_set_semaphore_offset = true; + m_semaphore_offset = args[0]; } break; + case NV4097_BACK_END_WRITE_SEMAPHORE_RELEASE: + { + if(m_set_semaphore_offset) + { + m_set_semaphore_offset = false; + u32 value = args[0]; + value = (value & 0xff00ff00) | ((value & 0xff) << 16) | ((value >> 16) & 0xff); + + Memory.Write32(Memory.RSXCMDMem.GetStartAddr() + m_semaphore_offset, value); + } + } + break; + + case NV406E_SEMAPHORE_RELEASE: + case NV4097_TEXTURE_READ_SEMAPHORE_RELEASE: + if(m_set_semaphore_offset) + { + m_set_semaphore_offset = false; + Memory.Write32(Memory.RSXCMDMem.GetStartAddr() + m_semaphore_offset, args[0]); + } + break; + case NV406E_SEMAPHORE_ACQUIRE: { //TODO @@ -1043,27 +1427,32 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c //TODO } break; + case NV4097_SET_CONTEXT_DMA_COLOR_A: { - //TODO + m_set_context_dma_color_a = true; + m_context_dma_color_a = args[0]; } break; case NV4097_SET_CONTEXT_DMA_COLOR_B: { - //TODO + m_set_context_dma_color_b = true; + m_context_dma_color_b = args[0]; } break; case NV4097_SET_CONTEXT_DMA_COLOR_C: { - //TODO + m_set_context_dma_color_c = true; + m_context_dma_color_c = args[0]; } break; case NV4097_SET_CONTEXT_DMA_ZETA: { - //TODO + m_set_context_dma_z = true; + m_context_dma_z = args[0]; } break; @@ -1097,9 +1486,30 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c } break; + case NV4097_SET_SURFACE_CLIP_VERTICAL: + { + u32 a0 = args[0]; + m_set_surface_clip_vertical = true; + m_surface_clip_y = a0; + m_surface_clip_h = a0 >> 16; + } + break; + case NV4097_SET_SURFACE_CLIP_HORIZONTAL: { - //TODO + u32 a0 = args[0]; + + m_set_surface_clip_horizontal = true; + m_surface_clip_x = a0; + m_surface_clip_w = a0 >> 16; + + if(count >= 2) + { + u32 a1 = args[1]; + m_set_surface_clip_vertical = true; + m_surface_clip_y = a1; + m_surface_clip_h = a1 >> 16; + } } break; @@ -1121,12 +1531,197 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c } break; + case NV4097_SET_LINE_SMOOTH_ENABLE: + m_set_line_smooth = args[0] ? true : false; + break; + + case NV4097_SET_LINE_WIDTH: + m_set_line_width = true; + m_line_width = args[0]; + break; + + case NV4097_SET_SHADE_MODE: + m_set_shade_mode = true; + m_shade_mode = args[0]; + break; + case NV4097_SET_ZSTENCIL_CLEAR_VALUE: case NV4097_SET_ZCULL_CONTROL0: case NV4097_SET_ZCULL_CONTROL1: case NV4097_SET_SCULL_CONTROL: break; + case NV4097_GET_REPORT: + { + u32 a0 = args[0]; + u8 type = a0 >> 24; + u32 offset = a0 & 0xffffff; + + u64 data; + switch(type) + { + case 1: + data = std::chrono::steady_clock::now().time_since_epoch().count(); + data *= 1000000; + break; + + default: + data = 0; + ConLog.Error("NV4097_GET_REPORT: bad type %d", type); + break; + } + + Memory.Write64(m_local_mem_addr + offset, data); + } + break; + + case NV3062_SET_OFFSET_DESTIN: + m_dst_offset = args[0]; + break; + + case NV308A_COLOR: + { + TransformConstant c; + c.id = m_dst_offset; + + if(count >= 1) + { + u32 a = args[0]; + a = a << 16 | a >> 16; + c.x = (float&)a; + } + + if(count >= 2) + { + u32 a = args[1]; + a = a << 16 | a >> 16; + c.y = (float&)a; + } + + if(count >= 3) + { + u32 a = args[2]; + a = a << 16 | a >> 16; + c.z = (float&)a; + } + + if(count >= 4) + { + u32 a = args[3]; + a = a << 16 | a >> 16; + c.w = (float&)a; + } + + if(count >= 5) + { + ConLog.Warning("NV308A_COLOR: count = %d", count); + } + + //ConLog.Warning("NV308A_COLOR: [%d]: %f, %f, %f, %f", c.id, c.x, c.y, c.z, c.w); + m_fragment_constants.AddCpy(c); + } + break; + + case NV308A_POINT: + //TODO + break; + + case NV3062_SET_COLOR_FORMAT: + { + m_color_format = args[0]; + m_color_format_src_pitch = args[1]; + m_color_format_dst_pitch = args[1] >> 16; + } + break; + + case NV3089_SET_COLOR_CONVERSION: + { + m_color_conv = args[0]; + m_color_conv_fmt = args[1]; + m_color_conv_op = args[2]; + m_color_conv_in_x = args[3]; + m_color_conv_in_y = args[3] >> 16; + m_color_conv_in_w = args[4]; + m_color_conv_in_h = args[4] >> 16; + m_color_conv_out_x = args[5]; + m_color_conv_out_y = args[5] >> 16; + m_color_conv_out_w = args[6]; + m_color_conv_out_h = args[6] >> 16; + m_color_conv_dsdx = args[7]; + m_color_conv_dtdy = args[8]; + } + break; + + case NV3089_IMAGE_IN_SIZE: + { + u16 w = args[0]; + u16 h = args[0] >> 16; + u16 pitch = args[1]; + u8 origin = args[1] >> 16; + u8 inter = args[1] >> 24; + u32 offset = args[2]; + u16 u = args[3]; + u16 v = args[3] >> 16; + + u8* pixels_src = &Memory[GetAddress(offset, m_context_dma_img_src - 0xfeed0000)]; + u8* pixels_dst = &Memory[GetAddress(m_dst_offset, m_context_dma_img_dst - 0xfeed0000)]; + + for(u16 y=0; y> 4) & 0xf; + m_clip_plane_2 = (a0 >> 8) & 0xf; + m_clip_plane_3 = (a0 >> 12) & 0xf; + m_clip_plane_4 = (a0 >> 16) & 0xf; + m_clip_plane_5 = a0 >> 20; + } + break; + + case NV4097_SET_FOG_PARAMS: + { + m_set_fog_params = true; + u32 a0 = args[0]; + u32 a1 = args[1]; + m_fog_param0 = (float&)a0; + m_fog_param1 = (float&)a1; + } + break; + default: { wxString log = GetMethodName(cmd); @@ -1134,7 +1729,7 @@ void GLGSRender::DoCmd(const u32 fcmd, const u32 cmd, mem32_t& args, const u32 c for(u32 i=0; iDecompile(); if(!m_cur_vertex_prog) { - ConLog.Warning("NV4097_SET_BEGIN_END: m_cur_vertex_prog == NULL"); + ConLog.Warning("LoadProgram: m_cur_vertex_prog == NULL"); return false; } @@ -1170,11 +1772,11 @@ bool GLGSRender::LoadProgram() if(m_fp_buf_num == -1) { ConLog.Warning("FP not found in buffer!"); - m_shader_prog.Wait(); - m_shader_prog.Compile(); + m_cur_shader_prog->Wait(); + m_cur_shader_prog->Compile(); wxFile f(wxGetCwd() + "/FragmentProgram.txt", wxFile::write); - f.Write(m_shader_prog.shader); + f.Write(m_cur_shader_prog->shader); } if(m_vp_buf_num == -1) @@ -1191,10 +1793,14 @@ bool GLGSRender::LoadProgram() m_program.id = m_prog_buffer.GetProg(m_fp_buf_num, m_vp_buf_num); } - if(!m_program.id) + if(m_program.id) { - m_program.Create(m_cur_vertex_prog->id, m_shader_prog.id); - m_prog_buffer.Add(m_program, m_shader_prog, *m_cur_vertex_prog); + m_program.Use(); + } + else + { + m_program.Create(m_cur_vertex_prog->id, m_cur_shader_prog->id); + m_prog_buffer.Add(m_program, *m_cur_shader_prog, *m_cur_vertex_prog); m_program.Use(); @@ -1225,53 +1831,175 @@ void GLGSRender::ExecCMD() { if(LoadProgram()) { + if(m_set_surface_clip_horizontal && m_set_surface_clip_vertical) + { + m_width = m_surface_clip_w; + m_height = m_surface_clip_h; + //ConLog.Write("width: %d, height: %d, x: %d, y: %d", m_width, m_height, m_surface_clip_x, m_surface_clip_y); + } + if(m_set_color_mask) { glColorMask(m_color_mask_r, m_color_mask_g, m_color_mask_b, m_color_mask_a); + checkForGlError("glColorMask"); } if(m_set_viewport_horizontal && m_set_viewport_vertical) { - glViewport(m_viewport_x, m_viewport_y, m_viewport_w, m_viewport_h); - if(m_frame->GetClientSize() != wxSize(m_viewport_w, m_viewport_h)) - m_frame->SetClientSize(m_viewport_w, m_viewport_h); - //m_frame->SetViewport(m_viewport_x, m_viewport_y, m_viewport_w, m_viewport_h); + glViewport(m_scissor_x, m_height-m_viewport_y-m_viewport_h, m_viewport_w, m_viewport_h); + checkForGlError("glViewport"); } if(m_set_scissor_horizontal && m_set_scissor_vertical) { - glScissor(m_scissor_x, m_scissor_y, m_scissor_w, m_scissor_h); + glScissor(m_scissor_x, m_height-m_scissor_y-m_scissor_h, m_scissor_w, m_scissor_h); + checkForGlError("glScissor"); + } + + if(m_set_clear_color) + { + glClearColor( + m_clear_color_r / 255.0f, + m_clear_color_g / 255.0f, + m_clear_color_b / 255.0f, + m_clear_color_a / 255.0f); + } + + if(m_set_clear_surface) + { + GLbitfield f = 0; + if (m_clear_surface_mask & 0x1) f |= GL_DEPTH_BUFFER_BIT; + if (m_clear_surface_mask & 0x2) f |= GL_STENCIL_BUFFER_BIT; + if (m_clear_surface_mask & 0xF0) f |= GL_COLOR_BUFFER_BIT; + glClear(f); + } + + if(m_set_front_polygon_mode) + { + glPolygonMode(GL_FRONT, m_front_polygon_mode); + checkForGlError("glPolygonMode"); } Enable(m_depth_test_enable, GL_DEPTH_TEST); Enable(m_set_alpha_test, GL_ALPHA_TEST); Enable(m_set_depth_bounds_test, GL_DEPTH_CLAMP); Enable(m_set_blend, GL_BLEND); + Enable(m_set_logic_op, GL_LOGIC_OP); + Enable(m_set_cull_face, GL_CULL_FACE); + Enable(m_set_dither, GL_DITHER); + Enable(m_set_stencil_test, GL_STENCIL_TEST); + Enable(m_set_line_smooth, GL_LINE_SMOOTH); + Enable(m_set_poly_smooth, GL_POLYGON_SMOOTH); + checkForGlError("glEnable"); + + if(m_set_clip_plane) + { + Enable(m_clip_plane_0, GL_CLIP_PLANE0); + Enable(m_clip_plane_1, GL_CLIP_PLANE1); + Enable(m_clip_plane_2, GL_CLIP_PLANE2); + Enable(m_clip_plane_3, GL_CLIP_PLANE3); + Enable(m_clip_plane_4, GL_CLIP_PLANE4); + Enable(m_clip_plane_5, GL_CLIP_PLANE5); + + checkForGlError("m_set_clip_plane"); + } + + if(m_set_two_sided_stencil_test_enable) + { + if(m_set_back_stencil_fail && m_set_back_stencil_zfail && m_set_back_stencil_zpass) + { + glStencilOpSeparate(GL_BACK, m_back_stencil_fail, m_back_stencil_zfail, m_back_stencil_zpass); + checkForGlError("glStencilOpSeparate(GL_BACK)"); + } + + if(m_set_back_stencil_mask) + { + glStencilMaskSeparate(GL_BACK, m_back_stencil_mask); + checkForGlError("glStencilMaskSeparate(GL_BACK)"); + } + + if(m_set_back_stencil_func && m_set_back_stencil_func_ref && m_set_back_stencil_func_mask) + { + glStencilFuncSeparate(GL_BACK, m_back_stencil_func, m_back_stencil_func_ref, m_back_stencil_func_mask); + checkForGlError("glStencilFuncSeparate(GL_BACK)"); + } + } + + if(m_set_stencil_fail && m_set_stencil_zfail && m_set_stencil_zpass) + { + glStencilOpSeparate(GL_FRONT, m_stencil_fail, m_stencil_zfail, m_stencil_zpass); + checkForGlError("glStencilOpSeparate(GL_FRONT)"); + } + + if(m_set_stencil_mask) + { + glStencilMaskSeparate(GL_FRONT, m_stencil_mask); + checkForGlError("glStencilMaskSeparate(GL_FRONT)"); + } + + if(m_set_stencil_func && m_set_stencil_func_ref && m_set_stencil_func_mask) + { + glStencilFuncSeparate(GL_FRONT, m_stencil_func, m_stencil_func_ref, m_stencil_func_mask); + checkForGlError("glStencilFuncSeparate(GL_FRONT)"); + } + + if(m_set_shade_mode) + { + glShadeModel(m_shade_mode); + checkForGlError("glShadeModel"); + } + + if(m_set_depth_mask) + { + glDepthMask(m_depth_mask); + checkForGlError("glDepthMask"); + } if(m_set_depth_func) { glDepthFunc(m_depth_func); + checkForGlError("glDepthFunc"); } if(m_set_clip) { glDepthRangef(m_clip_min, m_clip_max); + checkForGlError("glDepthRangef"); } - for(u32 i=0; i<16; ++i) + if(m_set_line_width) { - GLTexture& tex = m_frame->GetTexture(i); - if(!tex.IsEnabled()) continue; + glLineWidth(m_line_width / 255.f); + checkForGlError("glLineWidth"); + } - glActiveTexture(GL_TEXTURE0_ARB + i); - checkForGlError("glActiveTexture"); - tex.Bind(); - checkForGlError("tex.Bind"); - m_program.SetTex(i); - checkForGlError("m_program.SetTex"); - tex.Init(); - checkForGlError("tex.Init"); - tex.Save(); + if(m_set_blend_equation) + { + glBlendEquationSeparate(m_blend_equation_rgb, m_blend_equation_alpha); + checkForGlError("glBlendEquationSeparate"); + } + + if(m_set_blend_sfactor && m_set_blend_dfactor) + { + glBlendFuncSeparate(m_blend_sfactor_rgb, m_blend_dfactor_rgb, m_blend_sfactor_alpha, m_blend_dfactor_alpha); + checkForGlError("glBlendFuncSeparate"); + } + + if(m_set_blend_color) + { + glBlendColor(m_blend_color_r, m_blend_color_g, m_blend_color_b, m_blend_color_a); + checkForGlError("glBlendColor"); + } + + if(m_set_fog_mode) + { + glFogi(GL_FOG_MODE, m_fog_mode); + } + + if(m_set_fog_params) + { + glFogf(GL_FOG_START, m_fog_param0); + glFogf(GL_FOG_END, m_fog_param1); } if(m_indexed_array.m_count && m_draw_array_count) @@ -1279,28 +2007,45 @@ void GLGSRender::ExecCMD() ConLog.Warning("m_indexed_array.m_count && draw_array_count"); } + for(u32 i=0; iGetTexture(i); + if(!tex.IsEnabled()) continue; + + glActiveTexture(GL_TEXTURE0 + i); + checkForGlError("glActiveTexture"); + tex.Create(); + tex.Bind(); + checkForGlError("tex.Bind"); + m_program.SetTex(i); + tex.Init(); + checkForGlError("tex.Init"); + //tex.Save(); + } + + m_vao.Bind(); if(m_indexed_array.m_count) { LoadVertexData(m_indexed_array.index_min, m_indexed_array.index_max - m_indexed_array.index_min + 1); - EnableVertexData(true); - InitVertexData(); + } - wxFile log("IndexedDrawLog.txt", wxFile::write); - log.Write(wxString::Format("Draw mode: %d\n", m_draw_mode)); + EnableVertexData(m_indexed_array.m_count ? true : false); - m_vao.Bind(); + InitVertexData(); + InitFragmentData(); + + if(m_indexed_array.m_count) + { switch(m_indexed_array.m_type) { case 0: glDrawElements(m_draw_mode, m_indexed_array.m_count, GL_UNSIGNED_INT, nullptr); checkForGlError("glDrawElements #4"); - for(uint i=0; iid = 0; + if(m_cur_vertex_prog) m_cur_vertex_prog->id = 0; - memset(m_vertex_data, 0, sizeof(VertexData) * 16); + m_cur_shader_prog_num = 0; + m_transform_constants.Clear(); + for(uint i=0; i glGenTextures"); + Bind(); + + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + } + } + void SetRect(const u32 width, const u32 height) { m_width = width; @@ -54,6 +96,37 @@ public: m_mipmap = mipmap; } + void SetAddress(u8 wraps, u8 wrapt, u8 wrapr, u8 unsigned_remap, u8 zfunc, u8 gamma, u8 aniso_bias, u8 signed_remap) + { + m_wraps = wraps; + m_wrapt = wrapt; + m_wrapr = wrapr; + m_unsigned_remap = unsigned_remap; + m_zfunc = zfunc; + m_gamma = gamma; + m_aniso_bias = aniso_bias; + m_signed_remap = signed_remap; + } + + void SetControl0(const bool enable, const u16 minlod, const u16 maxlod, const u8 maxaniso) + { + m_enabled = enable; + m_minlod = minlod; + m_maxlod = maxlod; + m_maxaniso = maxaniso; + } + + void SetControl1(u32 remap) + { + m_remap = remap; + } + + void SetControl3(u16 depth, u32 pitch) + { + m_depth = depth; + m_pitch = pitch; + } + u32 GetFormat() const { return m_format; } void SetOffset(const u32 offset) @@ -66,59 +139,193 @@ public: return wxSize(m_width, m_height); } - void Init() + int GetGlWrap(int wrap) { - if(!m_id) + switch(wrap) { - glGenTextures(1, &m_id); - checkForGlError("GLTexture::Init() -> glGenTextures"); - glBindTexture(GL_TEXTURE_2D, m_id); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - } - else - { - glBindTexture(GL_TEXTURE_2D, m_id); + case 1: return GL_REPEAT; + case 2: return GL_MIRRORED_REPEAT; + case 3: return GL_CLAMP_TO_EDGE; + case 4: return GL_TEXTURE_BORDER; + case 5: return GL_CLAMP_TO_EDGE;//GL_CLAMP; + //case 6: return GL_MIRROR_CLAMP_TO_EDGE_EXT; } + ConLog.Error("Texture wrap error: bad wrap (%d).", wrap); + return GL_REPEAT; + } + + void Init() + { + Bind(); + if(!Memory.IsGoodAddr(m_offset)) + { + ConLog.Error("Bad texture address=0x%x", m_offset); + return; + } + //ConLog.Warning("texture addr = 0x%x, width = %d, height = %d, max_aniso=%d, mipmap=%d, remap=0x%x, zfunc=0x%x, wraps=0x%x, wrapt=0x%x, wrapr=0x%x, minlod=0x%x, maxlod=0x%x", + // m_offset, m_width, m_height, m_maxaniso, m_mipmap, m_remap, m_zfunc, m_wraps, m_wrapt, m_wrapr, m_minlod, m_maxlod); //TODO: safe init checkForGlError("GLTexture::Init() -> glBindTexture"); - switch(m_format & ~(0x20 | 0x40)) + glPixelStorei(GL_PACK_ROW_LENGTH, m_pitch); + + int format = m_format & ~(0x20 | 0x40); + bool is_swizzled = (m_format & 0x20) == 0; + + char* pixels = (char*)Memory.GetMemFromAddr(m_offset); + + switch(format) { case 0x81: - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RED, GL_UNSIGNED_BYTE, Memory.GetMemFromAddr(m_offset)); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_BLUE, GL_UNSIGNED_BYTE, pixels); checkForGlError("GLTexture::Init() -> glTexImage2D"); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_RED); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_BLUE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_BLUE); + checkForGlError("GLTexture::Init() -> glTexParameteri"); break; case 0x85: - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, Memory.GetMemFromAddr(m_offset)); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, pixels); checkForGlError("GLTexture::Init() -> glTexImage2D"); break; - default: ConLog.Error("Init tex error: Bad tex format (0x%x)", m_format); break; + case 0x86: + { + u32 size = ((m_width + 3) / 4) * ((m_height + 3) / 4) * 8; + + glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, m_width, m_height, 0, size, pixels); + checkForGlError("GLTexture::Init() -> glCompressedTexImage2D"); + } + break; + + case 0x87: + { + u32 size = ((m_width + 3) / 4) * ((m_height + 3) / 4) * 16; + + glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, m_width, m_height, 0, size, pixels); + checkForGlError("GLTexture::Init() -> glCompressedTexImage2D"); + } + break; + + case 0x88: + { + u32 size = ((m_width + 3) / 4) * ((m_height + 3) / 4) * 16; + + glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, m_width, m_height, 0, size, pixels); + checkForGlError("GLTexture::Init() -> glCompressedTexImage2D"); + } + break; + + case 0x94: + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RED, GL_SHORT, pixels); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ONE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_ONE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_ONE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED); + checkForGlError("GLTexture::Init() -> glTexImage2D"); + break; + + case 0x9a: + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_BGRA, GL_HALF_FLOAT, pixels); + checkForGlError("GLTexture::Init() -> glTexImage2D"); + break; + + case 0x9e: + { + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, pixels); + checkForGlError("GLTexture::Init() -> glTexImage2D"); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE); + } + break; + + default: ConLog.Error("Init tex error: Bad tex format (0x%x | 0x%x | 0x%x)", format, m_format & 0x20, m_format & 0x40); break; } - //glBindTexture(GL_TEXTURE_2D, 0); + if(m_mipmap > 1) + { + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); + } + + if(format != 0x81 && format != 0x94) + { + u8 remap_a = m_remap & 0x3; + u8 remap_r = (m_remap >> 2) & 0x3; + u8 remap_g = (m_remap >> 4) & 0x3; + u8 remap_b = (m_remap >> 6) & 0x3; + + static const int gl_remap[] = + { + GL_ALPHA, + GL_RED, + GL_GREEN, + GL_BLUE, + }; + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, gl_remap[remap_a]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, gl_remap[remap_r]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, gl_remap[remap_g]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, gl_remap[remap_b]); + } + + static const int gl_tex_zfunc[] = + { + GL_NEVER, + GL_LESS, + GL_EQUAL, + GL_LEQUAL, + GL_GREATER, + GL_NOTEQUAL, + GL_GEQUAL, + GL_ALWAYS, + }; + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GetGlWrap(m_wraps)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GetGlWrap(m_wrapt)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GetGlWrap(m_wrapr)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, gl_tex_zfunc[m_zfunc]); + + glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, m_aniso_bias); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, m_minlod); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, m_maxlod); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, m_maxaniso); + + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + //Unbind(); } void Save(const wxString& name) { - if(!m_id || !m_offset) return; + if(!m_id || !m_offset || !m_width || !m_height) return; - ConLog.Write("start"); u32* alldata = new u32[m_width * m_height]; - glBindTexture(GL_TEXTURE_2D, m_id); - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, alldata); + Bind(); + switch(m_format & ~(0x20 | 0x40)) + { + case 0x81: + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, alldata); + break; + + case 0x85: + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, alldata); + break; + + default: + delete[] alldata; + return; + } + + { + wxFile f(name + ".raw", wxFile::write); + f.Write(alldata, m_width * m_height * 4); + } u8* data = new u8[m_width * m_height * 3]; u8* alpha = new u8[m_width * m_height]; @@ -133,7 +340,6 @@ public: *dst_a++ = *src++; } - ConLog.Write("end"); wxImage out; out.Create(m_width, m_height, data, alpha); out.SaveFile(name, wxBITMAP_TYPE_PNG); @@ -160,10 +366,46 @@ public: glBindTexture(GL_TEXTURE_2D, m_id); } - void Enable(bool enable) { m_enabled = enable; } + void Unbind() + { + glBindTexture(GL_TEXTURE_2D, 0); + } + + void Delete() + { + if(m_id) + { + glDeleteTextures(1, &m_id); + m_id = 0; + } + } + bool IsEnabled() const { return m_enabled; } }; +struct TransformConstant +{ + u32 id; + float x, y, z, w; + + TransformConstant() + : x(0.0f) + , y(0.0f) + , z(0.0f) + , w(0.0f) + { + } + + TransformConstant(u32 id, float x, float y, float z, float w) + : id(id) + , x(x) + , y(y) + , z(z) + , w(w) + { + } +}; + struct IndexArrayData { Array m_data; @@ -211,8 +453,6 @@ private: virtual void OnSize(wxSizeEvent& event); }; -extern gcmBuffer gcmBuffers[2]; - struct GLRSXThread : public ThreadBase { wxWindow* m_parent; @@ -228,16 +468,26 @@ class GLGSRender , public GSRender , public ExecRSXCMDdata { +public: + static const uint m_vertex_count = 16; + static const uint m_fragment_count = 16; + static const uint m_textures_count = 16; + private: GLRSXThread* m_rsx_thread; IndexArrayData m_indexed_array; - ShaderProgram m_shader_prog; - VertexData m_vertex_data[16]; + ShaderProgram m_shader_progs[m_fragment_count]; + ShaderProgram* m_cur_shader_prog; + int m_cur_shader_prog_num; + VertexData m_vertex_data[m_vertex_count]; Array m_vdata; - VertexProgram m_vertex_progs[16]; + VertexProgram m_vertex_progs[m_vertex_count]; VertexProgram* m_cur_vertex_prog; + Array m_transform_constants; + Array m_fragment_constants; + Program m_program; int m_fp_buf_num; int m_vp_buf_num; @@ -245,8 +495,13 @@ private: int m_draw_mode; ProgramBuffer m_prog_buffer; + u32 m_width; + u32 m_height; + GLvao m_vao; GLvbo m_vbo; + GLrbo m_rbo; + GLfbo m_fbo; public: GLGSFrame* m_frame; @@ -261,6 +516,7 @@ private: void DisableVertexData(); void LoadVertexData(u32 first, u32 count); void InitVertexData(); + void InitFragmentData(); void Enable(bool enable, const u32 cap); virtual void Init(const u32 ioAddress, const u32 ioSize, const u32 ctrlAddress, const u32 localAddress); diff --git a/rpcs3/Emu/GS/GL/GLProcTable.tbl b/rpcs3/Emu/GS/GL/GLProcTable.tbl index 2ebe4199e7..6aeb2c8be4 100644 --- a/rpcs3/Emu/GS/GL/GLProcTable.tbl +++ b/rpcs3/Emu/GS/GL/GLProcTable.tbl @@ -30,6 +30,17 @@ OPENGL_PROC(PFNGLBINDATTRIBLOCATIONPROC, BindAttribLocation); OPENGL_PROC(PFNGLGETUNIFORMLOCATIONPROC, GetUniformLocation); OPENGL_PROC(PFNGLGETPROGRAMIVPROC, GetProgramiv); OPENGL_PROC(PFNGLGETPROGRAMINFOLOGPROC, GetProgramInfoLog); +OPENGL_PROC(PFNGLVERTEXATTRIB4BVPROC, VertexAttrib4bv); +OPENGL_PROC(PFNGLVERTEXATTRIB4UBVPROC, VertexAttrib4ubv); +OPENGL_PROC(PFNGLVERTEXATTRIB1SPROC, VertexAttrib1s); +OPENGL_PROC(PFNGLVERTEXATTRIB2SVPROC, VertexAttrib2sv); +OPENGL_PROC(PFNGLVERTEXATTRIB3SVPROC, VertexAttrib3sv); +OPENGL_PROC(PFNGLVERTEXATTRIB4SVPROC, VertexAttrib4sv); +OPENGL_PROC(PFNGLVERTEXATTRIB4IVPROC, VertexAttrib4iv); +OPENGL_PROC(PFNGLVERTEXATTRIB1FPROC, VertexAttrib1f); +OPENGL_PROC(PFNGLVERTEXATTRIB2FVPROC, VertexAttrib2fv); +OPENGL_PROC(PFNGLVERTEXATTRIB3FVPROC, VertexAttrib3fv); +OPENGL_PROC(PFNGLVERTEXATTRIB4FVPROC, VertexAttrib4fv); OPENGL_PROC(PFNGLVERTEXATTRIBPOINTERPROC, VertexAttribPointer); OPENGL_PROC(PFNGLENABLEVERTEXATTRIBARRAYPROC, EnableVertexAttribArray); OPENGL_PROC(PFNGLDISABLEVERTEXATTRIBARRAYPROC, DisableVertexAttribArray); @@ -39,7 +50,49 @@ OPENGL_PROC(PFNGLDELETEVERTEXARRAYSPROC, DeleteVertexArrays); OPENGL_PROC(PFNGLDEPTHRANGEFPROC, DepthRangef); OPENGL_PROC(PFNGLUNIFORM1IPROC, Uniform1i); OPENGL_PROC(PFNGLUNIFORM1FPROC, Uniform1f); +OPENGL_PROC(PFNGLUNIFORM1UIPROC, Uniform1ui); +OPENGL_PROC(PFNGLUNIFORM1IVPROC, Uniform1iv); +OPENGL_PROC(PFNGLUNIFORM1FVPROC, Uniform1fv); +OPENGL_PROC(PFNGLUNIFORM1UIVPROC, Uniform1uiv); +OPENGL_PROC(PFNGLUNIFORM2IPROC, Uniform2i); +OPENGL_PROC(PFNGLUNIFORM2FPROC, Uniform2f); +OPENGL_PROC(PFNGLUNIFORM2UIPROC, Uniform2ui); +OPENGL_PROC(PFNGLUNIFORM2IVPROC, Uniform2iv); +OPENGL_PROC(PFNGLUNIFORM2FVPROC, Uniform2fv); +OPENGL_PROC(PFNGLUNIFORM2UIVPROC, Uniform2uiv); +OPENGL_PROC(PFNGLUNIFORM3IPROC, Uniform3i); +OPENGL_PROC(PFNGLUNIFORM3FPROC, Uniform3f); +OPENGL_PROC(PFNGLUNIFORM3UIPROC, Uniform3ui); +OPENGL_PROC(PFNGLUNIFORM3IVPROC, Uniform3iv); +OPENGL_PROC(PFNGLUNIFORM3FVPROC, Uniform3fv); +OPENGL_PROC(PFNGLUNIFORM3UIVPROC, Uniform3uiv); +OPENGL_PROC(PFNGLUNIFORM4FPROC, Uniform4i); OPENGL_PROC(PFNGLUNIFORM4FPROC, Uniform4f); +OPENGL_PROC(PFNGLUNIFORM4UIPROC, Uniform4ui); +OPENGL_PROC(PFNGLUNIFORM4IVPROC, Uniform4iv); +OPENGL_PROC(PFNGLUNIFORM4FVPROC, Uniform4fv); +OPENGL_PROC(PFNGLUNIFORM4UIVPROC, Uniform4uiv); +OPENGL_PROC(PFNGLPROGRAMUNIFORM1IPROC, ProgramUniform1i); +OPENGL_PROC(PFNGLPROGRAMUNIFORM1FPROC, ProgramUniform1f); +OPENGL_PROC(PFNGLPROGRAMUNIFORM4FPROC, ProgramUniform4f); OPENGL_PROC(PFNGLUNIFORMMATRIX4FVPROC, UniformMatrix4fv); OPENGL_PROC(PFNGLUSEPROGRAMPROC, UseProgram); -OPENGL_PROC2(PFNWGLSWAPINTERVALEXTPROC, SwapInterval, wglSwapIntervalEXT); \ No newline at end of file +OPENGL_PROC2(PFNWGLSWAPINTERVALEXTPROC, SwapInterval, wglSwapIntervalEXT); +OPENGL_PROC2(PFNGLDEPTHBOUNDSEXTPROC, DepthBounds, glDepthBoundsEXT); +OPENGL_PROC(PFNGLSTENCILOPSEPARATEPROC, StencilOpSeparate); +OPENGL_PROC(PFNGLSTENCILFUNCSEPARATEPROC, StencilFuncSeparate); +OPENGL_PROC(PFNGLSTENCILMASKSEPARATEPROC, StencilMaskSeparate); +OPENGL_PROC(PFNGLCOMPRESSEDTEXIMAGE2DPROC, CompressedTexImage2D); +OPENGL_PROC(PFNGLGENERATEMIPMAPPROC, GenerateMipmap); +OPENGL_PROC(PFNGLBINDRENDERBUFFERPROC, BindRenderbuffer); +OPENGL_PROC(PFNGLDELETERENDERBUFFERSPROC, DeleteRenderbuffers); +OPENGL_PROC(PFNGLGENRENDERBUFFERSPROC, GenRenderbuffers); +OPENGL_PROC(PFNGLRENDERBUFFERSTORAGEPROC, RenderbufferStorage); +OPENGL_PROC(PFNGLBINDFRAMEBUFFERPROC, BindFramebuffer); +OPENGL_PROC(PFNGLDELETEFRAMEBUFFERSPROC, DeleteFramebuffers); +OPENGL_PROC(PFNGLGENFRAMEBUFFERSPROC, GenFramebuffers); +OPENGL_PROC(PFNGLFRAMEBUFFERTEXTURE1DPROC, FramebufferTexture1D); +OPENGL_PROC(PFNGLFRAMEBUFFERTEXTURE2DPROC, FramebufferTexture2D); +OPENGL_PROC(PFNGLFRAMEBUFFERTEXTURE3DPROC, FramebufferTexture3D); +OPENGL_PROC(PFNGLFRAMEBUFFERRENDERBUFFERPROC, FramebufferRenderbuffer); +OPENGL_PROC(PFNGLBLITFRAMEBUFFERPROC, BlitFramebuffer); \ No newline at end of file diff --git a/rpcs3/Emu/GS/GL/Program.cpp b/rpcs3/Emu/GS/GL/Program.cpp index bc90e28628..4730f33805 100644 --- a/rpcs3/Emu/GS/GL/Program.cpp +++ b/rpcs3/Emu/GS/GL/Program.cpp @@ -19,7 +19,9 @@ int Program::GetLocation(const wxString& name) u32 pos = m_locations.Move(new Location()); m_locations[pos].name = name; - return m_locations[pos].loc = glGetUniformLocation(id, name); + m_locations[pos].loc = glGetUniformLocation(id, name); + checkForGlError(wxString::Format("glGetUniformLocation(0x%x, %s)", id, name)); + return m_locations[pos].loc; } bool Program::IsCreated() const @@ -72,6 +74,12 @@ void Program::Create(const u32 vp, const u32 fp) } } +void Program::UnUse() +{ + id = 0; + m_locations.Clear(); +} + void Program::Use() { glUseProgram(id); @@ -80,8 +88,10 @@ void Program::Use() void Program::SetTex(u32 index) { - glUniform1i(GetLocation(wxString::Format("tex_%d", index)), index); - checkForGlError(wxString::Format("SetTex(%d)", index)); + int loc = GetLocation(wxString::Format("tex%u", index)); + checkForGlError(wxString::Format("GetLocation(tex%u)", index)); + glProgramUniform1i(id, loc, index); + checkForGlError(wxString::Format("SetTex(%u - %d - %d)", id, index, loc)); } void Program::Delete() @@ -89,4 +99,5 @@ void Program::Delete() if(!IsCreated()) return; glDeleteProgram(id); id = 0; + m_locations.Clear(); } \ No newline at end of file diff --git a/rpcs3/Emu/GS/GL/Program.h b/rpcs3/Emu/GS/GL/Program.h index 4a376414b6..71fb597ff6 100644 --- a/rpcs3/Emu/GS/GL/Program.h +++ b/rpcs3/Emu/GS/GL/Program.h @@ -22,6 +22,7 @@ public: bool IsCreated() const; void Create(const u32 vp, const u32 fp); void Use(); + void UnUse(); void SetTex(u32 index); void Delete(); }; \ No newline at end of file diff --git a/rpcs3/Emu/GS/GL/ProgramBuffer.cpp b/rpcs3/Emu/GS/GL/ProgramBuffer.cpp index ee6a292e73..859bad2bce 100644 --- a/rpcs3/Emu/GS/GL/ProgramBuffer.cpp +++ b/rpcs3/Emu/GS/GL/ProgramBuffer.cpp @@ -8,7 +8,7 @@ int ProgramBuffer::SearchFp(ShaderProgram& fp) if(memcmp(&m_buf[i].fp_data[0], &Memory[fp.addr], m_buf[i].fp_data.GetCount()) != 0) continue; fp.id = m_buf[i].fp_id; - fp.shader = m_buf[i].fp_shader; + fp.shader = m_buf[i].fp_shader.GetPtr(); return i; } @@ -21,10 +21,10 @@ int ProgramBuffer::SearchVp(VertexProgram& vp) for(u32 i=0; i fp_data; Array vp_data; - wxString fp_shader; - wxString vp_shader; + ArrayString fp_shader; + ArrayString vp_shader; }; struct ProgramBuffer diff --git a/rpcs3/Emu/GS/GL/ShaderParam.h b/rpcs3/Emu/GS/GL/ShaderParam.h index f90ba43acc..c0f91e38fb 100644 --- a/rpcs3/Emu/GS/GL/ShaderParam.h +++ b/rpcs3/Emu/GS/GL/ShaderParam.h @@ -5,18 +5,21 @@ enum ParamFlag { PARAM_IN, PARAM_OUT, + PARAM_UNIFORM, PARAM_CONST, PARAM_NONE, }; struct ParamItem { - wxString name; - wxString location; + ArrayString name; + ArrayString location; + ArrayString value; - ParamItem(const wxString& _name, int _location) + ParamItem(const wxString& _name, int _location, const wxString& _value = wxEmptyString) : name(_name) , location(_location > -1 ? wxString::Format("layout (location = %d) ", _location) : "") + , value(_value) { } }; @@ -24,7 +27,7 @@ struct ParamItem struct ParamType { const ParamFlag flag; - wxString type; + ArrayString type; Array items; ParamType(const ParamFlag _flag, const wxString& _type) @@ -37,7 +40,7 @@ struct ParamType { for(u32 i=0; iSearchName(name); + } + + wxString AddParam(const ParamFlag flag, wxString type, const wxString& name, const wxString& value) + { + type = GetParamFlag(flag) + type; + ParamType* t = SearchParam(type); + + if(t) + { + if(!t->SearchName(name)) t->items.Move(new ParamItem(name, -1, value)); + } + else + { + const u32 num = params.GetCount(); + params.Move(new ParamType(flag, type)); + params[num].items.Move(new ParamItem(name, -1, value)); + } + + return name; + } + wxString AddParam(const ParamFlag flag, wxString type, const wxString& name, int location = -1) { type = GetParamFlag(flag) + type; diff --git a/rpcs3/Emu/GS/GL/VertexProgram.cpp b/rpcs3/Emu/GS/GL/VertexProgram.cpp index 9938ad184f..83cad2e739 100644 --- a/rpcs3/Emu/GS/GL/VertexProgram.cpp +++ b/rpcs3/Emu/GS/GL/VertexProgram.cpp @@ -1,28 +1,36 @@ #include "stdafx.h" #include "VertexProgram.h" -wxString VertexDecompilerThread::GetVecMask() +wxString VertexDecompilerThread::GetMask(bool is_sca) { wxString ret = wxEmptyString; - if(d3.vec_writemask_x) ret += "x"; - if(d3.vec_writemask_y) ret += "y"; - if(d3.vec_writemask_z) ret += "z"; - if(d3.vec_writemask_w) ret += "w"; + if(is_sca) + { + if(d3.sca_writemask_x) ret += "x"; + if(d3.sca_writemask_y) ret += "y"; + if(d3.sca_writemask_z) ret += "z"; + if(d3.sca_writemask_w) ret += "w"; + } + else + { + if(d3.vec_writemask_x) ret += "x"; + if(d3.vec_writemask_y) ret += "y"; + if(d3.vec_writemask_z) ret += "z"; + if(d3.vec_writemask_w) ret += "w"; + } return ret.IsEmpty() || ret == "xyzw" ? wxEmptyString : ("." + ret); } +wxString VertexDecompilerThread::GetVecMask() +{ + return GetMask(false); +} + wxString VertexDecompilerThread::GetScaMask() { - wxString ret = wxEmptyString; - - if(d3.sca_writemask_x) ret += "x"; - if(d3.sca_writemask_y) ret += "y"; - if(d3.sca_writemask_z) ret += "z"; - if(d3.sca_writemask_w) ret += "w"; - - return ret.IsEmpty() || ret == "xyzw" ? wxEmptyString : ("." + ret); + return GetMask(true); } wxString VertexDecompilerThread::GetDST(bool isSca) @@ -32,32 +40,31 @@ wxString VertexDecompilerThread::GetDST(bool isSca) "gl_Position", "col0", "col1", "bfc0", "bfc1", - "fogc", - "gl_Pointsize", + "gl_ClipDistance[%d]", + "gl_ClipDistance[%d]", "tc0", "tc1", "tc2", "tc3", "tc4", "tc5", "tc6", "tc7" }; wxString ret = wxEmptyString; - u32 dst = isSca ? d3.sca_dst : d3.dst; - switch(dst) + switch(isSca ? 0x1f : d3.dst) { - case 0x0: case 0x6: - ret += reg_table[dst]; + case 0x0: case 0x5: case 0x6: + ret += reg_table[d3.dst]; break; case 0x1f: - ret += m_parr.AddParam(PARAM_NONE, "vec4", wxString::Format("tmp%d", d0.dst_tmp)); + ret += m_parr.AddParam(PARAM_NONE, "vec4", wxString::Format("tmp%u", isSca ? d3.sca_dst_tmp : d0.dst_tmp)); break; default: - if(dst < WXSIZEOF(reg_table)) + if(d3.dst < WXSIZEOF(reg_table)) { - ret += m_parr.AddParam(PARAM_OUT, "vec4", reg_table[dst]); + ret += m_parr.AddParam(PARAM_OUT, "vec4", reg_table[d3.dst]); } else { - ConLog.Error("Bad dst reg num: %d", dst); + ConLog.Error("Bad dst reg num: %d", d3.dst); ret += m_parr.AddParam(PARAM_OUT, "vec4", "unk"); } break; @@ -83,7 +90,7 @@ wxString VertexDecompilerThread::GetSRC(const u32 n, bool isSca) switch(src[n].reg_type) { case 1: //temp - ret += m_parr.AddParam(PARAM_NONE, "vec4", wxString::Format("tmp%d", src[n].tmp_src)); + ret += m_parr.AddParam(PARAM_NONE, "vec4", wxString::Format("tmp%u", src[n].tmp_src)); break; case 2: //input if(d1.input_src < WXSIZEOF(reg_table)) @@ -97,19 +104,16 @@ wxString VertexDecompilerThread::GetSRC(const u32 n, bool isSca) } break; case 3: //const - ret += m_parr.AddParam(PARAM_CONST, "vec4", wxString::Format("vc%d", d1.const_src)); + ret += m_parr.AddParam(PARAM_UNIFORM, "vec4", wxString::Format("vc%u", d1.const_src)); break; default: - ConLog.Error("Bad src%d reg type: %d", n, src[n].reg_type); + ConLog.Error("Bad src%u reg type: %d", n, src[n].reg_type); Emu.Pause(); break; } - static const char f[4] = {'x', 'z', 'w', 'y'}; - static const char fSca[4] = {'x', 'z', 'y', 'w'}; - - wxString swizzle = wxEmptyString; + static const wxString f = "xyzw"; if (isSca) { @@ -117,16 +121,19 @@ wxString VertexDecompilerThread::GetSRC(const u32 n, bool isSca) assert(src[n].swz_z == src[n].swz_w); assert(src[n].swz_x == src[n].swz_z); - ret += "." + fSca[src[n].swz_x]; + ret += '.'; + ret += f[src[n].swz_x]; } else { + wxString swizzle = wxEmptyString; + swizzle += f[src[n].swz_x]; swizzle += f[src[n].swz_y]; swizzle += f[src[n].swz_z]; swizzle += f[src[n].swz_w]; - if(swizzle != "xyzw") ret += "." + swizzle; + if(swizzle != f) ret += '.' + swizzle; } bool abs; @@ -144,34 +151,78 @@ wxString VertexDecompilerThread::GetSRC(const u32 n, bool isSca) return ret; } -void VertexDecompilerThread::AddVecCode(wxString code, bool src_mask) +void VertexDecompilerThread::AddCode(bool is_sca, wxString code, bool src_mask) { if(d0.cond == 0) return; - if(d0.cond != 7) + enum { - ConLog.Error("Bad cond! %d", d0.cond); - Emu.Pause(); - return; + lt = 0x1, + eq = 0x2, + gt = 0x4, + }; + + wxString cond; + + if(d0.cond != (lt | gt | eq)) + { + if((d0.cond & (lt | gt)) == (lt | gt)) + { + cond = "!="; + } + else + { + if(d0.cond & lt) cond = "<"; + else if(d0.cond & gt) cond = ">"; + else if(d0.cond & eq) cond = "="; + + if(d0.cond & eq) cond += "="; + } + + //ConLog.Error("cond! %d (%d %s %d %d)", d0.cond, d0.dst_tmp, cond, d1.input_src, d1.const_src); + cond = wxString::Format("if(tmp%d.x %s 0) ", d0.dst_tmp, cond); } - code = GetDST() + GetVecMask() + " = " + (src_mask ? code + GetVecMask() : code); + wxString value = src_mask ? code + GetMask(is_sca) : code; + + if(d0.staturate) + { + value = "clamp(" + value + ", 0.0, 1.0)"; + } + + wxString dest; + if(d3.dst == 5 || d3.dst == 6) + { + int num = d3.dst == 5 ? 0 : 3; + + if(d3.vec_writemask_x) + { + ConLog.Error("Bad clip mask."); + } + + //if(d3.vec_writemask_y) num += 0; + if(d3.vec_writemask_z) num += 1; + else if(d3.vec_writemask_w) num += 2; + + dest = wxString::Format(GetDST(is_sca), num); + } + else + { + dest = GetDST(is_sca) + GetMask(is_sca); + } + + code = cond + dest + " = " + value; main += "\t" + code + ";\n"; } -void VertexDecompilerThread::AddScaCode(wxString code, bool src_mask) +void VertexDecompilerThread::AddVecCode(const wxString& code, bool src_mask) { - if(d0.cond == 0) return; - if(d0.cond != 7) - { - ConLog.Error("Bad cond! %d", d0.cond); - Emu.Pause(); - return; - } + AddCode(false, code, src_mask); +} - code = GetDST(true) + GetScaMask() + " = " + (src_mask ? code + GetScaMask() : code); - - main += "\t" + code + ";\n"; +void VertexDecompilerThread::AddScaCode(const wxString& code) +{ + AddCode(true, code, false); } wxString VertexDecompilerThread::BuildCode() @@ -187,7 +238,7 @@ wxString VertexDecompilerThread::BuildCode() "#version 330\n" "\n" "%s\n" - "void main()\n{\n%s}\n"; + "void main()\n{\n\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n%s}\n"; return wxString::Format(prot, p, main); } @@ -201,16 +252,18 @@ void VertexDecompilerThread::Task() d2.HEX = m_data[i++]; d3.HEX = m_data[i++]; - src[0].HEX = d2.src0l | (d1.src0h << 9); - src[1].HEX = d2.src1; - src[2].HEX = d3.src2l | (d2.src2h << 11); + src[0].src0l = d2.src0l; + src[0].src0h = d1.src0h; + src[1].src1 = d2.src1; + src[2].src2l = d3.src2l; + src[2].src2h = d2.src2h; switch(d1.sca_opcode) { case 0x00: break; // NOP case 0x01: AddScaCode(GetSRC(2, true)); break; // MOV case 0x02: AddScaCode("1 / (" + GetSRC(2, true) + ")"); break; // RCP - case 0x03: AddScaCode("clamp(1 / (" + GetSRC(2, true) + "), 5.42101e-20, 1.884467e19"); break; // RCC + case 0x03: AddScaCode("clamp(1 / (" + GetSRC(2, true) + "), 5.42101e-20, 1.884467e19)"); break; // RCC case 0x04: AddScaCode("inversesqrt(" + GetSRC(2, true) + ")"); break; // RSQ case 0x05: AddScaCode("exp(" + GetSRC(2, true) + ")"); break; // EXP case 0x06: AddScaCode("log(" + GetSRC(2, true) + ")"); break; // LOG @@ -229,7 +282,6 @@ void VertexDecompilerThread::Task() //case 0x13: break; // PSH : works differently (PSH o[1].x A0;) //case 0x14: break; // POP : works differently (POP o[1].x;) - default: ConLog.Error("Unknown vp sca_opcode 0x%x", d1.sca_opcode); Emu.Pause(); @@ -241,26 +293,25 @@ void VertexDecompilerThread::Task() case 0x00: break; //NOP case 0x01: AddVecCode(GetSRC(0)); break; //MOV case 0x02: AddVecCode("(" + GetSRC(0) + " * " + GetSRC(1) + ")"); break; //MUL - case 0x03: AddVecCode("(" + GetSRC(0) + " + " + GetSRC(1) + ")"); break; //ADD + case 0x03: AddVecCode("(" + GetSRC(0) + " + " + GetSRC(2) + ")"); break; //ADD case 0x04: AddVecCode("(" + GetSRC(0) + " * " + GetSRC(1) + " + " + GetSRC(2) + ")"); break; //MAD - case 0x05: AddVecCode("dot(" + GetSRC(0) + ".xyz, " + GetSRC(1) + ".xyz)", false); break; //DP3 - case 0x06: AddVecCode("(dot(" + GetSRC(0) + ".xyz, " + GetSRC(1) + ".xyz) + " + GetSRC(1) + ".w)", false); break; //DPH - case 0x07: AddVecCode("dot(" + GetSRC(0) + ", " + GetSRC(1) + ")", false); break; //DP4 - case 0x08: AddVecCode("distance(" + GetSRC(0) + ", " + GetSRC(1) + ")"); break; //DST + case 0x05: AddVecCode("vec4(dot(" + GetSRC(0) + ".xyz, " + GetSRC(1) + ".xyz)).xxxx"); break; //DP3 + case 0x06: AddVecCode("vec4(dot(vec4(" + GetSRC(0) + ".xyz, 1), " + GetSRC(1) + ")).xxxx"); break; //DPH + case 0x07: AddVecCode("vec4(dot(" + GetSRC(0) + ", " + GetSRC(1) + ")).xxxx"); break; //DP4 + case 0x08: AddVecCode("vec4(distance(" + GetSRC(0) + ", " + GetSRC(1) + ")).xxxx"); break; //DST case 0x09: AddVecCode("min(" + GetSRC(0) + ", " + GetSRC(1) + ")"); break; //MIN case 0x0a: AddVecCode("max(" + GetSRC(0) + ", " + GetSRC(1) + ")"); break; //MAX - case 0x0b: AddVecCode("lessThan(" + GetSRC(0) + ", " + GetSRC(1) + ")"); break; //SLT - case 0x0c: AddVecCode("greaterThanEqual(" + GetSRC(0) + ", " + GetSRC(1) + ")"); break; //SGE + case 0x0b: AddVecCode("vec4(lessThan(" + GetSRC(0) + ", " + GetSRC(1) + "))"); break; //SLT + case 0x0c: AddVecCode("vec4(greaterThanEqual(" + GetSRC(0) + ", " + GetSRC(1) + "))"); break; //SGE case 0x0e: AddVecCode("fract(" + GetSRC(0) + ")"); break; //FRC case 0x0f: AddVecCode("floor(" + GetSRC(0) + ")"); break; //FLR - case 0x10: AddVecCode("equal(" + GetSRC(0) + ", " + GetSRC(1) + ")"); break; //SEQ - case 0x11: AddVecCode("vec4(0.0f, 0.0f, 0.0f, 0.0f)"); break; //SFL - case 0x12: AddVecCode("greaterThan(" + GetSRC(0) + ", " + GetSRC(1) + ")"); break; //SGT - case 0x13: AddVecCode("lessThanEqual(" + GetSRC(0) + ", " + GetSRC(1) + ")"); break; //SLE - case 0x14: AddVecCode("notEqual(" + GetSRC(0) + ", " + GetSRC(1) + ")"); break; //SNE - case 0x15: AddVecCode("vec4(1.0f, 1.0f, 1.0f, 1.0f)"); break; //STR - case 0x16: AddVecCode("sign(" + GetSRC(0) + ", " + GetSRC(1) + ")"); break; //SSG - + case 0x10: AddVecCode("vec4(equal(" + GetSRC(0) + ", " + GetSRC(1) + "))"); break; //SEQ + //case 0x11: AddVecCode("vec4(0.0f, 0.0f, 0.0f, 0.0f)"); break; //SFL + case 0x12: AddVecCode("vec4(greaterThan(" + GetSRC(0) + ", " + GetSRC(1) + "))"); break; //SGT + case 0x13: AddVecCode("vec4(lessThanEqual(" + GetSRC(0) + ", " + GetSRC(1) + "))"); break; //SLE + case 0x14: AddVecCode("vec4(notEqual(" + GetSRC(0) + ", " + GetSRC(1) + "))"); break; //SNE + //case 0x15: AddVecCode("vec4(1.0f, 1.0f, 1.0f, 1.0f)"); break; //STR + case 0x16: AddVecCode("sign(" + GetSRC(0) + ")"); break; //SSG default: ConLog.Error("Unknown vp opcode 0x%x", d1.vec_opcode); @@ -272,11 +323,12 @@ void VertexDecompilerThread::Task() } m_shader = BuildCode(); + main = wxEmptyString; } VertexProgram::VertexProgram() - : m_decompiler_thread(NULL) + : m_decompiler_thread(nullptr) , id(0) { } @@ -358,13 +410,7 @@ void VertexProgram::Compile() void VertexProgram::Delete() { data.Clear(); - for(u32 i=0; i constants4; - Array data; ParamArray parr; @@ -165,20 +178,19 @@ struct VertexProgram struct VertexData { - u32 index; u32 frequency; u32 stride; u32 size; u32 type; u32 addr; + u32 constant_count; Array data; - VertexData() { memset(this, 0, sizeof(*this)); } - ~VertexData() { data.Clear(); } + VertexData(); + void Reset(); bool IsEnabled() { return size > 0; } - void Load(u32 start, u32 count); u32 GetTypeSize(); diff --git a/rpcs3/Emu/GS/GSManager.cpp b/rpcs3/Emu/GS/GSManager.cpp index 7f9b2f1e07..456aa9125e 100644 --- a/rpcs3/Emu/GS/GSManager.cpp +++ b/rpcs3/Emu/GS/GSManager.cpp @@ -8,7 +8,7 @@ BEGIN_EVENT_TABLE(GSFrame, wxFrame) EVT_SIZE(GSFrame::OnSize) END_EVENT_TABLE() -GSManager::GSManager() : m_render(NULL) +GSManager::GSManager() : m_render(nullptr) { } diff --git a/rpcs3/Emu/GS/GSManager.h b/rpcs3/Emu/GS/GSManager.h index bac7ce4233..7ab4fda396 100644 --- a/rpcs3/Emu/GS/GSManager.h +++ b/rpcs3/Emu/GS/GSManager.h @@ -38,15 +38,8 @@ struct gcmBuffer u32 pitch; u32 width; u32 height; - bool update; - - gcmBuffer() : update(false) - { - } }; -extern gcmBuffer gcmBuffers[2]; - class GSManager { GSInfo m_info; diff --git a/rpcs3/Emu/GS/GSRender.cpp b/rpcs3/Emu/GS/GSRender.cpp index 3055b66733..225ae860de 100644 --- a/rpcs3/Emu/GS/GSRender.cpp +++ b/rpcs3/Emu/GS/GSRender.cpp @@ -78,9 +78,10 @@ void GSFrame::SetSize(int width, int height) GSRender::GSRender() - : m_ctrl(NULL) + : m_ctrl(nullptr) , m_flip_status(0) , m_flip_mode(CELL_GCM_DISPLAY_VSYNC) + , m_main_mem_addr(0) { } @@ -88,9 +89,11 @@ u32 GSRender::GetAddress(u32 offset, u8 location) { switch(location) { - case CELL_GCM_LOCATION_LOCAL: return Memory.RSXFBMem.GetStartAddr() + offset; - case CELL_GCM_LOCATION_MAIN: return offset; + case CELL_GCM_LOCATION_LOCAL: return m_local_mem_addr + offset; + case CELL_GCM_LOCATION_MAIN: return m_main_mem_addr + offset; } + + ConLog.Error("GetAddress(offset=0x%x, location=0x%x", location); return 0; } diff --git a/rpcs3/Emu/GS/GSRender.h b/rpcs3/Emu/GS/GSRender.h index 86c05ece7b..8c79740f2e 100644 --- a/rpcs3/Emu/GS/GSRender.h +++ b/rpcs3/Emu/GS/GSRender.h @@ -1,5 +1,7 @@ #pragma once #include "Emu/GS/GCM.h" +#include "Emu/SysCalls/Callback.h" +#include "rpcs3.h" enum Method { @@ -38,9 +40,109 @@ private: DECLARE_EVENT_TABLE(); }; +struct CellGcmSurface +{ + u8 type; + u8 antialias; + + u8 color_format; + u8 color_target; + u8 color_location[4]; + u32 color_offset[4]; + u32 color_pitch[4]; + + u8 depth_format; + u8 depth_location; + u16 pad; + u32 depth_offset; + u32 depth_pitch; + + u16 width; + u16 height; + u16 x; + u16 y; +}; + +struct CellGcmReportData +{ + u64 timer; + u32 value; + u32 pad; +}; + +struct CellGcmZcullInfo +{ + u32 region; + u32 size; + u32 start; + u32 offset; + u32 status0; + u32 status1; +}; + +struct CellGcmTileInfo +{ + u32 tile; + u32 limit; + u32 pitch; + u32 format; +}; + +struct GcmZcullInfo +{ + u32 m_offset; + u32 m_width; + u32 m_height; + u32 m_cullStart; + u32 m_zFormat; + u32 m_aaFormat; + u32 m_zCullDir; + u32 m_zCullFormat; + u32 m_sFunc; + u32 m_sRef; + u32 m_sMask; + bool m_binded; + + GcmZcullInfo() + { + memset(this, 0, sizeof(*this)); + } +}; + +struct GcmTileInfo +{ + u8 m_location; + u32 m_offset; + u32 m_size; + u32 m_pitch; + u8 m_comp; + u16 m_base; + u8 m_bank; + bool m_binded; + + GcmTileInfo() + { + memset(this, 0, sizeof(*this)); + } + + CellGcmTileInfo Pack() + { + CellGcmTileInfo ret; + + re(ret.tile, (m_location + 1) | (m_bank << 4) | ((m_offset / 0x10000) << 16) | (m_location << 31)); + re(ret.limit, ((m_offset + m_size - 1) / 0x10000) << 16 | (m_location << 31)); + re(ret.pitch, (m_pitch / 0x100) << 8); + re(ret.format, m_base | ((m_base + ((m_size - 1) / 0x10000)) << 13) | (m_comp << 26) | (1 << 30)); + + return ret; + } +}; + +static const int g_tiles_count = 15; + struct GSRender { - u32 m_ioAddress, m_ioSize, m_ctrlAddress, m_localAddress; + u32 m_ioAddress, m_ioSize, m_ctrlAddress; CellGcmControl* m_ctrl; wxCriticalSection m_cs_main; wxSemaphore m_sem_flush; @@ -48,6 +150,20 @@ struct GSRender int m_flip_status; int m_flip_mode; volatile bool m_draw; + Callback m_flip_handler; + + GcmTileInfo m_tiles[g_tiles_count]; + + u32 m_tiles_addr; + u32 m_zculls_addr; + u32 m_gcm_buffers_addr; + u32 m_gcm_buffers_count; + u32 m_gcm_current_buffer; + u32 m_ctxt_addr; + u32 m_report_main_addr; + + u32 m_local_mem_addr, m_main_mem_addr; + Array m_main_mem_info; GSRender(); diff --git a/rpcs3/Emu/GS/Null/NullGSRender.h b/rpcs3/Emu/GS/Null/NullGSRender.h index d9c9443b1a..116e78cbbd 100644 --- a/rpcs3/Emu/GS/Null/NullGSRender.h +++ b/rpcs3/Emu/GS/Null/NullGSRender.h @@ -71,7 +71,7 @@ private: m_ioAddress = ioAddress; m_ctrlAddress = ctrlAddress; m_ioSize = ioSize; - m_localAddress = localAddress; + m_local_mem_addr = localAddress; m_ctrl = (CellGcmControl*)Memory.GetMemFromAddr(m_ctrlAddress); (m_rsx_thread = new NullRSXThread(this))->Start(); diff --git a/rpcs3/Emu/GS/RSXThread.h b/rpcs3/Emu/GS/RSXThread.h index 9cf1e9c458..28a61a0898 100644 --- a/rpcs3/Emu/GS/RSXThread.h +++ b/rpcs3/Emu/GS/RSXThread.h @@ -3,7 +3,7 @@ class ExecRSXCMDdata { -protected: +public: bool m_set_color_mask; bool m_color_mask_r; bool m_color_mask_g; @@ -21,6 +21,12 @@ protected: bool m_set_blend; bool m_set_depth_bounds_test; bool m_depth_test_enable; + bool m_set_logic_op; + bool m_set_cull_face; + bool m_set_dither; + bool m_set_stencil_test; + bool m_set_line_smooth; + bool m_set_poly_smooth; bool m_set_viewport_horizontal; bool m_set_viewport_vertical; @@ -36,6 +42,162 @@ protected: u16 m_scissor_w; u16 m_scissor_h; + bool m_set_front_polygon_mode; + u32 m_front_polygon_mode; + + bool m_set_clear_surface; + u32 m_clear_surface_mask; + + bool m_set_blend_sfactor; + u16 m_blend_sfactor_rgb; + u16 m_blend_sfactor_alpha; + + bool m_set_blend_dfactor; + u16 m_blend_dfactor_rgb; + u16 m_blend_dfactor_alpha; + + bool m_set_stencil_mask; + u32 m_stencil_mask; + + bool m_set_stencil_func; + u32 m_stencil_func; + + bool m_set_stencil_func_ref; + u32 m_stencil_func_ref; + + bool m_set_stencil_func_mask; + u32 m_stencil_func_mask; + + bool m_set_stencil_fail; + u32 m_stencil_fail; + + bool m_set_stencil_zfail; + u32 m_stencil_zfail; + + bool m_set_stencil_zpass; + u32 m_stencil_zpass; + + bool m_set_two_sided_stencil_test_enable; + + bool m_set_back_stencil_mask; + u32 m_back_stencil_mask; + + bool m_set_back_stencil_func; + u32 m_back_stencil_func; + + bool m_set_back_stencil_func_ref; + u32 m_back_stencil_func_ref; + + bool m_set_back_stencil_func_mask; + u32 m_back_stencil_func_mask; + + bool m_set_back_stencil_fail; + u32 m_back_stencil_fail; + + bool m_set_back_stencil_zfail; + u32 m_back_stencil_zfail; + + bool m_set_back_stencil_zpass; + u32 m_back_stencil_zpass; + + bool m_set_blend_equation; + u16 m_blend_equation_rgb; + u16 m_blend_equation_alpha; + + bool m_set_depth_mask; + u32 m_depth_mask; + + bool m_set_line_width; + u32 m_line_width; + + bool m_set_shade_mode; + u32 m_shade_mode; + + bool m_set_blend_color; + u8 m_blend_color_r; + u8 m_blend_color_g; + u8 m_blend_color_b; + u8 m_blend_color_a; + + bool m_set_clear_color; + u8 m_clear_color_r; + u8 m_clear_color_g; + u8 m_clear_color_b; + u8 m_clear_color_a; + + u32 m_context_dma_img_src; + u32 m_context_dma_img_dst; + u32 m_dst_offset; + u32 m_color_format; + u16 m_color_format_src_pitch; + u16 m_color_format_dst_pitch; + + u32 m_color_conv; + u32 m_color_conv_fmt; + u32 m_color_conv_op; + u16 m_color_conv_in_x; + u16 m_color_conv_in_y; + u16 m_color_conv_in_w; + u16 m_color_conv_in_h; + u16 m_color_conv_out_x; + u16 m_color_conv_out_y; + u16 m_color_conv_out_w; + u16 m_color_conv_out_h; + u32 m_color_conv_dsdx; + u32 m_color_conv_dtdy; + + bool m_set_semaphore_offset; + u32 m_semaphore_offset; + + bool m_set_fog_mode; + u32 m_fog_mode; + + bool m_set_fog_params; + float m_fog_param0; + float m_fog_param1; + + bool m_set_clip_plane; + u32 m_clip_plane_0; + u32 m_clip_plane_1; + u32 m_clip_plane_2; + u32 m_clip_plane_3; + u32 m_clip_plane_4; + u32 m_clip_plane_5; + + bool m_set_surface_format; + u8 m_surface_color_format; + u8 m_surface_depth_format; + u8 m_surface_type; + u8 m_surface_antialias; + u8 m_surface_width; + u8 m_surface_height; + u32 m_surface_pitch_a; + u32 m_surface_offset_a; + u32 m_surface_offset_z; + u32 m_surface_offset_b; + u32 m_surface_pitch_b; + + bool m_set_context_dma_color_a; + u32 m_context_dma_color_a; + + bool m_set_context_dma_color_b; + u32 m_context_dma_color_b; + + bool m_set_context_dma_color_c; + u32 m_context_dma_color_c; + + bool m_set_context_dma_z; + u32 m_context_dma_z; + + bool m_set_surface_clip_horizontal; + u16 m_surface_clip_x; + u16 m_surface_clip_w; + bool m_set_surface_clip_vertical; + u16 m_surface_clip_y; + u16 m_surface_clip_h; + + u8 m_begin_end; + public: ExecRSXCMDdata() { @@ -55,6 +217,49 @@ public: m_set_viewport_vertical = false; m_set_scissor_horizontal = false; m_set_scissor_vertical = false; + m_set_front_polygon_mode = false; + m_set_clear_surface = false; + m_set_blend_sfactor = false; + m_set_blend_dfactor = false; + m_set_logic_op = false; + m_set_cull_face = false; + m_set_dither = false; + m_set_stencil_test = false; + m_set_stencil_mask = false; + m_set_stencil_func = false; + m_set_stencil_func_ref = false; + m_set_stencil_func_mask = false; + m_set_stencil_fail = false; + m_set_stencil_zfail = false; + m_set_stencil_zpass = false; + m_set_two_sided_stencil_test_enable = false; + m_set_back_stencil_mask = false; + m_set_back_stencil_func = false; + m_set_back_stencil_func_ref = false; + m_set_back_stencil_func_mask = false; + m_set_back_stencil_fail = false; + m_set_back_stencil_zfail = false; + m_set_back_stencil_zpass = false; + m_set_blend_equation = false; + m_set_depth_mask = false; + m_set_line_smooth = false; + m_set_poly_smooth = false; + m_set_line_width = false; + m_set_shade_mode = false; + m_set_blend_color = false; + m_set_clear_color = false; + m_set_semaphore_offset = false; + m_set_fog_mode = false; + m_set_fog_params = false; + m_set_clip_plane = false; + m_set_surface_format = false; + m_set_context_dma_color_a = false; + m_set_context_dma_color_b = false; + m_set_context_dma_color_c = false; + m_set_context_dma_z = false; + m_set_surface_clip_horizontal = false; + m_set_surface_clip_vertical = false; + m_begin_end = 0; } virtual void ExecCMD()=0; diff --git a/rpcs3/Emu/HDD/HDD.cpp b/rpcs3/Emu/HDD/HDD.cpp new file mode 100644 index 0000000000..00f20832bd --- /dev/null +++ b/rpcs3/Emu/HDD/HDD.cpp @@ -0,0 +1,3 @@ +#include "stdafx.h" +#include "HDD.h" + diff --git a/rpcs3/Emu/HDD/HDD.h b/rpcs3/Emu/HDD/HDD.h new file mode 100644 index 0000000000..58438a6a4e --- /dev/null +++ b/rpcs3/Emu/HDD/HDD.h @@ -0,0 +1,864 @@ +#pragma once +#include "Emu/FS/vfsDevice.h" + +static const u64 g_hdd_magic = *(u64*)"PS3eHDD\0"; +static const u16 g_hdd_version = 0x0001; + +struct vfsHDD_Block +{ + struct + { + u64 is_used : 1; + u64 next_block : 63; + }; +} static const g_null_block = {0}, g_used_block = {1}; + +struct vfsHDD_Hdr : public vfsHDD_Block +{ + u64 magic; + u16 version; + u64 block_count; + u32 block_size; +}; + +enum vfsHDD_EntryType : u8 +{ + vfsHDD_Entry_Dir = 0, + vfsHDD_Entry_File = 1, + vfsHDD_Entry_Link = 2, +}; + +struct vfsHDD_Entry : public vfsHDD_Block +{ + u64 data_block; + vfsOpenMode access; + vfsHDD_EntryType type; + u64 size; + u64 ctime; + u64 mtime; + u64 atime; +}; + +class vfsHDDManager +{ +public: + static void CreateBlock(vfsHDD_Block& block) + { + block.is_used = true; + block.next_block = 0; + } + + static void CreateEntry(vfsHDD_Entry& entry) + { + memset(&entry, 0, sizeof(vfsHDD_Entry)); + u64 ctime = time(nullptr); + entry.atime = ctime; + entry.ctime = ctime; + entry.mtime = ctime; + entry.access = vfsReadWrite; + CreateBlock(entry); + } + + static void CreateHDD(const wxString& path, u64 size, u64 block_size) + { + wxFile f(path, wxFile::write); + + static const u64 cur_dir_block = 1; + + vfsHDD_Hdr hdr; + CreateBlock(hdr); + hdr.next_block = cur_dir_block; + hdr.magic = g_hdd_magic; + hdr.version = g_hdd_version; + hdr.block_count = (size + block_size) / block_size; + hdr.block_size = block_size; + f.Write(&hdr, sizeof(vfsHDD_Hdr)); + + { + vfsHDD_Entry entry; + CreateEntry(entry); + entry.type = vfsHDD_Entry_Dir; + entry.data_block = hdr.next_block; + entry.next_block = 0; + + f.Seek(cur_dir_block * hdr.block_size); + f.Write(&entry, sizeof(vfsHDD_Entry)); + f.Write("."); + } + + u8 null = 0; + f.Seek(hdr.block_count * hdr.block_size - sizeof(null)); + f.Write(&null, sizeof(null)); + } + + void Format() + { + } + + void AppendEntry(vfsHDD_Entry entry) + { + } +}; + + +class vfsHDDFile +{ + u64 m_info_block; + vfsHDD_Entry m_info; + const vfsHDD_Hdr& m_hdd_info; + vfsLocalFile& m_hdd; + u32 m_position; + u64 m_cur_block; + + bool goto_block(u64 n) + { + vfsHDD_Block block_info; + + if(m_info.data_block >= m_hdd_info.block_count) + { + return false; + } + + m_hdd.Seek(m_info.data_block * m_hdd_info.block_size); + block_info.next_block = m_info.data_block; + + for(u64 i=0; i= m_hdd_info.block_count) + { + return false; + } + + m_hdd.Seek(block_info.next_block * m_hdd_info.block_size); + m_hdd.Read(&block_info, sizeof(vfsHDD_Block)); + } + + return true; + } + + void RemoveBlocks(u64 start_block) + { + vfsHDD_Block block_info; + block_info.next_block = start_block; + + while(block_info.next_block && block_info.is_used) + { + u64 offset = block_info.next_block * m_hdd_info.block_size; + + ReadBlock(offset, block_info); + WriteBlock(offset, g_null_block); + } + } + + void WriteBlock(u64 block, const vfsHDD_Block& data) + { + m_hdd.Seek(block * m_hdd_info.block_size); + m_hdd.Write(&data, sizeof(vfsHDD_Block)); + } + + void ReadBlock(u64 block, vfsHDD_Block& data) + { + m_hdd.Seek(block * m_hdd_info.block_size); + m_hdd.Read(&data, sizeof(vfsHDD_Block)); + } + + void WriteEntry(u64 block, const vfsHDD_Entry& data) + { + m_hdd.Seek(block * m_hdd_info.block_size); + m_hdd.Write(&data, sizeof(vfsHDD_Entry)); + } + + void ReadEntry(u64 block, vfsHDD_Entry& data) + { + m_hdd.Seek(block * m_hdd_info.block_size); + m_hdd.Read(&data, sizeof(vfsHDD_Entry)); + } + + void ReadEntry(u64 block, vfsHDD_Entry& data, wxString& name) + { + m_hdd.Seek(block * m_hdd_info.block_size); + m_hdd.Read(&data, sizeof(vfsHDD_Entry)); + m_hdd.Read(wxStringBuffer(name, GetMaxNameLen()), GetMaxNameLen()); + } + + void ReadEntry(u64 block, wxString& name) + { + m_hdd.Seek(block * m_hdd_info.block_size + sizeof(vfsHDD_Entry)); + m_hdd.Read(wxStringBuffer(name, GetMaxNameLen()), GetMaxNameLen()); + } + + void WriteEntry(u64 block, const vfsHDD_Entry& data, const wxString& name) + { + m_hdd.Seek(block * m_hdd_info.block_size); + m_hdd.Write(&data, sizeof(vfsHDD_Entry)); + m_hdd.Write(name.c_str(), min(GetMaxNameLen() - 1, name.Len() + 1)); + } + + __forceinline u32 GetMaxNameLen() const + { + return m_hdd_info.block_size - sizeof(vfsHDD_Entry); + } + +public: + vfsHDDFile(vfsLocalFile& hdd, const vfsHDD_Hdr& hdd_info) + : m_hdd(hdd) + , m_hdd_info(hdd_info) + { + } + + ~vfsHDDFile() + { + } + + void Open(u64 info_block) + { + m_info_block = info_block; + ReadEntry(m_info_block, m_info); + m_position = 0; + m_cur_block = m_info.data_block; + } + + u64 FindFreeBlock() + { + vfsHDD_Block block_info; + + for(u64 i = 0; i(block_size - m_position, size); + + vfsHDD_Block cur_block_info; + m_hdd.Seek(m_cur_block * m_hdd_info.block_size); + m_hdd.Read(&cur_block_info, sizeof(vfsHDD_Block)); + m_hdd.Seek(m_cur_block * m_hdd_info.block_size + sizeof(vfsHDD_Block) + m_position); + m_hdd.Read(dst, rsize); + size -= rsize; + m_position += rsize; + if(!size) + { + return rsize; + } + + u64 offset = rsize; + + for(; size; size -= rsize, offset += rsize) + { + if(!cur_block_info.is_used || !cur_block_info.next_block || cur_block_info.next_block >= m_hdd_info.block_count) + { + return offset; + } + + m_cur_block = cur_block_info.next_block; + rsize = min(block_size, size); + + m_hdd.Seek(cur_block_info.next_block * m_hdd_info.block_size); + m_hdd.Read(&cur_block_info, sizeof(vfsHDD_Block)); + + if(m_hdd.Read((u8*)dst + offset, rsize) != rsize) + { + return offset; + } + } + + m_position = rsize; + + return offset; + } + + u64 Write(const void* src, u64 size) + { + if(!size) + return 0; + + vfsDeviceLocker lock(m_hdd); + + const u32 block_size = m_hdd_info.block_size - sizeof(vfsHDD_Block); + + if(!m_cur_block) + { + if(!m_info.data_block) + { + u64 new_block = FindFreeBlock(); + + if(!new_block) + { + return 0; + } + + WriteBlock(new_block, g_used_block); + m_info.data_block = new_block; + m_info.size = 0; + SaveInfo(); + } + + m_cur_block = m_info.data_block; + m_position = 0; + } + + u64 wsize = min(block_size - m_position, size); + + vfsHDD_Block block_info; + ReadBlock(m_cur_block, block_info); + + if(wsize) + { + m_hdd.Seek(m_cur_block * m_hdd_info.block_size + sizeof(vfsHDD_Block) + m_position); + m_hdd.Write(src, wsize); + size -= wsize; + m_info.size += wsize; + m_position += wsize; + SaveInfo(); + + if(!size) + return wsize; + } + + u64 last_block = m_cur_block; + block_info.is_used = true; + u64 offset = wsize; + + for(; size; size -= wsize, offset += wsize, m_info.size += wsize) + { + u64 new_block = FindFreeBlock(); + + if(!new_block) + { + m_position = 0; + SaveInfo(); + return offset; + } + + m_cur_block = new_block; + wsize = min(block_size, size); + + block_info.next_block = m_cur_block; + m_hdd.Seek(last_block * m_hdd_info.block_size); + if(m_hdd.Write(&block_info, sizeof(vfsHDD_Block)) != sizeof(vfsHDD_Block)) + { + m_position = 0; + SaveInfo(); + return offset; + } + + block_info.next_block = 0; + m_hdd.Seek(m_cur_block * m_hdd_info.block_size); + if(m_hdd.Write(&block_info, sizeof(vfsHDD_Block)) != sizeof(vfsHDD_Block)) + { + m_position = 0; + SaveInfo(); + return offset; + } + if((m_position = m_hdd.Write((u8*)src + offset, wsize)) != wsize) + { + m_info.size += wsize; + SaveInfo(); + return offset; + } + + last_block = m_cur_block; + } + + SaveInfo(); + m_position = wsize; + return offset; + } + + bool Eof() const + { + return m_info.size <= (m_cur_block * m_hdd_info.block_size + m_position); + } +}; + +class vfsHDD : public vfsFileBase +{ + vfsHDD_Hdr m_hdd_info; + vfsHDD_Entry m_cur_dir; + u64 m_cur_dir_block; + vfsHDDFile m_file; + vfsLocalFile m_hdd_file; + const wxString& m_hdd_path; + +public: + vfsHDD(const wxString& hdd_path) + : m_hdd_file(hdd_path, vfsReadWrite) + , m_file(m_hdd_file, m_hdd_info) + , m_hdd_path(hdd_path) + { + m_hdd_file.Read(&m_hdd_info, sizeof(vfsHDD_Hdr)); + m_cur_dir_block = m_hdd_info.next_block; + if(!m_hdd_info.block_size) + { + ConLog.Error("Bad block size!"); + m_hdd_info.block_size = 2048; + } + m_hdd_file.Seek(m_cur_dir_block * m_hdd_info.block_size); + m_hdd_file.Read(&m_cur_dir, sizeof(vfsHDD_Entry)); + } + + virtual vfsDevice* GetNew() + { + return new vfsHDD(m_hdd_path); + } + + __forceinline u32 GetMaxNameLen() const + { + return m_hdd_info.block_size - sizeof(vfsHDD_Entry); + } + + bool SearchEntry(const wxString& name, u64& entry_block, u64* parent_block = nullptr) + { + u64 last_block = 0; + u64 block = m_cur_dir_block; + vfsHDD_Entry entry; + wxString buf; + + while(block) + { + ReadEntry(block, entry, buf); + + if(name.CmpNoCase(buf) == 0) + { + entry_block = block; + if(parent_block) + *parent_block = last_block; + + return true; + } + + last_block = block; + block = entry.is_used ? entry.next_block : 0ULL; + } + + return false; + } + + int OpenDir(const wxString& name) + { + ConLog.Warning("OpenDir(%s)", name); + u64 entry_block; + if(!SearchEntry(name, entry_block)) + return -1; + + m_hdd_file.Seek(entry_block * m_hdd_info.block_size); + vfsHDD_Entry entry; + m_hdd_file.Read(&entry, sizeof(vfsHDD_Entry)); + if(entry.type == vfsHDD_Entry_File) + return 1; + + m_cur_dir_block = entry.data_block; + ReadEntry(m_cur_dir_block, m_cur_dir); + + return 0; + } + + bool Rename(const wxString& from, const wxString& to) + { + u64 entry_block; + if(!SearchEntry(from, entry_block)) + { + return false; + } + + vfsHDD_Entry entry; + ReadEntry(entry_block, entry); + WriteEntry(entry_block, entry, to); + + return true; + } + + u64 FindFreeBlock() + { + vfsHDD_Block block_info; + + for(u64 i = 0; i(GetMaxNameLen() - 1, name.Len() + 1)); + } + + bool Create(vfsHDD_EntryType type, const wxString& name) + { + if(HasEntry(name)) + { + return false; + } + + u64 new_block = FindFreeBlock(); + + ConLog.Write("CREATION ENTRY AT 0x%llx", new_block); + if(!new_block) + { + return false; + } + + WriteBlock(new_block, g_used_block); + + { + vfsHDD_Entry new_entry; + vfsHDDManager::CreateEntry(new_entry); + new_entry.next_block = 0; + new_entry.type = type; + + if(type == vfsHDD_Entry_Dir) + { + u64 block_cur = FindFreeBlock(); + + if(!block_cur) + { + return false; + } + + WriteBlock(block_cur, g_used_block); + + u64 block_last = FindFreeBlock(); + + if(!block_last) + { + return false; + } + + WriteBlock(block_last, g_used_block); + + vfsHDD_Entry entry_cur, entry_last; + vfsHDDManager::CreateEntry(entry_cur); + vfsHDDManager::CreateEntry(entry_last); + + entry_cur.type = vfsHDD_Entry_Dir; + entry_cur.data_block = block_cur; + entry_cur.next_block = block_last; + + entry_last.type = vfsHDD_Entry_Dir; + entry_last.data_block = m_cur_dir_block; + entry_last.next_block = 0; + + new_entry.data_block = block_cur; + + WriteEntry(block_cur, entry_cur, "."); + WriteEntry(block_last, entry_last, ".."); + } + + WriteEntry(new_block, new_entry, name); + } + + { + u64 block = m_cur_dir_block; + + vfsHDD_Block tmp; + while(block) + { + ReadBlock(block, tmp); + + if(!tmp.next_block) + break; + + block = tmp.next_block; + } + + tmp.next_block = new_block; + WriteBlock(block, tmp); + } + + return true; + } + + bool GetFirstEntry(u64& block, vfsHDD_Entry& entry, wxString& name) + { + if(!m_cur_dir_block) + { + return false; + } + + ReadEntry(m_cur_dir_block, entry, name); + block = entry.is_used ? entry.next_block : 0; + + return true; + } + + bool GetNextEntry(u64& block, vfsHDD_Entry& entry, wxString& name) + { + if(!block) + { + return false; + } + + ReadEntry(block, entry, name); + + block = entry.is_used ? entry.next_block : 0; + return true; + } + + virtual bool Open(const wxString& path, vfsOpenMode mode = vfsRead) + { + const char* s = path.c_str(); + u64 from = 0; + u64 pos = 0; + u64 file_pos = -1; + + do + { + if(s[pos] == '\\' || s[pos] == '\0') + { + if(file_pos != -1) + { + return false; + } + + if(from != -1) + { + if(pos - from > 1) + { + int res = OpenDir(wxString(s + from, pos)); + if(res == -1) + { + return false; + } + + if(res == 1) + { + file_pos = from; + } + } + + from = pos; + } + else + { + from = pos; + } + } + } + while(s[pos++] != '\0'); + + if(file_pos == -1) + { + return false; + } + + u64 file_block; + if(!SearchEntry(wxString(s + file_pos), file_block)) + { + return false; + } + + ConLog.Write("ENTRY FINDED AT 0x%llx", file_block); + m_file.Open(file_block); + + return vfsFileBase::Open(path, mode); + } + + bool HasEntry(const wxString& name) + { + u64 file_block; + if(!SearchEntry(name, file_block)) + { + return false; + } + + return true; + } + + void RemoveBlocksDir(u64 start_block) + { + wxString name; + u64 block = start_block; + vfsHDD_Entry entry; + + while(block) + { + ReadEntry(block, entry, name); + WriteBlock(block, g_null_block); + + if(entry.type == vfsHDD_Entry_Dir && name != "." && name != "..") + { + ConLog.Warning("removing sub folder '%s'", name); + RemoveBlocksDir(entry.data_block); + } + else if(entry.type == vfsHDD_Entry_File) + { + RemoveBlocksFile(entry.data_block); + } + + block = entry.next_block; + } + } + + void RemoveBlocksFile(u64 start_block) + { + u64 block = start_block; + vfsHDD_Block block_data; + + while(block) + { + ReadBlock(block, block_data); + WriteBlock(block, g_null_block); + + block = block_data.next_block; + } + } + + bool RemoveEntry(const wxString& name) + { + u64 entry_block, parent_entry; + if(!SearchEntry(name, entry_block, &parent_entry)) + { + return false; + } + + vfsHDD_Entry entry; + ReadEntry(entry_block, entry); + if(entry.type == vfsHDD_Entry_Dir) + { + RemoveBlocksDir(entry.data_block); + } + else if(entry.type == vfsHDD_Entry_File) + { + RemoveBlocksFile(entry.data_block); + } + + if(parent_entry) + { + u64 next = entry.next_block; + ReadEntry(parent_entry, entry); + entry.next_block = next; + WriteEntry(parent_entry, entry); + } + WriteBlock(entry_block, g_null_block); + return true; + } + + virtual bool Create(const wxString& path) + { + return false; + } + + virtual u32 Write(const void* src, u32 size) + { + return vfsFileBase::Write(src, m_file.Write(src, size)); + } + + virtual u32 Read(void* dst, u32 size) + { + return vfsFileBase::Read(dst, m_file.Read(dst, size)); + } + + virtual u64 Seek(s64 offset, vfsSeekMode mode = vfsSeekSet) + { + switch(mode) + { + case vfsSeekCur: + m_file.Seek(Tell() + offset); + break; + + case vfsSeekSet: + m_file.Seek(offset); + break; + + case vfsSeekEnd: + m_file.Seek(m_file.GetSize() + offset); + break; + } + + return vfsFileBase::Seek(offset, mode); + } + + virtual bool Eof() + { + return m_file.Eof(); + } + + virtual u64 GetSize() + { + return m_file.GetSize(); + } +}; \ No newline at end of file diff --git a/rpcs3/Emu/Io/Pad.cpp b/rpcs3/Emu/Io/Pad.cpp index 743b0166d1..73f2d216ed 100644 --- a/rpcs3/Emu/Io/Pad.cpp +++ b/rpcs3/Emu/Io/Pad.cpp @@ -4,7 +4,7 @@ #include "Windows/WindowsPadHandler.h" PadManager::PadManager() - : m_pad_handler(NULL) + : m_pad_handler(nullptr) , m_inited(false) { } @@ -32,7 +32,7 @@ void PadManager::Init(const u32 max_connect) void PadManager::Close() { if(m_pad_handler) m_pad_handler->Close(); - m_pad_handler = NULL; + m_pad_handler = nullptr; m_inited = false; } \ No newline at end of file diff --git a/rpcs3/Emu/Io/PadHandler.h b/rpcs3/Emu/Io/PadHandler.h index 30c7852d48..2060e01339 100644 --- a/rpcs3/Emu/Io/PadHandler.h +++ b/rpcs3/Emu/Io/PadHandler.h @@ -90,9 +90,11 @@ struct Button u32 m_keyCode; u32 m_outKeyCode; bool m_pressed; + bool m_flush; Button(u32 offset, u32 keyCode, u32 outKeyCode) : m_pressed(false) + , m_flush(false) , m_offset(offset) , m_keyCode(keyCode) , m_outKeyCode(outKeyCode) @@ -169,8 +171,8 @@ struct Pad struct PadInfo { u32 max_connect; - u32 now_connect; - u32 system_info; + u32 now_connect; + u32 system_info; }; class PadHandlerBase @@ -191,7 +193,14 @@ public: { Button& button = GetButtons(p).Get(b); if(button.m_keyCode != code) continue; - button.m_pressed = pressed; + if(button.m_pressed && !pressed) + { + button.m_flush = true; + } + else + { + button.m_pressed = pressed; + } } } } diff --git a/rpcs3/Emu/Memory/Memory.cpp b/rpcs3/Emu/Memory/Memory.cpp index 0c08be11b7..60d60a838b 100644 --- a/rpcs3/Emu/Memory/Memory.cpp +++ b/rpcs3/Emu/Memory/Memory.cpp @@ -88,7 +88,7 @@ MemoryBlock* MemoryBlock::SetRange(const u64 start, const u32 size) bool MemoryBlock::IsMyAddress(const u64 addr) { - return addr >= GetStartAddr() && addr < GetEndAddr(); + return mem && addr >= GetStartAddr() && addr < GetEndAddr(); } __forceinline const u8 MemoryBlock::FastRead8(const u64 addr) const @@ -466,24 +466,52 @@ u8* DynamicMemoryBlock::GetMem(u64 addr) const return nullptr; } +#define DEBUG_RAWSPU_MEM 1 //MemoryBase void MemoryBase::Write8(u64 addr, const u8 data) { +#if DEBUG_RAWSPU_MEM + if(SpuRawMem.IsMyAddress(addr)) + { + ConLog.Warning("Write8(addr=0x%llx,data=0x%x)", addr, data); + } +#endif GetMemByAddr(addr).Write8(addr, data); } void MemoryBase::Write16(u64 addr, const u16 data) { +#if DEBUG_RAWSPU_MEM + if(SpuRawMem.IsMyAddress(addr)) + { + ConLog.Warning("Write16(addr=0x%llx,data=0x%x)", addr, data); + } +#endif + GetMemByAddr(addr).Write16(addr, data); } void MemoryBase::Write32(u64 addr, const u32 data) { +#if DEBUG_RAWSPU_MEM + if(SpuRawMem.IsMyAddress(addr)) + { + ConLog.Warning("Write32(addr=0x%llx,data=0x%x)", addr, data); + } +#endif + GetMemByAddr(addr).Write32(addr, data); } void MemoryBase::Write64(u64 addr, const u64 data) { +#if DEBUG_RAWSPU_MEM + if(SpuRawMem.IsMyAddress(addr)) + { + ConLog.Warning("Write64(addr=0x%llx,data=0x%llx)", addr, data); + } +#endif + GetMemByAddr(addr).Write64(addr, data); } @@ -529,6 +557,13 @@ bool MemoryBase::Write128NN(u64 addr, const u128 data) u8 MemoryBase::Read8(u64 addr) { +#if DEBUG_RAWSPU_MEM + if(SpuRawMem.IsMyAddress(addr)) + { + ConLog.Warning("Read8(addr=0x%llx)", addr); + } +#endif + MemoryBlock& mem = GetMemByAddr(addr); if(mem.IsNULL()) { @@ -540,6 +575,13 @@ u8 MemoryBase::Read8(u64 addr) u16 MemoryBase::Read16(u64 addr) { +#if DEBUG_RAWSPU_MEM + if(SpuRawMem.IsMyAddress(addr)) + { + ConLog.Warning("Read16(addr=0x%llx)", addr); + } +#endif + MemoryBlock& mem = GetMemByAddr(addr); if(mem.IsNULL()) { @@ -551,6 +593,13 @@ u16 MemoryBase::Read16(u64 addr) u32 MemoryBase::Read32(u64 addr) { +#if DEBUG_RAWSPU_MEM + if(SpuRawMem.IsMyAddress(addr) && !(GetCurrentPPCThread() && GetCurrentPPCThread()->GetType() == PPC_THREAD_RAW_SPU)) + { + ConLog.Warning("Read32(addr=0x%llx)", addr); + } +#endif + MemoryBlock& mem = GetMemByAddr(addr); if(mem.IsNULL()) { @@ -562,6 +611,13 @@ u32 MemoryBase::Read32(u64 addr) u64 MemoryBase::Read64(u64 addr) { +#if DEBUG_RAWSPU_MEM + if(SpuRawMem.IsMyAddress(addr)) + { + ConLog.Warning("Read64(addr=0x%llx)", addr); + } +#endif + MemoryBlock& mem = GetMemByAddr(addr); if(mem.IsNULL()) { diff --git a/rpcs3/Emu/Memory/Memory.h b/rpcs3/Emu/Memory/Memory.h index 5fdcaa0b8f..312ae36c91 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -63,16 +63,16 @@ public: */ } - template static __forceinline T Reverse(T val); - template<> static __forceinline u8 Reverse(u8 val) { return val; }; - template<> static __forceinline u16 Reverse(u16 val) { return Reverse16(val); }; - template<> static __forceinline u32 Reverse(u32 val) { return Reverse32(val); }; - template<> static __forceinline u64 Reverse(u64 val) { return Reverse64(val); }; + template static __forceinline u64 ReverseData(u64 val); + template<> static __forceinline u64 ReverseData<1>(u64 val) { return val; } + template<> static __forceinline u64 ReverseData<2>(u64 val) { return Reverse16(val); } + template<> static __forceinline u64 ReverseData<4>(u64 val) { return Reverse32(val); } + template<> static __forceinline u64 ReverseData<8>(u64 val) { return Reverse64(val); } - template<> static __forceinline s8 Reverse(s8 val) { return val; }; - template<> static __forceinline s16 Reverse(s16 val) { return Reverse16(val); }; - template<> static __forceinline s32 Reverse(s32 val) { return Reverse32(val); }; - template<> static __forceinline s64 Reverse(s64 val) { return Reverse64(val); }; + template static __forceinline T Reverse(T val) + { + return (T)ReverseData(val); + }; MemoryBlock& GetMemByNum(const u8 num) { @@ -328,6 +328,32 @@ public: return PRXMem.Free(addr); } + bool Map(const u64 dst_addr, const u64 src_addr, const u32 size) + { + if(IsGoodAddr(dst_addr) || !IsGoodAddr(src_addr)) + { + return false; + } + + MemoryBlocks.Add((new MemoryMirror())->SetRange(GetMemFromAddr(src_addr), dst_addr, size)); + ConLog.Warning("memory mapped 0x%llx to 0x%llx size=0x%x", src_addr, dst_addr, size); + return true; + } + + bool Unmap(const u64 addr) + { + for(uint i=0; iWait(new_thread); +} - ConLog.Write("Callback EXIT!"); +Callback::operator bool() const +{ + return GetAddr() != 0; } Callback2::Callback2(u32 slot, u64 addr, u64 userdata) : Callback(slot, addr) diff --git a/rpcs3/Emu/SysCalls/Callback.h b/rpcs3/Emu/SysCalls/Callback.h index fe720ab18e..49395f3527 100644 --- a/rpcs3/Emu/SysCalls/Callback.h +++ b/rpcs3/Emu/SysCalls/Callback.h @@ -1,19 +1,29 @@ #pragma once -struct Callback +class Callback { +protected: u64 m_addr; u32 m_slot; + bool m_has_data; + +public: u64 a1; u64 a2; u64 a3; - bool m_has_data; + u32 GetSlot() const; + u64 GetAddr() const; + void SetSlot(u32 slot); + void SetAddr(u64 addr); + bool HasData() const; - Callback(u32 slot, u64 addr); - void Handle(u64 a1, u64 a2, u64 a3); - void Branch(); + Callback(u32 slot = 0, u64 addr = 0); + void Handle(u64 a1 = 0, u64 a2 = 0, u64 a3 = 0); + void Branch(bool wait); + + operator bool() const; }; struct Callback2 : public Callback @@ -46,7 +56,7 @@ struct Callbacks { for(u32 i=0; i g_modules_funcs_list; + +struct ModuleInfo +{ + u32 id; + char* name; +} +static const g_module_list[] = +{ + {0x0000, "sys_net"}, + {0x0001, "sys_http"}, + {0x0002, "cellHttpUtil"}, + {0x0003, "cellSsl"}, + {0x0004, "cellHttps"}, + {0x0005, "cellVdec"}, + {0x0006, "cellAdec"}, + {0x0007, "cellDmux"}, + {0x0008, "cellVpost"}, + {0x0009, "cellRtc"}, + {0x000a, "cellSpurs"}, + {0x000b, "cellOvis"}, + {0x000c, "cellSheap"}, + {0x000d, "sys_sync"}, + {0x000e, "sys_fs"}, + {0x000f, "sys_jpgdec"}, + {0x0010, "cellGcmSys"}, + {0x0011, "cellAudio"}, + {0x0012, "cellPamf"}, + {0x0013, "cellAtrac"}, + {0x0014, "cellNetCtl"}, + {0x0015, "cellSysutil"}, + {0x0016, "sceNp"}, + {0x0017, "sys_io"}, + {0x0018, "cellPngDec"}, + {0x0019, "cellFont"}, + {0x001a, "cellFontFt"}, + {0x001b, "cellFreetype"}, + {0x001c, "cellUsbd"}, + {0x001d, "cellSail"}, + {0x001e, "cellL10n"}, + {0x001f, "cellResc"}, + {0x0020, "cellDaisy"}, + {0x0021, "cellKey2char"}, + {0x0022, "cellMic"}, + {0x0023, "cellCamera"}, + {0x0024, "cellVdecMpeg2"}, + {0x0025, "cellVdecAvc"}, + {0x0026, "cellAdecLpcm"}, + {0x0027, "cellAdecAc3"}, + {0x0028, "cellAdecAtx"}, + {0x0029, "cellAdecAt3"}, + {0x002a, "cellDmuxPamf"}, + {0x002e, "cellLv2dbg"}, + {0x0030, "cellUsbpspcm"}, + {0x0031, "cellAvconfExt"}, + {0x0032, "cellSysutilUserinfo"}, + {0x0033, "cellSysutilSavedata"}, + {0x0034, "cellSubdisplay"}, + {0x0035, "cellSysutilRec"}, + {0x0036, "cellVideoExport"}, + {0x0037, "cellGameExec"}, + {0x0038, "sceNp2"}, + {0x0039, "cellSysutilAp"}, + {0x003a, "cellSysutilNpClans"}, + {0x003b, "cellSysutilOskExt"}, + {0x003c, "cellVdecDivx"}, + {0x003d, "cellJpgEnc"}, + {0x003e, "cellGame"}, + {0x003f, "cellBgdl"}, + {0x0040, "cellFreetypeTT"}, + {0x0041, "cellSysutilVideoUpload"}, + {0x0042, "cellSysutilSysconfExt"}, + {0x0043, "cellFiber"}, + {0x0044, "cellNpCommerce2"}, + {0x0045, "cellNpTus"}, + {0x0046, "cellVoice"}, + {0x0047, "cellAdecCelp8"}, + {0x0048, "cellCelp8Enc"}, + {0x0049, "cellLicenseArea"}, + {0x004a, "cellMusic2"}, + {0x004e, "cellScreenshot"}, + {0x004f, "cellMusicDecode"}, + {0x0050, "cellSpursJq"}, + {0x0052, "cellPngEnc"}, + {0x0053, "cellMusicDecode2"}, + {0x0055, "cellSync2"}, + {0x0056, "cellNpUtil"}, + {0x0057, "cellRudp"}, + {0x0059, "cellNpSns"}, + {0x005a, "cellGem"}, + {0xf00a, "cellCelpEnc"}, + {0xf010, "cellGifDec"}, + {0xf019, "cellAdecCelp"}, + {0xf01b, "cellAdecM2bc"}, + {0xf01d, "cellAdecM4aac"}, + {0xf01e, "cellAdecMp3"}, + {0xf023, "cellImejp"}, + {0xf028, "cellMusic"}, + {0xf029, "cellPhotoExport"}, + {0xf02a, "cellPrint"}, + {0xf02b, "cellPhotoImport"}, + {0xf02c, "cellMusicExport"}, + {0xf02e, "cellPhotoDecode"}, + {0xf02f, "cellSearch"}, + {0xf030, "cellAvchat2"}, + {0xf034, "cellSailRec"}, + {0xf035, "sceNpTrophy"}, + {0xf053, "cellAdecAt3multi"}, + {0xf054, "cellLibatrac3multi"}, +}; + +struct _InitNullModules +{ + _InitNullModules() + { + for(auto& m : g_module_list) + { + new Module(m.id, m.name); + } + } +} InitNullModules; + +bool IsLoadedFunc(u32 id) +{ + for(u32 i=0; i= g_modules_funcs_list.GetCount()) + return false; + + (*g_modules_funcs_list[num - 1024].func)(); + return true; +} + +bool UnloadFunc(u32 id) +{ + for(u32 i=0; iSetLoaded(false); + } + + if(g_modules[1][i]) + { + g_modules[1][i]->SetLoaded(false); + } + + if(g_modules[2][i]) + { + g_modules[2][i]->SetLoaded(false); + } + } + + g_modules_funcs_list.Clear(); +} + +Module* GetModuleByName(const wxString& name) +{ + for(u32 i=0; iGetName().Cmp(name) == 0) + { + return g_modules[0][i]; + } + + if(g_modules[1][i] && g_modules[1][i]->GetName().Cmp(name) == 0) + { + return g_modules[1][i]; + } + + if(g_modules[2][i] && g_modules[2][i]->GetName().Cmp(name) == 0) + { + return g_modules[2][i]; + } + } + + return nullptr; +} + +Module* GetModuleById(u16 id) +{ + for(u32 i=0; iGetID() == id) + { + return g_modules[0][i]; + } + + if(g_modules[1][i] && g_modules[1][i]->GetID() == id) + { + return g_modules[1][i]; + } + } + + return nullptr; +} + +void SetModule(int id, Module* module, bool with_data) +{ + if(id != 0xffff) + { + if(u16((u8)id + 1) > g_max_module_id) + { + g_max_module_id = u16((u8)id + 1); + } + + int index; + switch(id >> 8) + { + case 0x00: index = 0; break; + case 0xf0: index = 1; break; + default: assert(0); return; + } + + if(g_modules[index][(u8)id]) + { + if(with_data) + { + module->SetName(g_modules[index][(u8)id]->GetName()); + delete g_modules[index][(u8)id]; + g_modules[index][(u8)id] = module; + } + else + { + g_modules[index][(u8)id]->SetName(module->GetName()); + delete module; + } + } + else + { + g_modules[index][(u8)id] = module; + } + } + else + { + g_modules[2][g_module_2_count++] = module; + + if(g_module_2_count > g_max_module_id) + { + g_max_module_id = g_module_2_count; + } + } +} + +Module::Module(u16 id, const char* name) + : m_is_loaded(false) + , m_name(name) + , m_id(id) +{ + SetModule(m_id, this, false); +} + +Module::Module(const char* name, void (*init)()) + : m_is_loaded(false) + , m_name(name) + , m_id(-1) +{ + SetModule(m_id, this, init != nullptr); + if(init) init(); +} + +Module::Module(u16 id, void (*init)()) + : m_is_loaded(false) + , m_id(id) +{ + SetModule(m_id, this, init != nullptr); + if(init) init(); +} + +void Module::Load() +{ + for(u32 i=0; i bool Module::CheckId(u32 id, T*& data) +{ + ID id_data; + + if(!CheckId(id, id_data)) return false; + + data = (T*)id_data.m_data; + + return true; +} + +u32 Module::GetNewId(void* data, u8 flags) +{ + return Emu.GetIdManager().GetNewID(GetName(), data, flags); +} diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h new file mode 100644 index 0000000000..1d673d27e4 --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -0,0 +1,80 @@ +#pragma once + +#define declCPU PPUThread& CPU = GetCurrentPPUThread + +class func_caller +{ +public: + virtual void operator()() = 0; +}; + +//TODO +struct ModuleFunc +{ + u32 id; + func_caller* func; + + ModuleFunc(u32 id, func_caller* func) + : id(id) + , func(func) + { + } +}; + +class Module +{ + wxString m_name; + const u16 m_id; + bool m_is_loaded; + +public: + Array m_funcs_list; + + Module(u16 id, const char* name); + Module(const char* name, void (*init)()); + Module(u16 id, void (*init)()); + + void Load(); + void UnLoad(); + bool Load(u32 id); + bool UnLoad(u32 id); + + void SetLoaded(bool loaded = true); + bool IsLoaded() const; + + u16 GetID() const; + wxString GetName() const; + void SetName(const wxString& name); + +public: + void Log(const u32 id, wxString fmt, ...); + void Log(wxString fmt, ...); + + void Warning(const u32 id, wxString fmt, ...); + void Warning(wxString fmt, ...); + + void Error(const u32 id, wxString fmt, ...); + void Error(wxString fmt, ...); + + bool CheckId(u32 id) const; + + bool CheckId(u32 id, ID& _id) const; + + template bool CheckId(u32 id, T*& data); + + u32 GetNewId(void* data = nullptr, u8 flags = 0); + + template + __forceinline void AddFunc(u32 id, T func) + { + m_funcs_list.Move(new ModuleFunc(id, bind_func(func))); + } +}; + +bool IsLoadedFunc(u32 id); +bool CallFunc(u32 num); +bool UnloadFunc(u32 id); +void UnloadModules(); +u32 GetFuncNumById(u32 id); +Module* GetModuleByName(const wxString& name); +Module* GetModuleById(u16 id); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index ac33410632..fa8b4a5695 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -1,8 +1,344 @@ #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" +#include "Emu/GS/GCM.h" -Module cellGcmSys("cellGcmSys", 0x0010); +void cellGcmSys_init(); +Module cellGcmSys(0x0010, cellGcmSys_init); + +enum +{ + CELL_GCM_ERROR_FAILURE = 0x802100ff, + CELL_GCM_ERROR_INVALID_ENUM = 0x80210002, + CELL_GCM_ERROR_INVALID_VALUE = 0x80210003, + CELL_GCM_ERROR_INVALID_ALIGNMENT = 0x80210004, +}; + +CellGcmConfig current_config; +CellGcmContextData current_context; +gcmInfo gcm_info; +struct gcm_offset +{ + u16 ea; + u16 offset; +}; + +u32 map_offset_addr = 0; +u32 map_offset_pos = 0; + +int cellGcmMapMainMemory(u32 address, u32 size, u32 offset_addr) +{ + cellGcmSys.Warning("cellGcmMapMainMemory(address=0x%x,size=0x%x,offset_addr=0x%x)", address, size, offset_addr); + if(!Memory.IsGoodAddr(offset_addr, sizeof(u32))) return CELL_EFAULT; + + Emu.GetGSManager().GetRender().m_main_mem_addr = Emu.GetGSManager().GetRender().m_ioAddress; + + u32 offset = address - Emu.GetGSManager().GetRender().m_main_mem_addr; + Emu.GetGSManager().GetRender().m_main_mem_info.AddCpy(MemInfo(address, size)); + + Memory.Write32(offset_addr, offset); + + return CELL_OK; +} + +int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) +{ + cellGcmSys.Log("cellGcmInit(context_addr=0x%x,cmdSize=0x%x,ioSize=0x%x,ioAddress=0x%x)", context_addr, cmdSize, ioSize, ioAddress); + + const u32 local_size = 0xf900000; //TODO + const u32 local_addr = Memory.RSXFBMem.GetStartAddr(); + + map_offset_addr = 0; + map_offset_pos = 0; + current_config.ioSize = re32(ioSize); + current_config.ioAddress = re32(ioAddress); + current_config.localSize = re32(local_size); + current_config.localAddress = re32(local_addr); + current_config.memoryFrequency = re32(650000000); + current_config.coreFrequency = re32(500000000); + + Memory.RSXFBMem.Alloc(local_size); + Memory.RSXCMDMem.Alloc(cmdSize); + + u32 ctx_begin = ioAddress/* + 0x1000*/; + u32 ctx_size = 0x6ffc; + current_context.begin = re(ctx_begin); + current_context.end = re(ctx_begin + ctx_size); + current_context.current = current_context.begin; + current_context.callback = re32(Emu.GetRSXCallback() - 4); + + gcm_info.context_addr = Memory.MainMem.Alloc(0x1000); + gcm_info.control_addr = gcm_info.context_addr + 0x40; + + Memory.WriteData(gcm_info.context_addr, current_context); + Memory.Write32(context_addr, gcm_info.context_addr); + + CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; + ctrl.put = 0; + ctrl.get = 0; + ctrl.ref = -1; + + auto& render = Emu.GetGSManager().GetRender(); + render.m_ctxt_addr = context_addr; + render.m_gcm_buffers_addr = Memory.Alloc(sizeof(gcmBuffer) * 8, sizeof(gcmBuffer)); + render.m_zculls_addr = Memory.Alloc(sizeof(CellGcmZcullInfo) * 8, sizeof(CellGcmZcullInfo)); + render.m_tiles_addr = Memory.Alloc(sizeof(CellGcmTileInfo) * 15, sizeof(CellGcmTileInfo)); + render.m_gcm_buffers_count = 0; + render.m_gcm_current_buffer = 0; + render.m_main_mem_info.Clear(); + render.m_main_mem_addr = 0; + render.Init(ctx_begin, ctx_size, gcm_info.control_addr, local_addr); + + return CELL_OK; +} + +int cellGcmGetConfiguration(u32 config_addr) +{ + cellGcmSys.Log("cellGcmGetConfiguration(config_addr=0x%x)", config_addr); + + if(!Memory.IsGoodAddr(config_addr, sizeof(CellGcmConfig))) return CELL_EFAULT; + + Memory.WriteData(config_addr, current_config); + return CELL_OK; +} + +int cellGcmAddressToOffset(u32 address, u32 offset_addr) +{ + cellGcmSys.Log("cellGcmAddressToOffset(address=0x%x,offset_addr=0x%x)", address, offset_addr); + if(!Memory.IsGoodAddr(offset_addr, sizeof(u32))) return CELL_EFAULT; + + if(!map_offset_addr) + { + map_offset_addr = Memory.Alloc(4*50, 4); + } + + u32 sa; + bool is_main_mem = false; + const auto& main_mem_info = Emu.GetGSManager().GetRender().m_main_mem_info; + for(u32 i=0; i= main_mem_info[i].addr && address < main_mem_info[i].addr + main_mem_info[i].size) + { + is_main_mem = true; + break; + } + } + + if(is_main_mem) + { + //main + sa = Emu.GetGSManager().GetRender().m_main_mem_addr; + //ConLog.Warning("cellGcmAddressToOffset: main memory: offset = 0x%x - 0x%x = 0x%x", address, sa, address - sa); + } + else if(Memory.RSXFBMem.IsMyAddress(address)) + { + //local + sa = Emu.GetGSManager().GetRender().m_local_mem_addr; + //ConLog.Warning("cellGcmAddressToOffset: local memory: offset = 0x%x - 0x%x = 0x%x", address, sa, address - sa); + } + else + { + //io + sa = Emu.GetGSManager().GetRender().m_ioAddress; + //ConLog.Warning("cellGcmAddressToOffset: io memory: offset = 0x%x - 0x%x = 0x%x", address, sa, address - sa); + } + + u32 offset = address - sa; + //Memory.Write16(map_offset_addr + map_offset_pos + 0, ea); + //Memory.Write16(map_offset_addr + map_offset_pos + 2, offset); + //map_offset_pos += 4; + + Memory.Write32(offset_addr, offset); + + return CELL_OK; +} + +int cellGcmSetDisplayBuffer(u32 id, u32 offset, u32 pitch, u32 width, u32 height) +{ + cellGcmSys.Warning("cellGcmSetDisplayBuffer(id=0x%x,offset=0x%x,pitch=%d,width=%d,height=%d)", + id, offset, width ? pitch/width : pitch, width, height); + if(id > 7) return CELL_EINVAL; + + gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(Emu.GetGSManager().GetRender().m_gcm_buffers_addr); + + buffers[id].offset = re(offset); + buffers[id].pitch = re(pitch); + buffers[id].width = re(width); + buffers[id].height = re(height); + + if(id + 1 > Emu.GetGSManager().GetRender().m_gcm_buffers_count) + { + Emu.GetGSManager().GetRender().m_gcm_buffers_count = id + 1; + } + + return CELL_OK; +} + +u32 cellGcmGetLabelAddress(u8 index) +{ + cellGcmSys.Log("cellGcmGetLabelAddress(index=%d)", index); + return Memory.RSXCMDMem.GetStartAddr() + 0x10 * index; +} + +u32 cellGcmGetControlRegister() +{ + cellGcmSys.Log("cellGcmGetControlRegister()"); + + return gcm_info.control_addr; +} + +int cellGcmSetPrepareFlip(u32 ctx, u32 id) +{ + cellGcmSys.Log("cellGcmSetPrepareFlip(ctx=0x%x, id=0x%x)", ctx, id); + + if(id >= 8) + { + return CELL_GCM_ERROR_FAILURE; + } + + GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); + CellGcmContextData& ctxt = (CellGcmContextData&)Memory[ctx]; + u32 current = re(ctxt.current); + u32 end = re(ctxt.end); + + if(current + 8 >= end) + { + ConLog.Warning("bad flip!"); + cellGcmCallback(ctx, current + 8 - end); + } + + current = re(ctxt.current); + Memory.Write32(current, 0x3fead | (1 << 18)); + Memory.Write32(current + 4, id); + re(ctxt.current, current + 8); + + if(ctx == gcm_info.context_addr) + { + CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; + re(ctrl.put, re(ctrl.put) + 8); + } + + return id; +} + +int cellGcmSetFlipCommand(u32 ctx, u32 id) +{ + return cellGcmSetPrepareFlip(ctx, id); +} + +int cellGcmSetZcull(u8 index, u32 offset, u32 width, u32 height, u32 cullStart, u32 zFormat, u32 aaFormat, u32 zCullDir, u32 zCullFormat, u32 sFunc, u32 sRef, u32 sMask) +{ + cellGcmSys.Warning("TODO: cellGcmSetZcull(index=%d, offset=0x%x, width=%d, height=%d, cullStart=0x%x, zFormat=0x%x, aaFormat=0x%x, zCullDir=0x%x, zCullFormat=0x%x, sFunc=0x%x, sRef=0x%x, sMask=0x%x)", + index, offset, width, height, cullStart, zFormat, aaFormat, zCullDir, zCullFormat, sFunc, sRef, sMask); + + return CELL_OK; +} + +int cellGcmBindZcull(u8 index) +{ + cellGcmSys.Warning("TODO: cellGcmBindZcull(index=%d)", index); + + return CELL_OK; +} + +u32 cellGcmGetZcullInfo() +{ + cellGcmSys.Warning("cellGcmGetZcullInfo()"); + return Emu.GetGSManager().GetRender().m_zculls_addr; +} + +int cellGcmGetFlipStatus() +{ + return Emu.GetGSManager().GetRender().m_flip_status; +} + +int cellGcmResetFlipStatus() +{ + Emu.GetGSManager().GetRender().m_flip_status = 1; + + return CELL_OK; +} + +int cellGcmSetFlipMode(u32 mode) +{ + cellGcmSys.Warning("cellGcmSetFlipMode(mode=%d)", mode); + + switch(mode) + { + case CELL_GCM_DISPLAY_HSYNC: + case CELL_GCM_DISPLAY_VSYNC: + case CELL_GCM_DISPLAY_HSYNC_WITH_NOISE: + Emu.GetGSManager().GetRender().m_flip_mode = mode; + break; + + default: + return CELL_EINVAL; + } + + return CELL_OK; +} + +u32 cellGcmGetTiledPitchSize(u32 size) +{ + //TODO + cellGcmSys.Warning("cellGcmGetTiledPitchSize(size=%d)", size); + + return size; +} + +u32 cellGcmGetDefaultCommandWordSize() +{ + cellGcmSys.Warning("cellGcmGetDefaultCommandWordSize()"); + return 0x400; +} + +u32 cellGcmGetDefaultSegmentWordSize() +{ + cellGcmSys.Warning("cellGcmGetDefaultSegmentWordSize()"); + return 0x100; +} + +int cellGcmSetDefaultFifoSize(u32 bufferSize, u32 segmentSize) +{ + cellGcmSys.Warning("cellGcmSetDefaultFifoSize(bufferSize=0x%x, segmentSize=0x%x)", bufferSize, segmentSize); + return CELL_OK; +} + +int cellGcmMapEaIoAddress(const u32 ea, const u32 io, const u32 size) +{ + cellGcmSys.Warning("cellGcmMapEaIoAddress(ea=0x%x, io=0x%x, size=0x%x)", ea, io, size); + Memory.Map(io, ea, size); + Emu.GetGSManager().GetRender().m_report_main_addr = ea; + return CELL_OK; +} + +int cellGcmUnbindZcull(u8 index) +{ + cellGcmSys.Warning("cellGcmUnbindZcull(index=%d)", index); + if(index >= 8) + return CELL_EINVAL; + + return CELL_OK; +} + +u64 cellGcmGetTimeStamp(u32 index) +{ + cellGcmSys.Log("cellGcmGetTimeStamp(index=%d)", index); + return Memory.Read64(Memory.RSXFBMem.GetStartAddr() + index * 0x10); +} + +int cellGcmSetFlipHandler(u32 handler_addr) +{ + cellGcmSys.Warning("cellGcmSetFlipHandler(handler_addr=%d)", handler_addr); + if(!Memory.IsGoodAddr(handler_addr) && handler_addr != 0) + { + return CELL_EFAULT; + } + + Emu.GetGSManager().GetRender().m_flip_handler.SetAddr(handler_addr); + return 0; +} s64 cellGcmFunc15() { @@ -10,31 +346,216 @@ s64 cellGcmFunc15() return 0; } -s64 cellGcmSetFlipCommandWithWaitLabel() +int cellGcmSetFlipCommandWithWaitLabel(u32 ctx, u32 id, u32 label_index, u32 label_value) { - cellGcmSys.Error("cellGcmSetFlipCommandWithWaitLabel()"); - return 0; + int res = cellGcmSetPrepareFlip(ctx, id); + Memory.Write32(Memory.RSXCMDMem.GetStartAddr() + 0x10 * label_index, label_value); + return res == CELL_GCM_ERROR_FAILURE ? CELL_GCM_ERROR_FAILURE : CELL_OK; } -struct _cellGcmSys_init +int cellGcmInitCursor() { - _cellGcmSys_init() + UNIMPLEMENTED_FUNC(cellGcmSys); + return CELL_OK; +} + +int cellGcmSetCursorPosition(s32 x, s32 y) +{ + UNIMPLEMENTED_FUNC(cellGcmSys); + return CELL_OK; +} + +int cellGcmSetCursorDisable() +{ + UNIMPLEMENTED_FUNC(cellGcmSys); + return CELL_OK; +} + +int cellGcmSetVBlankHandler() +{ + UNIMPLEMENTED_FUNC(cellGcmSys); + return CELL_OK; +} + +int cellGcmUpdateCursor() +{ + UNIMPLEMENTED_FUNC(cellGcmSys); + return CELL_OK; +} + +int cellGcmSetCursorEnable() +{ + UNIMPLEMENTED_FUNC(cellGcmSys); + return CELL_OK; +} + +int cellGcmSetCursorImageOffset(u32 offset) +{ + UNIMPLEMENTED_FUNC(cellGcmSys); + return CELL_OK; +} + +u32 cellGcmGetDisplayInfo() +{ + cellGcmSys.Warning("cellGcmGetDisplayInfo() = 0x%x", Emu.GetGSManager().GetRender().m_gcm_buffers_addr); + return Emu.GetGSManager().GetRender().m_gcm_buffers_addr; +} + +int cellGcmGetCurrentDisplayBufferId(u32 id_addr) +{ + cellGcmSys.Warning("cellGcmGetCurrentDisplayBufferId(id_addr=0x%x)", id_addr); + + if(!Memory.IsGoodAddr(id_addr)) { - cellGcmSys.AddFunc(0x055bd74d, bind_func(cellGcmGetTiledPitchSize)); - cellGcmSys.AddFunc(0x15bae46b, bind_func(cellGcmInit)); - cellGcmSys.AddFunc(0x21397818, bind_func(cellGcmFlush)); - cellGcmSys.AddFunc(0x21ac3697, bind_func(cellGcmAddressToOffset)); - cellGcmSys.AddFunc(0x3a33c1fd, bind_func(cellGcmFunc15)); - cellGcmSys.AddFunc(0x4ae8d215, bind_func(cellGcmSetFlipMode)); - cellGcmSys.AddFunc(0x5e2ee0f0, bind_func(cellGcmGetDefaultCommandWordSize)); - cellGcmSys.AddFunc(0x72a577ce, bind_func(cellGcmGetFlipStatus)); - cellGcmSys.AddFunc(0x8cdf8c70, bind_func(cellGcmGetDefaultSegmentWordSize)); - cellGcmSys.AddFunc(0x9ba451e4, bind_func(cellGcmSetDefaultFifoSize)); - cellGcmSys.AddFunc(0xa53d12ae, bind_func(cellGcmSetDisplayBuffer)); - cellGcmSys.AddFunc(0xa547adde, bind_func(cellGcmGetControlRegister)); - cellGcmSys.AddFunc(0xb2e761d4, bind_func(cellGcmResetFlipStatus)); - cellGcmSys.AddFunc(0xd8f88e1a, bind_func(cellGcmSetFlipCommandWithWaitLabel)); - cellGcmSys.AddFunc(0xe315a0b2, bind_func(cellGcmGetConfiguration)); - cellGcmSys.AddFunc(0x9dc04436, bind_func(cellGcmBindZcull)); + return CELL_EFAULT; } -} _cellGcmSys_init; + + Memory.Write32(id_addr, Emu.GetGSManager().GetRender().m_gcm_current_buffer); + + return CELL_OK; +} + +void cellGcmSetDefaultCommandBuffer() +{ + cellGcmSys.Warning("cellGcmSetDefaultCommandBuffer()"); + Memory.Write32(Emu.GetGSManager().GetRender().m_ctxt_addr, gcm_info.context_addr); +} + +void cellGcmSetFlipStatus() +{ + cellGcmSys.Warning("cellGcmSetFlipStatus()"); + + Emu.GetGSManager().GetRender().m_flip_status = 0; +} + +int cellGcmSetTileInfo(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 comp, u16 base, u8 bank) +{ + cellGcmSys.Warning("cellGcmSetTileInfo(index=%d, location=%d, offset=%d, size=%d, pitch=%d, comp=%d, base=%d, bank=%d)", + index, location, offset, size, pitch, comp, base, bank); + + if(index >= g_tiles_count || base >= 800 || bank >= 4) + { + return CELL_GCM_ERROR_INVALID_VALUE; + } + + if(offset & 0xffff || size & 0xffff || pitch & 0xf) + { + return CELL_GCM_ERROR_INVALID_ALIGNMENT; + } + + if(location >= 2 || (comp != 0 && (comp < 7 || comp > 12))) + { + return CELL_GCM_ERROR_INVALID_ENUM; + } + + if(comp) + { + cellGcmSys.Error("cellGcmSetTileInfo: bad comp! (%d)", comp); + } + + auto& tile = Emu.GetGSManager().GetRender().m_tiles[index]; + tile.m_location = location; + tile.m_offset = offset; + tile.m_size = size; + tile.m_pitch = pitch; + tile.m_comp = comp; + tile.m_base = base; + tile.m_bank = bank; + Memory.WriteData(Emu.GetGSManager().GetRender().m_tiles_addr + sizeof(CellGcmTileInfo) * index, tile.Pack()); + + return CELL_OK; +} + +int cellGcmBindTile(u8 index) +{ + cellGcmSys.Warning("cellGcmBindTile(index=%d)", index); + + if(index >= g_tiles_count) + { + return CELL_GCM_ERROR_INVALID_VALUE; + } + + auto& tile = Emu.GetGSManager().GetRender().m_tiles[index]; + tile.m_binded = true; + + return CELL_OK; +} + +int cellGcmUnbindTile(u8 index) +{ + cellGcmSys.Warning("cellGcmUnbindTile(index=%d)", index); + + if(index >= g_tiles_count) + { + return CELL_GCM_ERROR_INVALID_VALUE; + } + + auto& tile = Emu.GetGSManager().GetRender().m_tiles[index]; + tile.m_binded = false; + + return CELL_OK; +} + +u32 cellGcmGetTileInfo() +{ + cellGcmSys.Warning("cellGcmGetTileInfo()"); + return Emu.GetGSManager().GetRender().m_tiles_addr; +} + +int cellGcmInitDefaultFifoMode(int mode) +{ + cellGcmSys.Warning("cellGcmInitDefaultFifoMode(mode=%d)", mode); + return CELL_OK; +} + +u32 cellGcmGetReportDataAddressLocation(u8 location, u32 index) +{ + ConLog.Warning("cellGcmGetReportDataAddressLocation(location=%d, index=%d)", location, index); + return Emu.GetGSManager().GetRender().m_report_main_addr; +} + +void cellGcmSys_init() +{ + cellGcmSys.AddFunc(0x055bd74d, cellGcmGetTiledPitchSize); + cellGcmSys.AddFunc(0x15bae46b, cellGcmInit); + cellGcmSys.AddFunc(0x21397818, cellGcmSetFlipCommand); + cellGcmSys.AddFunc(0x21ac3697, cellGcmAddressToOffset); + cellGcmSys.AddFunc(0x3a33c1fd, cellGcmFunc15); + cellGcmSys.AddFunc(0x4ae8d215, cellGcmSetFlipMode); + cellGcmSys.AddFunc(0x63441cb4, cellGcmMapEaIoAddress); + cellGcmSys.AddFunc(0x5e2ee0f0, cellGcmGetDefaultCommandWordSize); + cellGcmSys.AddFunc(0x72a577ce, cellGcmGetFlipStatus); + cellGcmSys.AddFunc(0x8cdf8c70, cellGcmGetDefaultSegmentWordSize); + cellGcmSys.AddFunc(0x9ba451e4, cellGcmSetDefaultFifoSize); + cellGcmSys.AddFunc(0xa53d12ae, cellGcmSetDisplayBuffer); + cellGcmSys.AddFunc(0xa547adde, cellGcmGetControlRegister); + cellGcmSys.AddFunc(0xb2e761d4, cellGcmResetFlipStatus); + cellGcmSys.AddFunc(0xd8f88e1a, cellGcmSetFlipCommandWithWaitLabel); + cellGcmSys.AddFunc(0xe315a0b2, cellGcmGetConfiguration); + cellGcmSys.AddFunc(0x9dc04436, cellGcmBindZcull); + cellGcmSys.AddFunc(0xd34a420d, cellGcmSetZcull); + cellGcmSys.AddFunc(0xd9a0a879, cellGcmGetZcullInfo); + cellGcmSys.AddFunc(0x5a41c10f, cellGcmGetTimeStamp); + cellGcmSys.AddFunc(0xd9b7653e, cellGcmUnbindTile); + cellGcmSys.AddFunc(0xa75640e8, cellGcmUnbindZcull); + cellGcmSys.AddFunc(0xa41ef7e8, cellGcmSetFlipHandler); + cellGcmSys.AddFunc(0xa114ec67, cellGcmMapMainMemory); + cellGcmSys.AddFunc(0xf80196c1, cellGcmGetLabelAddress); + cellGcmSys.AddFunc(0x107bf3a1, cellGcmInitCursor); + cellGcmSys.AddFunc(0x1a0de550, cellGcmSetCursorPosition); + cellGcmSys.AddFunc(0x69c6cc82, cellGcmSetCursorDisable); + cellGcmSys.AddFunc(0xa91b0402, cellGcmSetVBlankHandler); + cellGcmSys.AddFunc(0xbd2fa0a7, cellGcmUpdateCursor); + cellGcmSys.AddFunc(0xc47d0812, cellGcmSetCursorEnable); + cellGcmSys.AddFunc(0xf9bfdc72, cellGcmSetCursorImageOffset); + cellGcmSys.AddFunc(0x0e6b0dae, cellGcmGetDisplayInfo); + cellGcmSys.AddFunc(0x93806525, cellGcmGetCurrentDisplayBufferId); + cellGcmSys.AddFunc(0xbc982946, cellGcmSetDefaultCommandBuffer); + cellGcmSys.AddFunc(0xa47c09ff, cellGcmSetFlipStatus); + cellGcmSys.AddFunc(0xbd100dbc, cellGcmSetTileInfo); + cellGcmSys.AddFunc(0x4524cccd, cellGcmBindTile); + cellGcmSys.AddFunc(0x0b4b62d5, cellGcmSetPrepareFlip); + cellGcmSys.AddFunc(0x657571f7, cellGcmGetTileInfo); + cellGcmSys.AddFunc(0xcaabd992, cellGcmInitDefaultFifoMode); + cellGcmSys.AddFunc(0x8572bce2, cellGcmGetReportDataAddressLocation); +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp new file mode 100644 index 0000000000..beaa904bad --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -0,0 +1,39 @@ +#include "stdafx.h" +#include "Emu/SysCalls/SysCalls.h" +#include "Emu/SysCalls/SC_FUNC.h" +#include "Emu/GS/GCM.h" + +void cellRecs_init(); +Module cellRecs(0x001f, cellRecs_init); + +int cellRescSetConvertAndFlip(s32 indx) +{ + cellRecs.Log("cellRescSetConvertAndFlip(indx=0x%x)", indx); + Emu.GetGSManager().GetRender().Draw(); + + return CELL_OK; +} + +int cellRescSetWaitFlip() +{ + return CELL_OK; +} + +int cellRescSetFlipHandler(u32 handler_addr) +{ + cellRecs.Warning("cellRescSetFlipHandler(handler_addr=%d)", handler_addr); + if(!Memory.IsGoodAddr(handler_addr) && handler_addr != 0) + { + return CELL_EFAULT; + } + + Emu.GetGSManager().GetRender().m_flip_handler.SetAddr(handler_addr); + return 0; +} + +void cellRecs_init() +{ + cellRecs.AddFunc(0x25c107e6, cellRescSetConvertAndFlip); + cellRecs.AddFunc(0x0d3c22ce, cellRescSetWaitFlip); + cellRecs.AddFunc(0x2ea94661, cellRescSetFlipHandler); +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp new file mode 100644 index 0000000000..3f18a17da7 --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp @@ -0,0 +1,95 @@ +#include "stdafx.h" +#include "Emu/SysCalls/Modules.h" +#include "Emu/SysCalls/SC_FUNC.h" + +void cellSysmodule_init(); +Module cellSysmodule("cellSysmodule", cellSysmodule_init); + +enum +{ + CELL_SYSMODULE_LOADED = CELL_OK, + CELL_SYSMODULE_ERROR_DUPLICATED = 0x80012001, + CELL_SYSMODULE_ERROR_UNKNOWN = 0x80012002, + CELL_SYSMODULE_ERROR_UNLOADED = 0x80012003, + CELL_SYSMODULE_ERROR_INVALID_MEMCONTAINER = 0x80012004, + CELL_SYSMODULE_ERROR_FATAL = 0x800120ff, +}; + +int cellSysmoduleInitialize() +{ + cellSysmodule.Log("cellSysmoduleInitialize()"); + return CELL_OK; +} + +int cellSysmoduleFinalize() +{ + cellSysmodule.Log("cellSysmoduleFinalize()"); + return CELL_OK; +} + +int cellSysmoduleSetMemcontainer(u32 ct_id) +{ + cellSysmodule.Warning("TODO: cellSysmoduleSetMemcontainer(ct_id=0x%x)", ct_id); + return CELL_OK; +} + +int cellSysmoduleLoadModule(u16 id) +{ + cellSysmodule.Warning("cellSysmoduleLoadModule(id=0x%04x)", id); + Module* m = GetModuleById(id); + + if(!m) + { + return CELL_SYSMODULE_ERROR_UNKNOWN; + } + + if(m->IsLoaded()) + { + return CELL_SYSMODULE_ERROR_DUPLICATED; + } + + m->Load(); + return CELL_OK; +} + +int cellSysmoduleUnloadModule(u16 id) +{ + cellSysmodule.Warning("cellSysmoduleUnloadModule(id=0x%04x)", id); + Module* m = GetModuleById(id); + + if(!m) + { + return CELL_SYSMODULE_ERROR_UNKNOWN; + } + + if(!m->IsLoaded()) + { + return CELL_SYSMODULE_ERROR_UNLOADED; + } + + m->UnLoad(); + return CELL_OK; +} + +int cellSysmoduleIsLoaded(u16 id) +{ + cellSysmodule.Warning("cellSysmoduleIsLoaded(id=0x%04x)", id); + Module* m = GetModuleById(id); + + if(!m) + { + return CELL_SYSMODULE_ERROR_UNKNOWN; + } + + return m->IsLoaded() ? CELL_SYSMODULE_LOADED : CELL_SYSMODULE_ERROR_UNLOADED; +} + +void cellSysmodule_init() +{ + cellSysmodule.AddFunc(0x63ff6ff9, cellSysmoduleInitialize); + cellSysmodule.AddFunc(0x96c07adf, cellSysmoduleFinalize); + cellSysmodule.AddFunc(0xa193143c, cellSysmoduleSetMemcontainer); + cellSysmodule.AddFunc(0x32267a31, cellSysmoduleLoadModule); + cellSysmodule.AddFunc(0x112a5ee9, cellSysmoduleUnloadModule); + cellSysmodule.AddFunc(0x5a59e258, cellSysmoduleIsLoaded); +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp new file mode 100644 index 0000000000..1602f4fc52 --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -0,0 +1,240 @@ +#include "stdafx.h" +#include "Emu/SysCalls/SysCalls.h" +#include "Emu/SysCalls/SC_FUNC.h" + +enum +{ + CELL_SYSUTIL_SYSTEMPARAM_ID_LANG = 0x0111, + CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN = 0x0112, + CELL_SYSUTIL_SYSTEMPARAM_ID_DATE_FORMAT = 0x0114, + CELL_SYSUTIL_SYSTEMPARAM_ID_TIME_FORMAT = 0x0115, + CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE = 0x0116, + CELL_SYSUTIL_SYSTEMPARAM_ID_SUMMERTIME = 0x0117, + CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL = 0x0121, + CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL0_RESTRICT = 0x0123, + CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USER_HAS_NP_ACCOUNT = 0x0141, + CELL_SYSUTIL_SYSTEMPARAM_ID_CAMERA_PLFREQ = 0x0151, + CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_RUMBLE = 0x0152, + CELL_SYSUTIL_SYSTEMPARAM_ID_KEYBOARD_TYPE = 0x0153, + CELL_SYSUTIL_SYSTEMPARAM_ID_JAPANESE_KEYBOARD_ENTRY_METHOD = 0x0154, + CELL_SYSUTIL_SYSTEMPARAM_ID_CHINESE_KEYBOARD_ENTRY_METHOD = 0x0155, + CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_AUTOOFF = 0x0156, +}; + +enum +{ + CELL_SYSUTIL_LANG_JAPANESE = 0, + CELL_SYSUTIL_LANG_ENGLISH_US = 1, + CELL_SYSUTIL_LANG_FRENCH = 2, + CELL_SYSUTIL_LANG_SPANISH = 3, + CELL_SYSUTIL_LANG_GERMAN = 4, + CELL_SYSUTIL_LANG_ITALIAN = 5, + CELL_SYSUTIL_LANG_DUTCH = 6, + CELL_SYSUTIL_LANG_PORTUGUESE_PT = 7, + CELL_SYSUTIL_LANG_RUSSIAN = 8, + CELL_SYSUTIL_LANG_KOREAN = 9, + CELL_SYSUTIL_LANG_CHINESE_T = 10, + CELL_SYSUTIL_LANG_CHINESE_S = 11, + CELL_SYSUTIL_LANG_FINNISH = 12, + CELL_SYSUTIL_LANG_SWEDISH = 13, + CELL_SYSUTIL_LANG_DANISH = 14, + CELL_SYSUTIL_LANG_NORWEGIAN = 15, + CELL_SYSUTIL_LANG_POLISH = 16, + CELL_SYSUTIL_LANG_PORTUGUESE_BR = 17, + CELL_SYSUTIL_LANG_ENGLISH_GB = 18, +}; + +enum +{ + CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CIRCLE = 0, + CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CROSS = 1, +}; + +enum +{ + CELL_SYSUTIL_DATE_FMT_YYYYMMDD = 0, + CELL_SYSUTIL_DATE_FMT_DDMMYYYY = 1, + CELL_SYSUTIL_DATE_FMT_MMDDYYYY = 2, +}; + +enum +{ + CELL_SYSUTIL_TIME_FMT_CLOCK12 = 0, + CELL_SYSUTIL_TIME_FMT_CLOCK24 = 1, +}; + +enum +{ + CELL_SYSUTIL_GAME_PARENTAL_OFF = 0, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL01 = 1, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL02 = 2, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL03 = 3, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL04 = 4, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL05 = 5, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL06 = 6, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL07 = 7, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL08 = 8, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL09 = 9, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL10 = 10, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL11 = 11, +}; + +enum +{ + CELL_SYSUTIL_GAME_PARENTAL_LEVEL0_RESTRICT_OFF = 0, + CELL_SYSUTIL_GAME_PARENTAL_LEVEL0_RESTRICT_ON = 1, +}; + +enum +{ + CELL_SYSUTIL_CAMERA_PLFREQ_DISABLED = 0, + CELL_SYSUTIL_CAMERA_PLFREQ_50HZ = 1, + CELL_SYSUTIL_CAMERA_PLFREQ_60HZ = 2, + CELL_SYSUTIL_CAMERA_PLFREQ_DEVCIE_DEPEND = 4, +}; + +enum +{ + CELL_SYSUTIL_PAD_RUMBLE_OFF = 0, + CELL_SYSUTIL_PAD_RUMBLE_ON = 1, +}; + +enum +{ + CELL_KB_MAPPING_101, + CELL_KB_MAPPING_106, + CELL_KB_MAPPING_106_KANA, + CELL_KB_MAPPING_GERMAN_GERMANY, + CELL_KB_MAPPING_SPANISH_SPAIN, + CELL_KB_MAPPING_FRENCH_FRANCE, + CELL_KB_MAPPING_ITALIAN_ITALY, + CELL_KB_MAPPING_DUTCH_NETHERLANDS, + CELL_KB_MAPPING_PORTUGUESE_PORTUGAL, + CELL_KB_MAPPING_RUSSIAN_RUSSIA, + CELL_KB_MAPPING_ENGLISH_UK, + CELL_KB_MAPPING_KOREAN_KOREA, + CELL_KB_MAPPING_NORWEGIAN_NORWAY, + CELL_KB_MAPPING_FINNISH_FINLAND, + CELL_KB_MAPPING_DANISH_DENMARK, + CELL_KB_MAPPING_SWEDISH_SWEDEN, + CELL_KB_MAPPING_CHINESE_TRADITIONAL, + CELL_KB_MAPPING_CHINESE_SIMPLIFIED, + CELL_KB_MAPPING_SWISS_FRENCH_SWITZERLAND, + CELL_KB_MAPPING_SWISS_GERMAN_SWITZERLAND, + CELL_KB_MAPPING_CANADIAN_FRENCH_CANADA, + CELL_KB_MAPPING_BELGIAN_BELGIUM, + CELL_KB_MAPPING_POLISH_POLAND, + CELL_KB_MAPPING_PORTUGUESE_BRAZIL, +}; + +void cellSysutil_init(); +Module cellSysutil(0x0015, cellSysutil_init); + +void cellVideoOutGetDeviceInfo() +{ + UNIMPLEMENTED_FUNC(cellSysutil); +} + +int cellSysutilGetSystemParamInt(int id, u32 value_addr) +{ + cellSysutil.Log("cellSysutilGetSystemParamInt(id=0x%x, value_addr=0x%x)", id, value_addr); + + if(!Memory.IsGoodAddr(value_addr)) + { + return CELL_EFAULT; + } + + switch(id) + { + case CELL_SYSUTIL_SYSTEMPARAM_ID_LANG: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_LANG"); + Memory.Write32(value_addr, CELL_SYSUTIL_LANG_ENGLISH_US); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN"); + Memory.Write32(value_addr, CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CROSS); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_DATE_FORMAT: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_DATE_FORMAT"); + Memory.Write32(value_addr, CELL_SYSUTIL_DATE_FMT_DDMMYYYY); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_TIME_FORMAT: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_TIME_FORMAT"); + Memory.Write32(value_addr, CELL_SYSUTIL_TIME_FMT_CLOCK24); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE"); + Memory.Write32(value_addr, 3); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_SUMMERTIME: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_SUMMERTIME"); + Memory.Write32(value_addr, 1); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL"); + Memory.Write32(value_addr, CELL_SYSUTIL_GAME_PARENTAL_OFF); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL0_RESTRICT: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL0_RESTRICT"); + Memory.Write32(value_addr, CELL_SYSUTIL_GAME_PARENTAL_LEVEL0_RESTRICT_OFF); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USER_HAS_NP_ACCOUNT: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USER_HAS_NP_ACCOUNT"); + Memory.Write32(value_addr, 0); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_CAMERA_PLFREQ: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_CAMERA_PLFREQ"); + Memory.Write32(value_addr, CELL_SYSUTIL_CAMERA_PLFREQ_DISABLED); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_RUMBLE: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_RUMBLE"); + Memory.Write32(value_addr, CELL_SYSUTIL_PAD_RUMBLE_OFF); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_KEYBOARD_TYPE: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_KEYBOARD_TYPE"); + Memory.Write32(value_addr, 0); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_JAPANESE_KEYBOARD_ENTRY_METHOD: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_JAPANESE_KEYBOARD_ENTRY_METHOD"); + Memory.Write32(value_addr, 0); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_CHINESE_KEYBOARD_ENTRY_METHOD: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_CHINESE_KEYBOARD_ENTRY_METHOD"); + Memory.Write32(value_addr, 0); + break; + + case CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_AUTOOFF: + cellSysutil.Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_AUTOOFF"); + Memory.Write32(value_addr, 0); + break; + + default: + return CELL_EINVAL; + } + + return CELL_OK; +} + +void cellSysutil_init() +{ + cellSysutil.AddFunc(0x0bae8772, cellVideoOutConfigure); + cellSysutil.AddFunc(0x189a74da, cellSysutilCheckCallback); + cellSysutil.AddFunc(0x1e930eef, cellVideoOutGetDeviceInfo); + cellSysutil.AddFunc(0x40e895d3, cellSysutilGetSystemParamInt); + cellSysutil.AddFunc(0x887572d5, cellVideoOutGetState); + cellSysutil.AddFunc(0x9d98afa0, cellSysutilRegisterCallback); + cellSysutil.AddFunc(0xe558748d, cellVideoOutGetResolution); +} \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp index 2d8102dda6..ab26b6d773 100644 --- a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp @@ -2,7 +2,8 @@ #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" -Module sysPrxForUser("sysPrxForUser", -1); +void sysPrxForUser_init(); +Module sysPrxForUser("sysPrxForUser", sysPrxForUser_init); void sys_initialize_tls() { @@ -21,6 +22,12 @@ s64 sys_process_at_Exitspawn() return 0; } +int sys_spu_printf_initialize(int a1, int a2, int a3, int a4, int a5) +{ + sysPrxForUser.Warning("sys_spu_printf_initialize(0x%x, 0x%x, 0x%x, 0x%x, 0x%x)", a1, a2, a3, a4, a5); + return 0; +} + s64 sys_prx_register_library() { sysPrxForUser.Error("sys_prx_register_library()"); @@ -40,36 +47,36 @@ s64 sys_strlen(u32 addr) return str.Len(); } -struct _sysPrxForUser_init +void sysPrxForUser_init() { - _sysPrxForUser_init() - { - sysPrxForUser.AddFunc(0x744680a2, bind_func(sys_initialize_tls)); + sysPrxForUser.AddFunc(0x744680a2, sys_initialize_tls); + + sysPrxForUser.AddFunc(0x2f85c0ef, sys_lwmutex_create); + sysPrxForUser.AddFunc(0xc3476d0c, sys_lwmutex_destroy); + sysPrxForUser.AddFunc(0x1573dc3f, sys_lwmutex_lock); + sysPrxForUser.AddFunc(0xaeb78725, sys_lwmutex_trylock); + sysPrxForUser.AddFunc(0x1bc200f4, sys_lwmutex_unlock); - sysPrxForUser.AddFunc(0x2f85c0ef, bind_func(sys_lwmutex_create)); - sysPrxForUser.AddFunc(0xc3476d0c, bind_func(sys_lwmutex_destroy)); - sysPrxForUser.AddFunc(0x1573dc3f, bind_func(sys_lwmutex_lock)); - sysPrxForUser.AddFunc(0xaeb78725, bind_func(sys_lwmutex_trylock)); - sysPrxForUser.AddFunc(0x1bc200f4, bind_func(sys_lwmutex_unlock)); + sysPrxForUser.AddFunc(0x8461e528, sys_time_get_system_time); - sysPrxForUser.AddFunc(0x8461e528, bind_func(sys_time_get_system_time)); + sysPrxForUser.AddFunc(0xe6f2c1e7, sys_process_exit); + sysPrxForUser.AddFunc(0x2c847572, sys_process_atexitspawn); + sysPrxForUser.AddFunc(0x96328741, sys_process_at_Exitspawn); - sysPrxForUser.AddFunc(0xe6f2c1e7, bind_func(sys_process_exit)); - sysPrxForUser.AddFunc(0x2c847572, bind_func(sys_process_atexitspawn)); - sysPrxForUser.AddFunc(0x96328741, bind_func(sys_process_at_Exitspawn)); + sysPrxForUser.AddFunc(0x24a1ea07, sys_ppu_thread_create); + sysPrxForUser.AddFunc(0x350d454e, sys_ppu_thread_get_id); + sysPrxForUser.AddFunc(0xaff080a4, sys_ppu_thread_exit); + sysPrxForUser.AddFunc(0xa3e3be68, sys_ppu_thread_once); - sysPrxForUser.AddFunc(0x24a1ea07, bind_func(sys_ppu_thread_create)); - sysPrxForUser.AddFunc(0x350d454e, bind_func(sys_ppu_thread_get_id)); - sysPrxForUser.AddFunc(0xaff080a4, bind_func(sys_ppu_thread_exit)); + sysPrxForUser.AddFunc(0x45fe2fce, sys_spu_printf_initialize); - sysPrxForUser.AddFunc(0x42b23552, bind_func(sys_prx_register_library)); - sysPrxForUser.AddFunc(0xa2c7ba64, bind_func(sys_prx_exitspawn_with_level)); + sysPrxForUser.AddFunc(0x42b23552, sys_prx_register_library); + sysPrxForUser.AddFunc(0xa2c7ba64, sys_prx_exitspawn_with_level); - sysPrxForUser.AddFunc(0x2d36462b, bind_func(sys_strlen)); + sysPrxForUser.AddFunc(0x2d36462b, sys_strlen); - sysPrxForUser.AddFunc(0x35168520, bind_func(sys_heap_malloc)); - //sysPrxForUser.AddFunc(0xaede4b03, bind_func(sys_heap_free>); - //sysPrxForUser.AddFunc(0x8a561d92, bind_func(sys_heap_delete_heap>); - sysPrxForUser.AddFunc(0xb2fcf2c8, bind_func(sys_heap_create_heap)); - } -} sysPrxForUser_init; \ No newline at end of file + sysPrxForUser.AddFunc(0x35168520, sys_heap_malloc); + //sysPrxForUser.AddFunc(0xaede4b03, sys_heap_free); + //sysPrxForUser.AddFunc(0x8a561d92, sys_heap_delete_heap); + sysPrxForUser.AddFunc(0xb2fcf2c8, sys_heap_create_heap); +} diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index 6c0c9f0633..c4d4736cff 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -2,25 +2,23 @@ #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" -Module sys_fs("sys_fs", 0x000e); +void sys_fs_init(); +Module sys_fs(0x000e, sys_fs_init); -struct _sys_fs_init +void sys_fs_init() { - _sys_fs_init() - { - sys_fs.AddFunc(0x718bf5f8, bind_func(cellFsOpen)); - sys_fs.AddFunc(0x4d5ff8e2, bind_func(cellFsRead)); - sys_fs.AddFunc(0xecdcf2ab, bind_func(cellFsWrite)); - sys_fs.AddFunc(0x2cb51f0d, bind_func(cellFsClose)); - sys_fs.AddFunc(0x3f61245c, bind_func(cellFsOpendir)); - sys_fs.AddFunc(0x5c74903d, bind_func(cellFsReaddir)); - sys_fs.AddFunc(0xff42dcc3, bind_func(cellFsClosedir)); - sys_fs.AddFunc(0x7de6dced, bind_func(cellFsStat)); - sys_fs.AddFunc(0xef3efa34, bind_func(cellFsFstat)); - sys_fs.AddFunc(0xba901fe6, bind_func(cellFsMkdir)); - sys_fs.AddFunc(0xf12eecc8, bind_func(cellFsRename)); - sys_fs.AddFunc(0x2796fdf3, bind_func(cellFsRmdir)); - sys_fs.AddFunc(0x7f4677a8, bind_func(cellFsUnlink)); - sys_fs.AddFunc(0xa397d042, bind_func(cellFsLseek)); - } -} sys_fs_init; \ No newline at end of file + sys_fs.AddFunc(0x718bf5f8, cellFsOpen); + sys_fs.AddFunc(0x4d5ff8e2, cellFsRead); + sys_fs.AddFunc(0xecdcf2ab, cellFsWrite); + sys_fs.AddFunc(0x2cb51f0d, cellFsClose); + sys_fs.AddFunc(0x3f61245c, cellFsOpendir); + sys_fs.AddFunc(0x5c74903d, cellFsReaddir); + sys_fs.AddFunc(0xff42dcc3, cellFsClosedir); + sys_fs.AddFunc(0x7de6dced, cellFsStat); + sys_fs.AddFunc(0xef3efa34, cellFsFstat); + sys_fs.AddFunc(0xba901fe6, cellFsMkdir); + sys_fs.AddFunc(0xf12eecc8, cellFsRename); + sys_fs.AddFunc(0x2796fdf3, cellFsRmdir); + sys_fs.AddFunc(0x7f4677a8, cellFsUnlink); + sys_fs.AddFunc(0xa397d042, cellFsLseek); +} diff --git a/rpcs3/Emu/SysCalls/Modules/sys_io.cpp b/rpcs3/Emu/SysCalls/Modules/sys_io.cpp index 7bea344fdb..385f5c99d1 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_io.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_io.cpp @@ -2,19 +2,17 @@ #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" -Module sys_io("sys_io", 0x0017); +void sys_io_init(); +Module sys_io(0x0017, sys_io_init); -struct _sys_io_init +void sys_io_init() { - _sys_io_init() - { - sys_io.AddFunc(0x1cf98800, bind_func(cellPadInit)); - sys_io.AddFunc(0x4d9b75d5, bind_func(cellPadEnd)); - sys_io.AddFunc(0x0d5f2c14, bind_func(cellPadClearBuf)); - sys_io.AddFunc(0x8b72cda1, bind_func(cellPadGetData)); - sys_io.AddFunc(0x6bc09c61, bind_func(cellPadGetDataExtra)); - sys_io.AddFunc(0xf65544ee, bind_func(cellPadSetActDirect)); - sys_io.AddFunc(0xa703a51d, bind_func(cellPadGetInfo2)); - sys_io.AddFunc(0x578e3c98, bind_func(cellPadSetPortSetting)); - } -} sys_io_init; \ No newline at end of file + sys_io.AddFunc(0x1cf98800, cellPadInit); + sys_io.AddFunc(0x4d9b75d5, cellPadEnd); + sys_io.AddFunc(0x0d5f2c14, cellPadClearBuf); + sys_io.AddFunc(0x8b72cda1, cellPadGetData); + sys_io.AddFunc(0x6bc09c61, cellPadGetDataExtra); + sys_io.AddFunc(0xf65544ee, cellPadSetActDirect); + sys_io.AddFunc(0xa703a51d, cellPadGetInfo2); + sys_io.AddFunc(0x578e3c98, cellPadSetPortSetting); +} diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index b81c86d8c2..e76bf979e3 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -1,137 +1,10 @@ #include "stdafx.h" #include "SysCalls.h" +#include "Modules.h" #include "SC_FUNC.h" -#include -ArrayF g_modules_funcs_list; -ArrayF g_modules_list; - -bool IsLoadedFunc(u32 id) -{ - for(u32 i=0; i m_funcs_list; - - Module(const char* name, u16 id); - - void Load(); - void UnLoad(); - bool Load(u32 id); - bool UnLoad(u32 id); - - void SetLoaded(bool loaded = true) - { - m_is_loaded = loaded; - } - - bool IsLoaded() const - { - return m_is_loaded; - } - - u16 GetID() const - { - return m_id; - } - - wxString GetName() const - { - return m_name; - } - -public: - void Log(const u32 id, wxString fmt, ...) - { -#ifdef SYSCALLS_DEBUG - va_list list; - va_start(list, fmt); - ConLog.Write(GetName() + wxString::Format("[%d]: ", id) + wxString::FormatV(fmt, list)); - va_end(list); -#endif - } - - void Log(wxString fmt, ...) - { -#ifdef SYSCALLS_DEBUG - va_list list; - va_start(list, fmt); - ConLog.Write(GetName() + ": " + wxString::FormatV(fmt, list)); - va_end(list); -#endif - } - - void Warning(const u32 id, wxString fmt, ...) - { -//#ifdef SYSCALLS_DEBUG - va_list list; - va_start(list, fmt); - ConLog.Warning(GetName() + wxString::Format("[%d] warning: ", id) + wxString::FormatV(fmt, list)); - va_end(list); -//#endif - } - - void Warning(wxString fmt, ...) - { -//#ifdef SYSCALLS_DEBUG - va_list list; - va_start(list, fmt); - ConLog.Warning(GetName() + " warning: " + wxString::FormatV(fmt, list)); - va_end(list); -//#endif - } - - void Error(const u32 id, wxString fmt, ...) - { - va_list list; - va_start(list, fmt); - ConLog.Error(GetName() + wxString::Format("[%d] error: ", id) + wxString::FormatV(fmt, list)); - va_end(list); - } - - void Error(wxString fmt, ...) - { - va_list list; - va_start(list, fmt); - ConLog.Error(GetName() + " error: " + wxString::FormatV(fmt, list)); - va_end(list); - } - - bool CheckId(u32 id) const - { - return Emu.GetIdManager().CheckID(id) && !Emu.GetIdManager().GetIDData(id).m_name.Cmp(GetName()); - } - - bool CheckId(u32 id, ID& _id) const - { - return Emu.GetIdManager().CheckID(id) && !(_id = Emu.GetIdManager().GetIDData(id)).m_name.Cmp(GetName()); - } - - template bool CheckId(u32 id, T*& data) - { - ID id_data; - - if(!CheckId(id, id_data)) return false; - - data = (T*)id_data.m_data; - - return true; - } - - u32 GetNewId(void* data = nullptr, u8 flags = 0) - { - return Emu.GetIdManager().GetNewID(GetName(), data, flags); - } - -//protected: - __forceinline void AddFunc(u32 id, func_caller* func) - { - m_funcs_list.Move(new ModuleFunc(id, func)); - } -}; - -static s64 null_function() { return 0; } - -bool IsLoadedFunc(u32 id); -bool CallFunc(u32 id); -bool UnloadFunc(u32 id); -void UnloadModules(); -Module* GetModuleByName(const wxString& name); -Module* GetModuleById(u16 id); +extern bool enable_log; class SysCallBase //Module { @@ -178,22 +24,24 @@ public: void Log(const u32 id, wxString fmt, ...) { -#ifdef SYSCALLS_DEBUG + if(enable_log) + { va_list list; va_start(list, fmt); ConLog.Write(GetName() + wxString::Format("[%d]: ", id) + wxString::FormatV(fmt, list)); va_end(list); -#endif + } } void Log(wxString fmt, ...) { -#ifdef SYSCALLS_DEBUG + if(enable_log) + { va_list list; va_start(list, fmt); ConLog.Write(GetName() + ": " + wxString::FormatV(fmt, list)); va_end(list); -#endif + } } void Warning(const u32 id, wxString fmt, ...) @@ -259,40 +107,19 @@ public: } }; -/* -static bool CmpPath(const wxString& path1, const wxString& path2) -{ - return path1.Len() >= path2.Len() && path1(0, path2.Len()).CmpNoCase(path2) == 0; -} - -static wxString GetWinPath(const wxString& path) -{ - if(!CmpPath(path, "/") && CmpPath(path(1, 1), ":")) return path; - - wxString ppath = wxFileName(Emu.m_path).GetPath() + '/' + wxFileName(path).GetFullName(); - if(wxFileExists(ppath)) return ppath; - - if (CmpPath(path, "/dev_hdd0/") || - CmpPath(path, "/dev_hdd1/") || - CmpPath(path, "/dev_bdvd/") || - CmpPath(path, "/dev_usb001/") || - CmpPath(path, "/ps3_home/") || - CmpPath(path, "/app_home/") || - CmpPath(path, "/dev_flash/") || - CmpPath(path, "/dev_flash2/") || - CmpPath(path, "/dev_flash3/") - ) return wxGetCwd() + path; - - return wxFileName(Emu.m_path).GetPath() + (path[0] == '/' ? path : "/" + path); -} -*/ - //process extern int sys_process_getpid(); extern int sys_process_exit(int errorcode); extern int sys_game_process_exitspawn(u32 path_addr, u32 argv_addr, u32 envp_addr, u32 data, u32 data_size, int prio, u64 flags ); +//sys_event +extern int sys_event_queue_create(u32 equeue_id_addr, u32 attr_addr, u64 event_queue_key, int size); +extern int sys_event_queue_receive(u32 equeue_id, u32 event_addr, u32 timeout); +extern int sys_event_port_create(u32 eport_id_addr, int port_type, u64 name); +extern int sys_event_port_connect_local(u32 event_port_id, u32 event_queue_id); +extern int sys_event_port_send(u32 event_port_id, u64 data1, u64 data2, u64 data3); + //sys_semaphore extern int sys_semaphore_create(u32 sem_addr, u32 attr_addr, int initial_val, int max_val); extern int sys_semaphore_destroy(u32 sem); @@ -333,7 +160,9 @@ extern int sys_ppu_thread_get_stack_information(u32 info_addr); extern int sys_ppu_thread_stop(u32 thread_id); extern int sys_ppu_thread_restart(u32 thread_id); extern int sys_ppu_thread_create(u32 thread_id_addr, u32 entry, u32 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr); -extern int sys_ppu_thread_get_id(); +extern void sys_ppu_thread_once(u32 once_ctrl_addr, u32 entry); +extern int sys_ppu_thread_get_id(const u32 id_addr); +extern int sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq, u64 req, u32 spup_addr); //memory extern int sys_memory_container_create(u32 cid_addr, u32 yield_size); @@ -388,25 +217,7 @@ extern int cellPadGetInfo2(u32 info_addr); extern int cellPadSetPortSetting(u32 port_no, u32 port_setting); //cellGcm -extern int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress); -extern int cellGcmMapMainMemory(u32 address, u32 size, u32 offset_addr); extern int cellGcmCallback(u32 context_addr, u32 count); -extern int cellGcmGetConfiguration(u32 config_addr); -extern int cellGcmAddressToOffset(u32 address, u32 offset_addr); -extern int cellGcmSetDisplayBuffer(u32 id, u32 offset, u32 pitch, u32 width, u32 height); -extern u32 cellGcmGetLabelAddress(u32 index); -extern u32 cellGcmGetControlRegister(); -extern int cellGcmFlush(u32 ctx, u32 id); -extern void cellGcmSetTile(u32 index, u32 location, u32 offset, u32 size, u32 pitch, u32 comp, u32 base, u32 bank); -extern int cellGcmBindTile(u32 index); -extern int cellGcmBindZcull(u32 index, u32 offset, u32 width, u32 height, u32 cullStart, u32 zFormat, u32 aaFormat, u32 zCullDir, u32 zCullFormat, u32 sFunc, u32 sRef, u32 sMask); -extern int cellGcmGetFlipStatus(); -extern int cellGcmResetFlipStatus(); -extern u32 cellGcmGetTiledPitchSize(u32 size); -extern int cellGcmSetFlipMode(u32 mode); -extern u32 cellGcmGetDefaultCommandWordSize(); -extern u32 cellGcmGetDefaultSegmentWordSize(); -extern int cellGcmSetDefaultFifoSize(u32 bufferSize, u32 segmentSize); //sys_tty extern int sys_tty_read(u32 ch, u64 buf_addr, u32 len, u64 preadlen_addr); @@ -421,16 +232,25 @@ extern int sys_heap_create_heap(const u32 heap_addr, const u32 start_addr, const extern int sys_heap_malloc(const u32 heap_addr, const u32 size); //sys_spu +extern int sys_spu_image_open(u32 img_addr, u32 path_addr); +extern int sys_spu_thread_initialize(u32 thread_addr, u32 group, u32 spu_num, u32 img_addr, u32 attr_addr, u32 arg_addr); +extern int sys_spu_thread_set_argument(u32 id, u32 arg_addr); +extern int sys_spu_thread_group_start(u32 id); extern int sys_spu_thread_group_create(u64 id_addr, u32 num, int prio, u64 attr_addr); extern int sys_spu_thread_create(u64 thread_id_addr, u64 entry_addr, u64 arg, int prio, u32 stacksize, u64 flags, u64 threadname_addr); extern int sys_raw_spu_create(u32 id_addr, u32 attr_addr); extern int sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu); +extern int sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type); +extern int sys_spu_thread_read_ls(u32 id, u32 address, u32 value_addr, u32 type); +extern int sys_spu_thread_write_spu_mb(u32 id, u32 value); //sys_time extern int sys_time_get_current_time(u32 sec_addr, u32 nsec_addr); extern s64 sys_time_get_system_time(); extern u64 sys_time_get_timebase_frequency(); +#define UNIMPLEMENTED_FUNC(module) module.Error("Unimplemented function: "__FUNCTION__) + #define SC_ARGS_1 CPU.GPR[3] #define SC_ARGS_2 SC_ARGS_1,CPU.GPR[4] #define SC_ARGS_3 SC_ARGS_2,CPU.GPR[5] @@ -469,7 +289,7 @@ protected: ~SysCalls(); public: - s64 DoSyscall(u32 code); + void DoSyscall(u32 code); s64 DoFunc(const u32 id); }; diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp new file mode 100644 index 0000000000..8aa6f3fa00 --- /dev/null +++ b/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp @@ -0,0 +1,167 @@ +#include "stdafx.h" +#include "Emu/SysCalls/SysCalls.h" +#include "Emu/Cell/SPUThread.h" +#include "Emu/event.h" + +SysCallBase sys_event("sys_event"); + +//128 +int sys_event_queue_create(u32 equeue_id_addr, u32 attr_addr, u64 event_queue_key, int size) +{ + sys_event.Warning("sys_event_queue_create(equeue_id_addr=0x%x, attr_addr=0x%x, event_queue_key=0x%llx, size=%d)", + equeue_id_addr, attr_addr, event_queue_key, size); + + if(size <= 0 || size > 127) + { + return CELL_EINVAL; + } + + if(!Memory.IsGoodAddr(equeue_id_addr, 4) || !Memory.IsGoodAddr(attr_addr, sizeof(sys_event_queue_attr))) + { + return CELL_EFAULT; + } + + auto& attr = (sys_event_queue_attr&)Memory[attr_addr]; + sys_event.Warning("name = %s", attr.name); + sys_event.Warning("type = %d", re(attr.type)); + EventQueue* equeue = new EventQueue(); + equeue->size = size; + equeue->pos = 0; + equeue->type = re(attr.type); + strncpy(equeue->name, attr.name, 8); + Memory.Write32(equeue_id_addr, sys_event.GetNewId(equeue)); + + return CELL_OK; +} + +int sys_event_queue_receive(u32 equeue_id, u32 event_addr, u32 timeout) +{ + sys_event.Warning("sys_event_queue_receive(equeue_id=0x%x, event_addr=0x%x, timeout=0x%x)", + equeue_id, event_addr, timeout); + + if(!sys_event.CheckId(equeue_id)) + { + return CELL_ESRCH; + } + + int result; + auto queue_receive = [&](int status) -> bool + { + if(status == PPCThread_Stopped) + { + result = CELL_ECANCELED; + return false; + } + + EventQueue* equeue = (EventQueue*)Emu.GetIdManager().GetIDData(equeue_id).m_data; + for(int i=0; ipos; ++i) + { + if(!equeue->ports[i]->has_data && equeue->ports[i]->thread) + { + SPUThread* thr = (SPUThread*)equeue->ports[i]->thread; + if(thr->SPU_OutIntr_Mbox.GetCount()) + { + u32 val; + thr->SPU_OutIntr_Mbox.Pop(val); + if(!thr->mfc.SPU_Out_MBox.Pop(val)) val = 0; + equeue->ports[i]->data1 = val; + equeue->ports[i]->data2 = 0; + equeue->ports[i]->data3 = 0; + equeue->ports[i]->has_data = true; + } + } + } + + for(int i=0; ipos; i++) + { + if(equeue->ports[i]->has_data) + { + auto dst = (sys_event_data&)Memory[event_addr]; + + re(dst.source, equeue->ports[i]->name); + re(dst.data1, equeue->ports[i]->data1); + re(dst.data2, equeue->ports[i]->data2); + re(dst.data3, equeue->ports[i]->data3); + + equeue->ports[i]->has_data = false; + + result = CELL_OK; + return false; + } + } + + return true; + }; + + GetCurrentPPUThread().WaitFor(queue_receive); + + return result; +} + +int sys_event_port_create(u32 eport_id_addr, int port_type, u64 name) +{ + sys_event.Warning("sys_event_port_create(eport_id_addr=0x%x, port_type=0x%x, name=0x%llx)", + eport_id_addr, port_type, name); + + if(!Memory.IsGoodAddr(eport_id_addr, 4)) + { + return CELL_EFAULT; + } + + EventPort* eport = new EventPort(); + u32 id = sys_event.GetNewId(eport); + eport->pos = 0; + eport->has_data = false; + eport->name = name ? name : id; + Memory.Write32(eport_id_addr, id); + + return CELL_OK; +} + +int sys_event_port_connect_local(u32 event_port_id, u32 event_queue_id) +{ + sys_event.Warning("sys_event_port_connect_local(event_port_id=0x%x, event_queue_id=0x%x)", + event_port_id, event_queue_id); + + if(!sys_event.CheckId(event_port_id) || !sys_event.CheckId(event_queue_id)) + { + return CELL_ESRCH; + } + + EventPort* eport = (EventPort*)Emu.GetIdManager().GetIDData(event_port_id).m_data; + EventQueue* equeue = (EventQueue*)Emu.GetIdManager().GetIDData(event_queue_id).m_data; + equeue->ports[equeue->pos++] = eport; + eport->queue[eport->pos++] = equeue; + + return CELL_OK; +} + +int sys_event_port_send(u32 event_port_id, u64 data1, u64 data2, u64 data3) +{ + sys_event.Warning("sys_event_port_send(event_port_id=0x%x, data1=0x%llx, data2=0x%llx, data3=0x%llx)", + event_port_id, data1, data2, data3); + + if(!sys_event.CheckId(event_port_id)) + { + return CELL_ESRCH; + } + + EventPort* eport = (EventPort*)Emu.GetIdManager().GetIDData(event_port_id).m_data; + + if(!eport->pos) + { + return CELL_ENOTCONN; + } + + if(eport->has_data) + { + return CELL_EBUSY; + } + + eport->has_data = true; + eport->data1 = data1; + eport->data2 = data2; + eport->data3 = data3; + + return CELL_OK; +} \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp index 55e88107ef..a281671f61 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp @@ -199,9 +199,14 @@ int cellFsWrite(u32 fd, u32 buf_addr, u64 nbytes, u32 nwrite_addr) ID id; if(!sys_fs.CheckId(fd, id)) return CELL_ESRCH; vfsStream& file = *(vfsStream*)id.m_data; + if(Memory.IsGoodAddr(buf_addr) && !Memory.IsGoodAddr(buf_addr, nbytes)) + { + MemoryBlock& block = Memory.GetMemByAddr(buf_addr); + nbytes = block.GetSize() - (buf_addr - block.GetStartAddr()); + } - Memory.Write64NN(nwrite_addr, file.Write(Memory.GetMemFromAddr(buf_addr), nbytes)); - + int count = nbytes ? file.Write(Memory.GetMemFromAddr(buf_addr), nbytes) : 0; + Memory.Write64NN(nwrite_addr, count); return CELL_OK; } @@ -242,7 +247,13 @@ int cellFsStat(const u32 path_addr, const u32 sb_addr) const wxString& path = Memory.ReadString(path_addr); sys_fs.Log("cellFsFstat(path: %s, sb_addr: 0x%x)", path, sb_addr); - if(!wxFileExists(path)) return CELL_ENOENT; + vfsStream* f = Emu.GetVFS().Open(path, vfsRead); + if(!f || !f->IsOpened()) + { + sys_fs.Warning("cellFsFstat: '%s' not found.", path); + Emu.GetVFS().Close(f); + return CELL_ENOENT; + } Lv2FsStat stat; stat.st_mode = @@ -256,7 +267,7 @@ int cellFsStat(const u32 path_addr, const u32 sb_addr) stat.st_atime = 0; //TODO stat.st_mtime = 0; //TODO stat.st_ctime = 0; //TODO - stat.st_size = wxFile(path).Length(); + stat.st_size = f->GetSize(); stat.st_blksize = 4096; mem_class_t stat_c(sb_addr); @@ -269,6 +280,8 @@ int cellFsStat(const u32 path_addr, const u32 sb_addr) stat_c += stat.st_size; stat_c += stat.st_blksize; + Emu.GetVFS().Close(f); + return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_GCM.cpp b/rpcs3/Emu/SysCalls/lv2/SC_GCM.cpp index d01f4e426a..707651a5e8 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_GCM.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_GCM.cpp @@ -3,59 +3,7 @@ #include "Emu/GS/GCM.h" extern Module cellGcmSys; - -CellGcmConfig current_config; -CellGcmContextData current_context; -gcmInfo gcm_info; - -int cellGcmMapMainMemory(u32 address, u32 size, u32 offset_addr) -{ - cellGcmSys.Warning("cellGcmMapMainMemory(address=0x%x,size=0x%x,offset_addr=0x%x)", address, size, offset_addr); - if(!Memory.IsGoodAddr(offset_addr, sizeof(u32))) return CELL_EFAULT; - Memory.Write32(offset_addr, address & 0xffff); - - return CELL_OK; -} - -int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) -{ - cellGcmSys.Log("cellGcmInit(context_addr=0x%x,cmdSize=0x%x,ioSize=0x%x,ioAddress=0x%x)", context_addr, cmdSize, ioSize, ioAddress); - - const u32 local_size = 0xf900000; //TODO - const u32 local_addr = Memory.RSXFBMem.GetStartAddr(); - - current_config.ioSize = re32(ioSize); - current_config.ioAddress = re32(ioAddress); - current_config.localSize = re32(local_size); - current_config.localAddress = re32(local_addr); - current_config.memoryFrequency = re32(650000000); - current_config.coreFrequency = re32(500000000); - - Memory.RSXFBMem.Alloc(local_size); - Memory.RSXCMDMem.Alloc(cmdSize); - - u32 ctx_begin = ioAddress + 0x1000; - u32 ctx_size = 0x6ffc; - current_context.begin = re(ctx_begin); - current_context.end = re(ctx_begin + ctx_size); - current_context.current = current_context.begin; - current_context.callback = re32(Emu.GetRSXCallback() - 4); - - gcm_info.context_addr = Memory.MainMem.Alloc(0x1000); - gcm_info.control_addr = gcm_info.context_addr + 0x40; - - Memory.WriteData(gcm_info.context_addr, current_context); - Memory.Write32(context_addr, gcm_info.context_addr); - - CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; - ctrl.put = 0; - ctrl.get = 0; - ctrl.ref = -1; - - Emu.GetGSManager().GetRender().Init(ctx_begin, ctx_size, gcm_info.control_addr, local_addr); - - return CELL_OK; -} +extern gcmInfo gcm_info; int cellGcmCallback(u32 context_addr, u32 count) { @@ -75,143 +23,3 @@ int cellGcmCallback(u32 context_addr, u32 count) return CELL_OK; } - -int cellGcmGetConfiguration(u32 config_addr) -{ - cellGcmSys.Log("cellGcmGetConfiguration(config_addr=0x%x)", config_addr); - - if(!Memory.IsGoodAddr(config_addr, sizeof(CellGcmConfig))) return CELL_EFAULT; - - Memory.WriteData(config_addr, current_config); - return CELL_OK; -} - -int cellGcmAddressToOffset(u32 address, u32 offset_addr) -{ - cellGcmSys.Log("cellGcmAddressToOffset(address=0x%x,offset_addr=0x%x)", address, offset_addr); - if(!Memory.IsGoodAddr(offset_addr, sizeof(u32))) return CELL_EFAULT; - - Memory.Write32(offset_addr, - Memory.RSXFBMem.IsInMyRange(address) - ? address - Memory.RSXFBMem.GetStartAddr() - : address - re(current_context.begin)); - - return CELL_OK; -} - -int cellGcmSetDisplayBuffer(u32 id, u32 offset, u32 pitch, u32 width, u32 height) -{ - cellGcmSys.Warning("cellGcmSetDisplayBuffer(id=0x%x,offset=0x%x,pitch=%d,width=%d,height=%d)", - id, offset, width ? pitch/width : pitch, width, height); - if(id > 1) return CELL_EINVAL; - - gcmBuffers[id].offset = offset; - gcmBuffers[id].pitch = pitch; - gcmBuffers[id].width = width; - gcmBuffers[id].height = height; - gcmBuffers[id].update = true; - - return CELL_OK; -} - -u32 cellGcmGetLabelAddress(u32 index) -{ - cellGcmSys.Log("cellGcmGetLabelAddress(index=%d)", index); - return Memory.RSXCMDMem.GetStartAddr() + 0x10 * index; -} - -u32 cellGcmGetControlRegister() -{ - cellGcmSys.Log("cellGcmGetControlRegister()"); - - return gcm_info.control_addr; -} - -int cellGcmFlush(u32 ctx, u32 id) -{ - cellGcmSys.Log("cellGcmFlush(ctx=0x%x, id=0x%x)", ctx, id); - if(id > 1) return CELL_EINVAL; - - Emu.GetGSManager().GetRender().Draw(); - - return CELL_OK; -} - -void cellGcmSetTile(u32 index, u32 location, u32 offset, u32 size, u32 pitch, u32 comp, u32 base, u32 bank) -{ - cellGcmSys.Warning("cellGcmSetTile(index=%d, location=%d, offset=0x%x, size=0x%x, pitch=0x%x, comp=0x%x, base=0x%x, bank=0x%x)", - index, location, offset, size, pitch, comp, base, bank); - - //return CELL_OK; -} - -int cellGcmBindTile(u32 index) -{ - cellGcmSys.Warning("TODO: cellGcmBindTile(index=%d)", index); - - return CELL_OK; -} - -int cellGcmBindZcull(u32 index, u32 offset, u32 width, u32 height, u32 cullStart, u32 zFormat, u32 aaFormat, u32 zCullDir, u32 zCullFormat, u32 sFunc, u32 sRef, u32 sMask) -{ - cellGcmSys.Warning("TODO: cellGcmBindZcull(index=%d, offset=0x%x, width=%d, height=%d, cullStart=0x%x, zFormat=0x%x, aaFormat=0x%x, zCullDir=0x%x, zCullFormat=0x%x, sFunc=0x%x, sRef=0x%x, sMask=0x%x)", index, offset, width, height, cullStart, zFormat, aaFormat, zCullDir, zCullFormat, sFunc, sRef, sMask); - - return CELL_OK; -} - -int cellGcmGetFlipStatus() -{ - return Emu.GetGSManager().GetRender().m_flip_status; -} - -int cellGcmResetFlipStatus() -{ - Emu.GetGSManager().GetRender().m_flip_status = 1; - - return CELL_OK; -} - -int cellGcmSetFlipMode(u32 mode) -{ - cellGcmSys.Warning("cellGcmSetFlipMode(mode=%d)", mode); - - switch(mode) - { - case CELL_GCM_DISPLAY_HSYNC: - case CELL_GCM_DISPLAY_VSYNC: - case CELL_GCM_DISPLAY_HSYNC_WITH_NOISE: - Emu.GetGSManager().GetRender().m_flip_mode = mode; - break; - - default: - return CELL_EINVAL; - } - - return CELL_OK; -} - -u32 cellGcmGetTiledPitchSize(u32 size) -{ - //TODO - cellGcmSys.Warning("cellGcmGetTiledPitchSize(size=%d)", size); - - return size; -} - -u32 cellGcmGetDefaultCommandWordSize() -{ - cellGcmSys.Warning("cellGcmGetDefaultCommandWordSize()"); - return 0x400; -} - -u32 cellGcmGetDefaultSegmentWordSize() -{ - cellGcmSys.Warning("cellGcmGetDefaultSegmentWordSize()"); - return 0x100; -} - -int cellGcmSetDefaultFifoSize(u32 bufferSize, u32 segmentSize) -{ - cellGcmSys.Warning("cellGcmSetDefaultFifoSize(bufferSize=0x%x, segmentSize=0x%x)", bufferSize, segmentSize); - return CELL_OK; -} diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp index 99dba6cfca..8177530f34 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp @@ -33,26 +33,15 @@ SysCallBase sc_lwmutex("sys_wmutex"); int sys_lwmutex_create(u64 lwmutex_addr, u64 lwmutex_attr_addr) { + if(!Memory.IsGoodAddr(lwmutex_addr, 4) || !Memory.IsGoodAddr(lwmutex_attr_addr)) + { + return CELL_EFAULT; + } + lwmutex& lmtx = (lwmutex&)Memory[lwmutex_addr]; + lmtx.lock_var.all_info = 0; lwmutex_attr& lmtx_attr = (lwmutex_attr&)Memory[lwmutex_attr_addr]; - //sc_lwmutex.Warning("sys_lwmutex_create(lwmutex_addr = 0x%llx, lwmutex_attr_addr = 0x%llx)", lwmutex_addr, lwmutex_attr_addr); - - lmtx.lock_var.info.owner = 0; - lmtx.lock_var.info.waiter = 0; - - lmtx.attribute = Emu.GetIdManager().GetNewID(wxString::Format("lwmutex[%s]", lmtx_attr.name), nullptr, lwmutex_addr); - /* - ConLog.Write("r3:"); - ConLog.Write("*** lock_var[owner: 0x%x, waiter: 0x%x]", re(lmtx.lock_var.info.owner), re(lmtx.lock_var.info.waiter)); - ConLog.Write("*** attribute: 0x%x", re(lmtx.attribute)); - ConLog.Write("*** recursive_count: 0x%x", re(lmtx.recursive_count)); - ConLog.Write("*** sleep_queue: 0x%x", re(lmtx.sleep_queue)); - ConLog.Write("r4:"); - ConLog.Write("*** attr_protocol: 0x%x", re(lmtx_attr.attr_protocol)); - ConLog.Write("*** attr_recursive: 0x%x", re(lmtx_attr.attr_recursive)); - ConLog.Write("*** name: %s", lmtx_attr.name); - */ return CELL_OK; } @@ -60,39 +49,46 @@ int sys_lwmutex_destroy(u64 lwmutex_addr) { //sc_lwmutex.Warning("sys_lwmutex_destroy(lwmutex_addr = 0x%llx)", lwmutex_addr); - lwmutex& lmtx = (lwmutex&)Memory[lwmutex_addr]; - Emu.GetIdManager().RemoveID(lmtx.attribute); + //lwmutex& lmtx = (lwmutex&)Memory[lwmutex_addr]; + //Emu.GetIdManager().RemoveID(lmtx.attribute); return CELL_OK; } int sys_lwmutex_lock(u64 lwmutex_addr, u64 timeout) { - //sc_lwmutex.Warning("sys_lwmutex_lock(lwmutex_addr = 0x%llx, timeout = 0x%llx)", lwmutex_addr, timeout); - lwmutex& lmtx = (lwmutex&)Memory[lwmutex_addr]; + PPCThread& thr = GetCurrentPPUThread(); + + if(thr.GetId() == re(lmtx.lock_var.info.owner)) + { + re(lmtx.recursive_count, re(lmtx.recursive_count) + 1); + return CELL_OK; + } + if(!lmtx.lock_var.info.owner) { re(lmtx.lock_var.info.owner, GetCurrentPPUThread().GetId()); + re(lmtx.recursive_count, 1); } else if(!lmtx.lock_var.info.waiter) { - re(lmtx.lock_var.info.waiter, GetCurrentPPUThread().GetId()); - while(re(lmtx.lock_var.info.owner) != GetCurrentPPUThread().GetId()) Sleep(1); + thr.Wait(true); + re(lmtx.lock_var.info.waiter, thr.GetId()); } else { - return -1; + ConLog.Warning("lwmutex has waiter!"); + return CELL_EBUSY; } - + return CELL_OK; } int sys_lwmutex_trylock(u64 lwmutex_addr) { //sc_lwmutex.Warning("sys_lwmutex_trylock(lwmutex_addr = 0x%llx)", lwmutex_addr); - lwmutex& lmtx = (lwmutex&)Memory[lwmutex_addr]; if(lmtx.lock_var.info.owner) return CELL_EBUSY; @@ -105,8 +101,21 @@ int sys_lwmutex_unlock(u64 lwmutex_addr) //sc_lwmutex.Warning("sys_lwmutex_unlock(lwmutex_addr = 0x%llx)", lwmutex_addr); lwmutex& lmtx = (lwmutex&)Memory[lwmutex_addr]; - lmtx.lock_var.info.owner = lmtx.lock_var.info.waiter; - lmtx.lock_var.info.waiter = 0; + + re(lmtx.recursive_count, re(lmtx.recursive_count) - 1); + + if(!lmtx.recursive_count) + { + if(lmtx.lock_var.info.owner = lmtx.lock_var.info.waiter) + { + lmtx.lock_var.info.waiter = 0; + PPCThread* thr = Emu.GetCPU().GetThread(lmtx.lock_var.info.owner); + if(thr) + { + thr->Wait(false); + } + } + } return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp index 44981568ac..65e98f195c 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp @@ -1,158 +1,5 @@ #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" -/* -struct MemContiner -{ - u8* continer; - u32 num; - - void Create(u32 size) - { - continer = new u8[size]; - } - - void Delete() - { - if(continer != NULL) free(continer); - } - - ~MemContiner() - { - Delete(); - } -}; - -class MemContiners : private SysCallBase -{ - SysCallsArraysList continers; - -public: - MemContiners() : SysCallBase("MemContainers") - { - } - - u64 AddContiner(const u64 size) - { - const u64 id = continers.Add(); - bool error; - MemContiner& data = *continers.GetDataById(id, &error); - if(error) - { - ConLog.Error("%s error: id [%d] is not found!", module_name, id); - return 0; - } - - data.Create(size); - - return id; - } - - void DeleteContiner(const u64 id) - { - bool error; - MemContiner& data = *continers.GetDataById(id, &error); - if(error) - { - ConLog.Error("%s error: id [%d] is not found!", module_name, id); - return; - } - data.Delete(); - continers.RemoveById(id); - } -}; - -MemContiners continers; -*/ -/* -int SysCalls::lv2MemContinerCreate(PPUThread& CPU) -{ - u64& continer = CPU.GPR[3]; - u32 size = CPU.GPR[4]; - - ConLog.Warning("lv2MemContinerCreate[size: 0x%x]", size); - //continer = continers.AddContiner(size); - return 0; -} - -int SysCalls::lv2MemContinerDestroy(PPUThread& CPU) -{ - u32 container = CPU.GPR[3]; - ConLog.Warning("lv2MemContinerDestroy[container: 0x%x]", container); - //continers.DeleteContiner(container); - return 0; -}*/ -/* -static const u32 max_user_mem = 0x0d500000; //100mb -u32 free_user_mem = max_user_mem; -static u64 addr_user_mem = 0; - -struct MemoryInfo -{ - u32 free_user_mem; - u32 aviable_user_mem; -}; - -enum -{ - SYS_MEMORY_PAGE_SIZE_1M = 0x400, - SYS_MEMORY_PAGE_SIZE_64K = 0x200, -}; - -int SysCalls::sys_memory_allocate(u32 size, u64 flags, u64 alloc_addr) -{ - //int sys_memory_allocate(size_t size, uint64_t flags, sys_addr_t * alloc_addr); - - const u64 size = CPU.GPR[3]; - const u64 flags = CPU.GPR[4]; - const u64 alloc_addr = CPU.GPR[5]; - - ConLog.Write("lv2MemAllocate: size: 0x%llx, flags: 0x%llx, alloc_addr: 0x%llx", size, flags, alloc_addr); - - //u32 addr = 0; - switch(flags) - { - case SYS_MEMORY_PAGE_SIZE_1M: - if(size & 0xfffff) return CELL_EALIGN; - //addr = Memory.Alloc(size, 0x100000); - break; - - case SYS_MEMORY_PAGE_SIZE_64K: - if(size & 0xffff) return CELL_EALIGN; - //addr = Memory.Alloc(size, 0x10000); - break; - - default: return CELL_EINVAL; - } - - u32 num = Memory.MemoryBlocks.GetCount(); - Memory.MemoryBlocks.Add(new MemoryBlock()); - Memory.MemoryBlocks[num].SetRange(Memory.MemoryBlocks[num - 1].GetEndAddr(), size); - - Memory.Write32(alloc_addr, Memory.MemoryBlocks[num].GetStartAddr()); - ConLog.Write("Test..."); - Memory.Write32(Memory.MemoryBlocks[num].GetStartAddr(), 0xfff); - if(Memory.Read32(Memory.MemoryBlocks[num].GetStartAddr()) != 0xfff) - { - ConLog.Write("Test faild"); - } - else - { - ConLog.Write("Test OK"); - Memory.Write32(Memory.MemoryBlocks[num].GetStartAddr(), 0x0); - } - - return CELL_OK; -} - -int SysCalls::sys_memory_get_user_memory_size(PPUThread& CPU) -{ - ConLog.Write("lv2MemGetUserMemorySize: r3=0x%llx", CPU.GPR[3]); - //int sys_memory_get_user_memory_size(sys_memory_info_t * mem_info); - MemoryInfo& memoryinfo = *(MemoryInfo*)Memory.GetMemFromAddr(CPU.GPR[3]); - memoryinfo.aviable_user_mem = Memory.Reverse32(free_user_mem); - memoryinfo.free_user_mem = Memory.Reverse32(free_user_mem); - return CELL_OK; -}*/ SysCallBase sc_mem("memory"); @@ -162,15 +9,51 @@ enum SYS_MEMORY_PAGE_SIZE_64K = 0x200, }; +struct MemoryContainerInfo +{ + u64 addr; + u32 size; + + MemoryContainerInfo(u64 addr, u32 size) + : addr(addr) + , size(size) + { + } +}; + int sys_memory_container_create(u32 cid_addr, u32 yield_size) { - sc_mem.Warning("TODO: sys_memory_container_create(cid_addr=0x%x,yield_size=0x%x)", cid_addr, yield_size); + sc_mem.Warning("sys_memory_container_create(cid_addr=0x%x,yield_size=0x%x)", cid_addr, yield_size); + + if(!Memory.IsGoodAddr(cid_addr, 4)) + { + return CELL_EFAULT; + } + + u64 addr = Memory.Alloc(yield_size, 1); + + if(!addr) + { + return CELL_ENOMEM; + } + + Memory.Write32(cid_addr, sc_mem.GetNewId(new MemoryContainerInfo(addr, yield_size))); return CELL_OK; } int sys_memory_container_destroy(u32 cid) { - sc_mem.Warning("TODO: sys_memory_container_destroy(cid=0x%x)", cid); + sc_mem.Warning("sys_memory_container_destroy(cid=0x%x)", cid); + + MemoryContainerInfo* ct; + + if(!sc_mem.CheckId(cid, ct)) + { + return CELL_ESRCH; + } + + Memory.Free(ct->addr); + Emu.GetIdManager().RemoveID(cid); return CELL_OK; } @@ -212,11 +95,13 @@ int sys_memory_free(u32 start_addr) struct mmapper_info { + u64 addr; u32 size; u32 flags; - mmapper_info(u32 _size, u32 _flags) - : size(_size) + mmapper_info(u64 _addr, u32 _size, u32 _flags) + : addr(_addr) + , size(_size) , flags(_flags) { } @@ -240,7 +125,13 @@ int sys_mmapper_allocate_memory(u32 size, u64 flags, u32 mem_id_addr) sc_mem.Warning("sys_mmapper_allocate_memory(size=0x%x, flags=0x%llx, mem_id_addr=0x%x)", size, flags, mem_id_addr); if(!Memory.IsGoodAddr(mem_id_addr)) return CELL_EFAULT; - Memory.Write32(mem_id_addr, sc_mem.GetNewId(new mmapper_info(size, flags))); + + u64 addr = Memory.Alloc(size, 1); + + if(!addr) + return CELL_ENOMEM; + + Memory.Write32(mem_id_addr, sc_mem.GetNewId(new mmapper_info(addr, size, flags))); return CELL_OK; } @@ -252,6 +143,10 @@ int sys_mmapper_map_memory(u32 start_addr, u32 mem_id, u64 flags) mmapper_info* info; if(!sc_mem.CheckId(mem_id, info)) return CELL_ESRCH; + if(!Memory.Map(start_addr, info->addr, info->size)) + { + sc_mem.Error("sys_mmapper_map_memory failed!"); + } //Memory.MemoryBlocks.Add((new MemoryBlock())->SetRange(start_addr, info->size)); return CELL_OK; diff --git a/rpcs3/Emu/SysCalls/lv2/SC_PPU_Thread.cpp b/rpcs3/Emu/SysCalls/lv2/SC_PPU_Thread.cpp index eddf0ec52e..fddb80a40e 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_PPU_Thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_PPU_Thread.cpp @@ -3,28 +3,45 @@ extern Module sysPrxForUser; -#define PPU_THREAD_ID_INVALID 0xFFFFFFFFU +static const u32 PPU_THREAD_ID_INVALID = 0xFFFFFFFFU; +enum +{ + SYS_PPU_THREAD_ONCE_INIT, + SYS_PPU_THREAD_DONE_INIT, +}; int sys_ppu_thread_exit(int errorcode) { - sysPrxForUser.Log("sys_ppu_thread_exit(errorcode=%d)", errorcode); - Emu.GetCPU().RemoveThread(GetCurrentPPUThread().GetId()); + if(errorcode == 0) + { + sysPrxForUser.Log("sys_ppu_thread_exit(errorcode=%d)", errorcode); + } + else + { + sysPrxForUser.Warning("sys_ppu_thread_exit(errorcode=%d)", errorcode); + } + + PPUThread& thr = GetCurrentPPUThread(); + thr.SetExitStatus(errorcode); + Emu.GetCPU().RemoveThread(thr.GetId()); return CELL_OK; } int sys_ppu_thread_yield() { - sysPrxForUser.Log("sys_ppu_thread_yield()"); - wxThread::Yield(); - + sysPrxForUser.Log("sys_ppu_thread_yield()"); return CELL_OK; } int sys_ppu_thread_join(u32 thread_id, u32 vptr_addr) { - sysPrxForUser.Error("sys_ppu_thread_join(thread_id=%d, vptr_addr=0x%x)", thread_id, vptr_addr); + sysPrxForUser.Warning("sys_ppu_thread_join(thread_id=%d, vptr_addr=0x%x)", thread_id, vptr_addr); + PPCThread* thr = Emu.GetCPU().GetThread(thread_id); + if(!thr) return CELL_ESRCH; + + GetCurrentPPUThread().Wait(*thr); return CELL_OK; } @@ -110,13 +127,16 @@ int sys_ppu_thread_create(u32 thread_id_addr, u32 entry, u32 arg, int prio, u32 sysPrxForUser.Log("sys_ppu_thread_create(thread_id_addr=0x%x, entry=0x%x, arg=0x%x, prio=%d, stacksize=0x%x, flags=0x%llx, threadname_addr=0x%x('%s'))", thread_id_addr, entry, arg, prio, stacksize, flags, threadname_addr, Memory.ReadString(threadname_addr)); - if(!Memory.IsGoodAddr(entry) || !Memory.IsGoodAddr(thread_id_addr) || !Memory.IsGoodAddr(threadname_addr)) return CELL_EFAULT; + if(!Memory.IsGoodAddr(entry) || !Memory.IsGoodAddr(thread_id_addr) || !Memory.IsGoodAddr(threadname_addr)) + { + return CELL_EFAULT; + } - PPCThread& new_thread = Emu.GetCPU().AddThread(true); + PPCThread& new_thread = Emu.GetCPU().AddThread(PPC_THREAD_PPU); Memory.Write32(thread_id_addr, new_thread.GetId()); new_thread.SetEntry(entry); - new_thread.SetArg(arg); + new_thread.SetArg(0, arg); new_thread.SetPrio(prio); new_thread.stack_size = stacksize; //new_thread.flags = flags; @@ -127,9 +147,27 @@ int sys_ppu_thread_create(u32 thread_id_addr, u32 entry, u32 arg, int prio, u32 return CELL_OK; } -int sys_ppu_thread_get_id() +void sys_ppu_thread_once(u32 once_ctrl_addr, u32 entry) { - sysPrxForUser.Log("sys_ppu_thread_get_id()"); + sysPrxForUser.Warning("sys_ppu_thread_once(once_ctrl_addr=0x%x, entry=0x%x)", once_ctrl_addr, entry); - return GetCurrentPPUThread().GetId(); + if(Memory.IsGoodAddr(once_ctrl_addr, 4) && Memory.Read32(once_ctrl_addr) == SYS_PPU_THREAD_ONCE_INIT) + { + Memory.Write32(once_ctrl_addr, SYS_PPU_THREAD_DONE_INIT); + + PPCThread& new_thread = Emu.GetCPU().AddThread(PPC_THREAD_PPU); + new_thread.SetEntry(entry); + new_thread.Run(); + new_thread.Exec(); + + GetCurrentPPUThread().Wait(new_thread); + } +} + +int sys_ppu_thread_get_id(const u32 id_addr) +{ + sysPrxForUser.Log("sys_ppu_thread_get_id(id_addr=0x%x)", id_addr); + + Memory.Write32(id_addr, GetCurrentPPUThread().GetId()); + return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp index ca1761ed7b..15d9e7bb54 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp @@ -87,6 +87,12 @@ int cellPadGetData(u32 port_no, u32 data_addr) case CELL_PAD_BTN_OFFSET_DIGITAL1: if(!(d1 & buttons[i].m_outKeyCode)){d1 |= buttons[i].m_outKeyCode; len++;} break; case CELL_PAD_BTN_OFFSET_DIGITAL2: if(!(d2 & buttons[i].m_outKeyCode)){d2 |= buttons[i].m_outKeyCode; len++;} break; } + + if(buttons[i].m_flush) + { + buttons[i].m_pressed = false; + buttons[i].m_flush = false; + } } data.len = re(len); diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Process.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Process.cpp index 8f0a127121..14a1b70868 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Process.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Process.cpp @@ -11,7 +11,11 @@ int sys_process_getpid() int sys_process_exit(int errorcode) { ConLog.Warning("sys_process_exit(%d)", errorcode); +#ifdef _DEBUG Emu.Pause(); +#else + Emu.Stop(); +#endif return CELL_OK; } @@ -37,7 +41,6 @@ int SysCalls::lv2ProcessWaitForChild(PPUThread& CPU) int SysCalls::lv2ProcessGetStatus(PPUThread& CPU) { ConLog.Warning("lv2ProcessGetStatus"); - if(CPU.IsSPU()) return CELL_UNKNOWN_ERROR; //Memory.Write32(CPU.GPR[4], GetPPUThreadStatus(CPU)); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp b/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp index 7e3ba1b5d5..5ecad4f566 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" #include "Loader/ELF.h" +#include "Emu/Cell/SPUThread.h" SysCallBase sc_spu("sys_spu"); @@ -12,6 +13,21 @@ struct sys_spu_thread_group_attribute union{u32 ct;} option; }; +struct sys_spu_thread_attribute +{ + u32 name_addr; + u32 name_len; + u32 option; +}; + +struct sys_spu_thread_argument +{ + u64 arg1; + u64 arg2; + u64 arg3; + u64 arg4; +}; + struct sys_spu_image { u32 type; @@ -20,25 +36,185 @@ struct sys_spu_image int nsegs; }; -u32 LoadImage(vfsStream& stream) +static const u32 g_spu_group_thr_count = 255; + +struct SpuGroupInfo +{ + PPCThread* threads[g_spu_group_thr_count]; + sys_spu_thread_group_attribute& attr; + + SpuGroupInfo(sys_spu_thread_group_attribute& attr) : attr(attr) + { + memset(threads, 0, sizeof(PPCThread*) * g_spu_group_thr_count); + } +}; + +u64 g_spu_offset = 0; + +u32 LoadSpuImage(vfsStream& stream) { ELFLoader l(stream); l.LoadInfo(); - l.LoadData(Memory.MainMem.Alloc(stream.GetSize())); + g_spu_offset = Memory.MainMem.Alloc(0xFFFFED - stream.GetSize()); + l.LoadData(g_spu_offset); - return l.GetEntry(); + return g_spu_offset + l.GetEntry(); } - int sys_spu_image_open(u32 img_addr, u32 path_addr) - { +//156 +int sys_spu_image_open(u32 img_addr, u32 path_addr) +{ const wxString& path = Memory.ReadString(path_addr); sc_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img_addr, path_addr, path); - vfsLocalFile stream(path); - LoadImage(stream); + if(!Memory.IsGoodAddr(img_addr, sizeof(sys_spu_image)) || !Memory.IsGoodAddr(path_addr)) + { + return CELL_EFAULT; + } + + vfsStream* stream = Emu.GetVFS().Open(path, vfsRead); + + if(!stream || !stream->IsOpened()) + { + sc_spu.Error("sys_spu_image_open error: '%s' not found!", path); + delete stream; + + return CELL_ENOENT; + } + + u32 entry = LoadSpuImage(*stream); + delete stream; + + auto& ret = (sys_spu_image&)Memory[img_addr]; + re(ret.type, 1); + re(ret.entry_point, entry); + re(ret.segs_addr, 0x0); + re(ret.nsegs, 0); return CELL_OK; - } +} + +//172 +int sys_spu_thread_initialize(u32 thread_addr, u32 group, u32 spu_num, u32 img_addr, u32 attr_addr, u32 arg_addr) +{ + sc_spu.Warning("sys_spu_thread_initialize(thread_addr=0x%x, group=0x%x, spu_num=%d, img_addr=0x%x, attr_addr=0x%x, arg_addr=0x%x)", + thread_addr, group, spu_num, img_addr, attr_addr, arg_addr); + + if(!Emu.GetIdManager().CheckID(group)) + { + return CELL_ESRCH; + } + + SpuGroupInfo& group_info = *(SpuGroupInfo*)Emu.GetIdManager().GetIDData(group).m_data; + + if( + !Memory.IsGoodAddr(img_addr, sizeof(sys_spu_image)) || + !Memory.IsGoodAddr(attr_addr, sizeof(sys_spu_thread_attribute)) || + !Memory.IsGoodAddr(arg_addr, sizeof(sys_spu_thread_argument))) + { + return CELL_EFAULT; + } + + auto& img = (sys_spu_image&)Memory[img_addr]; + auto& attr = (sys_spu_thread_attribute&)Memory[attr_addr]; + auto& arg = (sys_spu_thread_argument&)Memory[arg_addr]; + + if(!Memory.IsGoodAddr(re(attr.name_addr), re(attr.name_len))) + { + return CELL_EFAULT; + } + + if(spu_num >= g_spu_group_thr_count) + { + return CELL_EINVAL; + } + + if(group_info.threads[spu_num]) + { + return CELL_EBUSY; + } + + u32 entry = re(img.entry_point); + wxString name = Memory.ReadString(re(attr.name_addr), re(attr.name_len)); + u64 a1 = re(arg.arg1); + u64 a2 = re(arg.arg2); + u64 a3 = re(arg.arg3); + u64 a4 = re(arg.arg4); + + ConLog.Write("New SPU Thread:"); + ConLog.Write("entry = 0x%x", entry); + ConLog.Write("name = %s", name); + ConLog.Write("a1 = 0x%x", a1); + ConLog.Write("a2 = 0x%x", a2); + ConLog.Write("a3 = 0x%x", a3); + ConLog.Write("a4 = 0x%x", a4); + ConLog.SkipLn(); + + PPCThread& new_thread = Emu.GetCPU().AddThread(PPC_THREAD_SPU); + new_thread.SetOffset(g_spu_offset); + new_thread.SetEntry(entry - g_spu_offset); + new_thread.SetName(name); + new_thread.Run(); + new_thread.Pause(); + new_thread.SetArg(0, a1); + new_thread.SetArg(1, a2); + new_thread.SetArg(2, a3); + new_thread.SetArg(3, a4); + + group_info.threads[spu_num] = &new_thread; + + return CELL_OK; +} + +//166 +int sys_spu_thread_set_argument(u32 id, u32 arg_addr) +{ + sc_spu.Warning("sys_spu_thread_set_argument(id=0x%x, arg_addr=0x%x)", id, arg_addr); + PPCThread* thr = Emu.GetCPU().GetThread(id); + + if(!thr || thr->GetType() == PPC_THREAD_PPU) + { + return CELL_ESRCH; + } + + if(!Memory.IsGoodAddr(arg_addr, sizeof(sys_spu_thread_argument))) + { + return CELL_EFAULT; + } + + auto& arg = (sys_spu_thread_argument&)Memory[arg_addr]; + thr->SetArg(0, re(arg.arg1)); + thr->SetArg(1, re(arg.arg2)); + thr->SetArg(2, re(arg.arg3)); + thr->SetArg(3, re(arg.arg4)); + + return CELL_OK; +} + +//173 +int sys_spu_thread_group_start(u32 id) +{ + sc_spu.Warning("sys_spu_thread_group_start(id=0x%x)", id); + + if(!Emu.GetIdManager().CheckID(id)) + { + return CELL_ESRCH; + } + + ID& id_data = Emu.GetIdManager().GetIDData(id); + SpuGroupInfo& group_info = *(SpuGroupInfo*)id_data.m_data; + + Emu.Pause(); + for(int i=0; iExec(); + } + } + + return CELL_OK; +} //170 int sys_spu_thread_group_create(u64 id_addr, u32 num, int prio, u64 attr_addr) @@ -49,7 +225,7 @@ int sys_spu_thread_group_create(u64 id_addr, u32 num, int prio, u64 attr_addr) ConLog.Write("*** prio=%d", prio); ConLog.Write("*** attr_addr=0x%llx", attr_addr); - sys_spu_thread_group_attribute& attr = *new sys_spu_thread_group_attribute(*(sys_spu_thread_group_attribute*)&Memory[attr_addr]); + sys_spu_thread_group_attribute& attr = (sys_spu_thread_group_attribute&)Memory[attr_addr]; ConLog.Write("*** attr.name_len=%d", re(attr.name_len)); ConLog.Write("*** attr.name_addr=0x%x", re(attr.name_addr)); @@ -60,7 +236,7 @@ int sys_spu_thread_group_create(u64 id_addr, u32 num, int prio, u64 attr_addr) ConLog.Write("*** name='%s'", name); Memory.Write32(id_addr, - Emu.GetIdManager().GetNewID(wxString::Format("sys_spu_thread_group %s", name), &attr, 0)); + Emu.GetIdManager().GetNewID(wxString::Format("sys_spu_thread_group '%s'", name), new SpuGroupInfo(attr))); return CELL_OK; } @@ -71,14 +247,31 @@ int sys_spu_thread_create(u64 thread_id_addr, u64 entry_addr, u64 arg, return CELL_OK; } +int sys_spu_thread_connect_event(u32 id, u32 eq, u32 et, u8 spup) +{ + if(!Emu.GetIdManager().CheckID(id)) + { + return CELL_ESRCH; + } + + if(spup > 63) + { + return CELL_EINVAL; + } + + return CELL_OK; +} + //160 int sys_raw_spu_create(u32 id_addr, u32 attr_addr) { sc_spu.Warning("sys_raw_spu_create(id_addr=0x%x, attr_addr=0x%x)", id_addr, attr_addr); - //PPCThread& new_thread = Emu.GetCPU().AddThread(false); //Emu.GetIdManager().GetNewID("sys_raw_spu", new u32(attr_addr)); - //Memory.Write32(id_addr, Emu.GetCPU().GetThreadNumById(false, new_thread.GetId())); + PPCThread& new_thread = Emu.GetCPU().AddThread(PPC_THREAD_RAW_SPU); + Memory.Write32(id_addr, Emu.GetCPU().GetThreadNumById(PPC_THREAD_RAW_SPU, new_thread.GetId())); + new_thread.Run(); + new_thread.Exec(); return CELL_OK; } @@ -88,10 +281,123 @@ int sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu) { sc_spu.Warning("sys_spu_initialize(max_usable_spu=%d, max_raw_spu=%d)", max_usable_spu, max_raw_spu); + if(max_raw_spu > 5) + { + return CELL_EINVAL; + } + if(!Memory.InitSpuRawMem(max_raw_spu)) { - return CELL_UNKNOWN_ERROR; + return CELL_ENOMEM; + } + + //enable_log = true; + //dump_enable = true; + + return CELL_OK; +} + +//181 +int sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type) +{ + sc_spu.Warning("sys_spu_thread_write_ls(id=0x%x, address=0x%x, value=0x%llx, type=0x%x)", + id, address, value, type); + + PPCThread* thr = Emu.GetCPU().GetThread(id); + + if(!thr || thr->GetType() == PPC_THREAD_PPU) + { + return CELL_ESRCH; + } + + (*(SPUThread*)thr).WriteLS64(address, value); + + return CELL_OK; +} + +//182 +int sys_spu_thread_read_ls(u32 id, u32 address, u32 value_addr, u32 type) +{ + sc_spu.Warning("sys_spu_thread_read_ls(id=0x%x, address=0x%x, value_addr=0x%x, type=0x%x)", + id, address, value_addr, type); + + PPCThread* thr = Emu.GetCPU().GetThread(id); + + if(!thr || thr->GetType() == PPC_THREAD_PPU) + { + return CELL_ESRCH; + } + + if(!(*(SPUThread*)thr).IsGoodLSA(address)) + { + return CELL_EFAULT; + } + + Memory.Write64(value_addr, (*(SPUThread*)thr).ReadLS64(address)); + + return CELL_OK; +} + +//190 +int sys_spu_thread_write_spu_mb(u32 id, u32 value) +{ + sc_spu.Warning("sys_spu_thread_write_spu_mb(id=0x%x, value=0x%x)", id, value); + + PPCThread* thr = Emu.GetCPU().GetThread(id); + + if(!thr || !thr->GetType() == PPC_THREAD_PPU) + { + return CELL_ESRCH; + } + + if(!(*(SPUThread*)thr).mfc.SPU_In_MBox.Push(value)) + { + ConLog.Warning("sys_spu_thread_write_spu_mb(id=0x%x, value=0x%x): used all mbox items."); + return CELL_EBUSY; //? } + return CELL_OK; +} + +extern SysCallBase sys_event; + +int sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq, u64 req, u32 spup_addr) +{ + sc_spu.Warning("sys_spu_thread_group_connect_event_all_threads(id=0x%x, eq=0x%x, req=0x%llx, spup_addr=0x%x)", + id, eq, req, spup_addr); + + if(!Emu.GetIdManager().CheckID(id) || !sys_event.CheckId(eq)) + { + return CELL_ESRCH; + } + + if(!req) + { + return CELL_EINVAL; + } + + SpuGroupInfo* group = (SpuGroupInfo*)Emu.GetIdManager().GetIDData(id).m_data; + EventQueue* equeue = (EventQueue*)Emu.GetIdManager().GetIDData(eq).m_data; + + for(int i=0; ithreads[i]) + { + bool finded_port = false; + for(int j=0; jpos; ++j) + { + if(!equeue->ports[j]->thread) + { + finded_port = true; + equeue->ports[j]->thread = group->threads[i]; + } + } + + if(!finded_port) + { + return CELL_EISCONN; + } + } + } return CELL_OK; } \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/lv2/SC_SysUtil.cpp b/rpcs3/Emu/SysCalls/lv2/SC_SysUtil.cpp index 4af1e69c9a..4a223aeab0 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_SysUtil.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_SysUtil.cpp @@ -201,4 +201,4 @@ int cellSysutilUnregisterCallback(int slot) wxGetApp().SendDbgCommand(DID_UNREGISTRED_CALLBACK); return CELL_OK; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/lv2/SC_SysUtil_MsgDialog.cpp b/rpcs3/Emu/SysCalls/lv2/SC_SysUtil_MsgDialog.cpp index 9ffc858806..720b7b579e 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_SysUtil_MsgDialog.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_SysUtil_MsgDialog.cpp @@ -70,7 +70,7 @@ int cellMsgDialogOpen2(u32 type, u32 msgString_addr, u32 callback_addr, u32 user Callback2 callback(0, callback_addr, userData); callback.Handle(status); - callback.Branch(); + callback.Branch(true); return CELL_OK; } \ No newline at end of file diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 812e50e05c..f0155e534b 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -12,7 +12,10 @@ using namespace PPU_instr; static const wxString& BreakPointsDBName = "BreakPoints.dat"; static const u16 bpdb_version = 0x1000; -//SysCalls SysCallsManager; +ModuleInitializer::ModuleInitializer() +{ + Emu.AddModuleInit(this); +} Emulator::Emulator() : m_status(Stopped) @@ -24,6 +27,11 @@ Emulator::Emulator() void Emulator::Init() { + while(m_modules_init.GetCount()) + { + m_modules_init[0].Init(); + m_modules_init.RemoveAt(0); + } //if(m_memory_viewer) m_memory_viewer->Close(); //m_memory_viewer = new MemoryViewerPanel(wxGetApp().m_MainFrame); } @@ -77,8 +85,6 @@ void Emulator::Load() Memory.Init(); GetInfo().Reset(); - Memory.Write64(Memory.PRXMem.Alloc(8), 0xDEADBEEFABADCAFE); - bool is_error; vfsLocalFile f(m_path); Loader l(f); @@ -106,29 +112,40 @@ void Emulator::Load() } LoadPoints(BreakPointsDBName); - PPCThread& thread = GetCPU().AddThread(l.GetMachine() == MACHINE_PPC64); + PPCThread& thread = GetCPU().AddThread(l.GetMachine() == MACHINE_PPC64 ? PPC_THREAD_PPU : PPC_THREAD_SPU); - thread.SetEntry(l.GetEntry()); - thread.SetArg(thread.GetId()); - Memory.StackMem.Alloc(0x1000); - thread.InitStack(); - thread.AddArgv(m_path); - //thread.AddArgv("-emu"); + if(l.GetMachine() == MACHINE_SPU) + { + ConLog.Write("offset = 0x%llx", Memory.MainMem.GetStartAddr()); + ConLog.Write("max addr = 0x%x", l.GetMaxAddr()); + thread.SetOffset(Memory.MainMem.GetStartAddr()); + Memory.MainMem.Alloc(Memory.MainMem.GetStartAddr() + l.GetMaxAddr(), 0xFFFFED - l.GetMaxAddr()); + thread.SetEntry(l.GetEntry() - Memory.MainMem.GetStartAddr()); + } + else + { + thread.SetEntry(l.GetEntry()); + Memory.StackMem.Alloc(0x1000); + thread.InitStack(); + thread.AddArgv(m_path); + //thread.AddArgv("-emu"); - m_rsx_callback = Memory.MainMem.Alloc(4 * 4) + 4; - Memory.Write32(m_rsx_callback - 4, m_rsx_callback); + m_rsx_callback = Memory.MainMem.Alloc(4 * 4) + 4; + Memory.Write32(m_rsx_callback - 4, m_rsx_callback); - mem32_t callback_data(m_rsx_callback); - callback_data += ADDI(11, 0, 0x3ff); - callback_data += SC(2); - callback_data += BCLR(0x10 | 0x04, 0, 0, 0); + mem32_t callback_data(m_rsx_callback); + callback_data += ADDI(11, 0, 0x3ff); + callback_data += SC(2); + callback_data += BCLR(0x10 | 0x04, 0, 0, 0); - m_ppu_thr_exit = Memory.MainMem.Alloc(4 * 3); - - mem32_t ppu_thr_exit_data(m_ppu_thr_exit); - ppu_thr_exit_data += ADDI(11, 0, 41); - ppu_thr_exit_data += SC(2); - ppu_thr_exit_data += BCLR(0x10 | 0x04, 0, 0, 0); + m_ppu_thr_exit = Memory.MainMem.Alloc(4 * 4); + + mem32_t ppu_thr_exit_data(m_ppu_thr_exit); + ppu_thr_exit_data += ADDI(3, 0, 0); + ppu_thr_exit_data += ADDI(11, 0, 41); + ppu_thr_exit_data += SC(2); + ppu_thr_exit_data += BCLR(0x10 | 0x04, 0, 0, 0); + } thread.Run(); @@ -158,10 +175,11 @@ void Emulator::Run() //ConLog.Write("run..."); m_status = Runned; - m_vfs.Mount("/", vfsDevice::GetRoot(m_path), new vfsLocalFile()); - m_vfs.Mount("/dev_hdd0/", wxGetCwd() + "\\dev_hdd0\\", new vfsLocalFile()); - m_vfs.Mount("/app_home/", vfsDevice::GetRoot(m_path), new vfsLocalFile()); - m_vfs.Mount(vfsDevice::GetRootPs3(m_path), vfsDevice::GetRoot(m_path), new vfsLocalFile()); + m_vfs.Init(m_path); + //m_vfs.Mount("/", vfsDevice::GetRoot(m_path), new vfsLocalFile()); + //m_vfs.Mount("/dev_hdd0/", wxGetCwd() + "\\dev_hdd0\\", new vfsLocalFile()); + //m_vfs.Mount("/app_home/", vfsDevice::GetRoot(m_path), new vfsLocalFile()); + //m_vfs.Mount(vfsDevice::GetRootPs3(m_path), vfsDevice::GetRoot(m_path), new vfsLocalFile()); ConLog.SkipLn(); ConLog.Write("Mount info:"); @@ -178,7 +196,14 @@ void Emulator::Run() //m_memory_viewer->ShowPC(); if(!m_dbg_console) + { m_dbg_console = new DbgConsole(); + } + else + { + GetDbgCon().Close(); + GetDbgCon().Clear(); + } GetGSManager().Init(); GetCallbackManager().Init(); @@ -229,6 +254,8 @@ void Emulator::Stop() m_break_points.Clear(); m_marked_points.Clear(); + m_vfs.UnMountAll(); + GetGSManager().Close(); GetCPU().Close(); //SysCallsManager.Close(); @@ -240,12 +267,6 @@ void Emulator::Stop() CurGameInfo.Reset(); Memory.Close(); - if(m_dbg_console) - { - GetDbgCon().Close(); - GetDbgCon().Clear(); - } - //if(m_memory_viewer && m_memory_viewer->IsShown()) m_memory_viewer->Hide(); wxGetApp().SendDbgCommand(DID_STOPED_EMU); } diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 837fe2322f..8719e5fa73 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -8,6 +8,7 @@ #include "Emu/DbgConsole.h" #include "Loader/Loader.h" #include "SysCalls/Callback.h" +#include "SysCalls/Modules.h" struct EmuInfo { @@ -45,6 +46,14 @@ public: u64 GetTLSMemsz() const { return tls_memsz; } }; +class ModuleInitializer +{ +public: + ModuleInitializer(); + + virtual void Init() = 0; +}; + class Emulator { enum Mode @@ -62,6 +71,7 @@ class Emulator u32 m_ppu_thr_exit; MemoryViewerPanel* m_memory_viewer; //ArrayF m_cpu_threads; + ArrayF m_modules_init; Array m_break_points; Array m_marked_points; @@ -93,6 +103,11 @@ public: VFS& GetVFS() { return m_vfs; } Array& GetBreakPoints() { return m_break_points; } Array& GetMarkedPoints() { return m_marked_points; } + + void AddModuleInit(ModuleInitializer* m) + { + m_modules_init.Add(m); + } void SetTLSData(const u64 addr, const u64 filesz, const u64 memsz) { diff --git a/rpcs3/Emu/event.h b/rpcs3/Emu/event.h new file mode 100644 index 0000000000..c3f72157d7 --- /dev/null +++ b/rpcs3/Emu/event.h @@ -0,0 +1,39 @@ +#pragma once + +struct sys_event_queue_attr +{ + u32 attr_protocol; + int type; + char name[8]; +}; + +struct sys_event_data +{ + u64 source; + u64 data1; + u64 data2; + u64 data3; +}; + +struct EventQueue; + +struct EventPort +{ + u64 name; + u64 data1; + u64 data2; + u64 data3; + bool has_data; + PPCThread* thread; + EventQueue* queue[127]; + int pos; +}; + +struct EventQueue +{ + EventPort* ports[127]; + int size; + int pos; + int type; + char name[8]; +}; \ No newline at end of file diff --git a/rpcs3/Gui/Debugger.cpp b/rpcs3/Gui/Debugger.cpp index 31bb005d06..a3100e1361 100644 --- a/rpcs3/Gui/Debugger.cpp +++ b/rpcs3/Gui/Debugger.cpp @@ -74,6 +74,8 @@ public: void HandleCommand(wxCommandEvent& event) { + event.Skip(); + switch(event.GetId()) { case DID_STOP_EMU: @@ -88,10 +90,13 @@ public: case DID_RESUME_EMU: m_btn_run->SetLabel("Pause"); break; + + case DID_EXIT_THR_SYSCALL: + Emu.GetCPU().RemoveThread(((PPCThread*)event.GetClientData())->GetId()); + break; } UpdateUI(); - event.Skip(); } }; @@ -99,16 +104,9 @@ DebuggerPanel::DebuggerPanel(wxWindow* parent) : wxPanel(parent, wxID_ANY, wxDef { m_aui_mgr.SetManagedWindow(this); - m_nb = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | - wxAUI_NB_TAB_EXTERNAL_MOVE | wxAUI_NB_SCROLL_BUTTONS | - wxAUI_NB_WINDOWLIST_BUTTON | wxAUI_NB_TAB_MOVE | wxNO_BORDER); - m_aui_mgr.AddPane(new DbgEmuPanel(this), wxAuiPaneInfo().Top()); - m_aui_mgr.AddPane(m_nb, wxAuiPaneInfo().Center().CaptionVisible(false).CloseButton().MaximizeButton()); + m_aui_mgr.AddPane(new InterpreterDisAsmFrame(this), wxAuiPaneInfo().Center().CaptionVisible(false).CloseButton().MaximizeButton()); m_aui_mgr.Update(); - - m_app_connector.Connect(wxEVT_DBG_COMMAND, wxCommandEventHandler(DebuggerPanel::HandleCommand), (wxObject*)0, this); } DebuggerPanel::~DebuggerPanel() @@ -119,30 +117,3 @@ DebuggerPanel::~DebuggerPanel() void DebuggerPanel::UpdateUI() { } - -void DebuggerPanel::HandleCommand(wxCommandEvent& event) -{ - PPCThread* thr = (PPCThread*)event.GetClientData(); - - switch(event.GetId()) - { - case DID_CREATE_THREAD: - m_nb->AddPage(new InterpreterDisAsmFrame(m_nb, thr), thr->GetFName()); - break; - - case DID_REMOVE_THREAD: - for(uint i=0; iGetPageCount(); ++i) - { - InterpreterDisAsmFrame* page = (InterpreterDisAsmFrame*)m_nb->GetPage(i); - - if(page->CPU.GetId() == thr->GetId()) - { - m_nb->DeletePage(i); - break; - } - } - break; - } - - event.Skip(); -} \ No newline at end of file diff --git a/rpcs3/Gui/Debugger.h b/rpcs3/Gui/Debugger.h index e127642937..7f48f0c623 100644 --- a/rpcs3/Gui/Debugger.h +++ b/rpcs3/Gui/Debugger.h @@ -5,13 +5,10 @@ class DebuggerPanel : public wxPanel { wxAuiManager m_aui_mgr; - wxAuiNotebook* m_nb; - AppConnector m_app_connector; public: DebuggerPanel(wxWindow* parent); ~DebuggerPanel(); void UpdateUI(); - void HandleCommand(wxCommandEvent& event); }; \ No newline at end of file diff --git a/rpcs3/Gui/DisAsmFrame.cpp b/rpcs3/Gui/DisAsmFrame.cpp index 5feadd3490..4fc2a446d7 100644 --- a/rpcs3/Gui/DisAsmFrame.cpp +++ b/rpcs3/Gui/DisAsmFrame.cpp @@ -135,7 +135,7 @@ public: *done = false; - if(Emu.GetCPU().GetThreads()[0].IsSPU()) + if(Emu.GetCPU().GetThreads()[0].GetType() != PPC_THREAD_PPU) { SPU_DisAsm& dis_asm = *new SPU_DisAsm(*(PPCThread*)NULL, DumpMode); decoder = new SPU_Decoder(dis_asm); @@ -341,7 +341,7 @@ void DisAsmFrame::Dump(wxCommandEvent& WXUNUSED(event)) PPC_DisAsm* disasm; PPC_Decoder* decoder; - if(Emu.GetCPU().GetThreads()[0].IsSPU()) + if(Emu.GetCPU().GetThreads()[0].GetType() != PPC_THREAD_PPU) { SPU_DisAsm& dis_asm = *new SPU_DisAsm(*(PPCThread*)NULL, DumpMode); decoder = new SPU_Decoder(dis_asm); diff --git a/rpcs3/Gui/InterpreterDisAsm.cpp b/rpcs3/Gui/InterpreterDisAsm.cpp index bdf9a1e4de..48464a661a 100644 --- a/rpcs3/Gui/InterpreterDisAsm.cpp +++ b/rpcs3/Gui/InterpreterDisAsm.cpp @@ -3,48 +3,39 @@ //static const int show_lines = 30; -u32 InterpreterDisAsmFrame::CentrePc(const u32 pc) const +u64 InterpreterDisAsmFrame::CentrePc(const u64 pc) const { return pc - ((m_item_count / 2) * 4); } -InterpreterDisAsmFrame::InterpreterDisAsmFrame(wxWindow* parent, PPCThread* cpu) +InterpreterDisAsmFrame::InterpreterDisAsmFrame(wxWindow* parent) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(500, 700), wxTAB_TRAVERSAL) , ThreadBase(false, "DisAsmFrame Thread") - , CPU(*cpu) , PC(0) + , CPU(nullptr) , m_item_count(30) + , decoder(nullptr) + , disasm(nullptr) { - if(CPU.IsSPU()) - { - SPU_DisAsm& dis_asm = *new SPU_DisAsm(CPU, InterpreterMode); - decoder = new SPU_Decoder(dis_asm); - disasm = &dis_asm; - } - else - { - PPU_DisAsm& dis_asm = *new PPU_DisAsm(CPU, InterpreterMode); - decoder = new PPU_Decoder(dis_asm); - disasm = &dis_asm; - } - wxBoxSizer& s_p_main = *new wxBoxSizer(wxVERTICAL); wxBoxSizer& s_b_main = *new wxBoxSizer(wxHORIZONTAL); m_list = new wxListView(this); + m_choice_units = new wxChoice(this, wxID_ANY); wxButton& b_go_to_addr = *new wxButton(this, wxID_ANY, "Go To Address"); wxButton& b_go_to_pc = *new wxButton(this, wxID_ANY, "Go To PC"); - m_btn_step = new wxButton(this, wxID_ANY, "Step"); - m_btn_run = new wxButton(this, wxID_ANY, "Run"); - m_btn_pause = new wxButton(this, wxID_ANY, "Pause"); + m_btn_step = new wxButton(this, wxID_ANY, "Step"); + m_btn_run = new wxButton(this, wxID_ANY, "Run"); + m_btn_pause = new wxButton(this, wxID_ANY, "Pause"); - s_b_main.Add(&b_go_to_addr, wxSizerFlags().Border(wxALL, 5)); - s_b_main.Add(&b_go_to_pc, wxSizerFlags().Border(wxALL, 5)); - s_b_main.Add(m_btn_step, wxSizerFlags().Border(wxALL, 5)); - s_b_main.Add(m_btn_run, wxSizerFlags().Border(wxALL, 5)); - s_b_main.Add(m_btn_pause, wxSizerFlags().Border(wxALL, 5)); + s_b_main.Add(&b_go_to_addr, wxSizerFlags().Border(wxALL, 5)); + s_b_main.Add(&b_go_to_pc, wxSizerFlags().Border(wxALL, 5)); + s_b_main.Add(m_btn_step, wxSizerFlags().Border(wxALL, 5)); + s_b_main.Add(m_btn_run, wxSizerFlags().Border(wxALL, 5)); + s_b_main.Add(m_btn_pause, wxSizerFlags().Border(wxALL, 5)); + s_b_main.Add(m_choice_units, wxSizerFlags().Border(wxALL, 5)); m_regs = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_DONTWRAP|wxNO_BORDER|wxTE_RICH2); @@ -77,12 +68,14 @@ InterpreterDisAsmFrame::InterpreterDisAsmFrame(wxWindow* parent, PPCThread* cpu) Connect(m_btn_run->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(InterpreterDisAsmFrame::DoRun)); Connect(m_btn_pause->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(InterpreterDisAsmFrame::DoPause)); Connect(m_list->GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(InterpreterDisAsmFrame::DClick)); + Connect(m_choice_units->GetId(),wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(InterpreterDisAsmFrame::OnSelectUnit)); Connect(wxEVT_SIZE, wxSizeEventHandler(InterpreterDisAsmFrame::OnResize)); m_app_connector.Connect(m_list->GetId(), wxEVT_MOUSEWHEEL, wxMouseEventHandler(InterpreterDisAsmFrame::MouseWheel), (wxObject*)0, this); m_app_connector.Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(InterpreterDisAsmFrame::OnKeyDown), (wxObject*)0, this); - m_app_connector.Connect(wxEVT_DBG_COMMAND, wxCommandEventHandler(InterpreterDisAsmFrame::HandleCommand), (wxObject*)0, this); - WriteRegs(); + + ShowAddr(CentrePc(PC)); + UpdateUnitList(); } InterpreterDisAsmFrame::~InterpreterDisAsmFrame() @@ -90,6 +83,48 @@ InterpreterDisAsmFrame::~InterpreterDisAsmFrame() ThreadBase::Stop(); } +void InterpreterDisAsmFrame::UpdateUnitList() +{ + m_choice_units->Freeze(); + m_choice_units->Clear(); + auto& thrs = Emu.GetCPU().GetThreads(); + + for(uint i=0; iAppend(thrs[i].GetFName(), &thrs[i]); + } + + m_choice_units->Thaw(); +} + +void InterpreterDisAsmFrame::OnSelectUnit(wxCommandEvent& event) +{ + CPU = (PPCThread*)event.GetClientData(); + + delete decoder; + //delete disasm; + decoder = nullptr; + disasm = nullptr; + + if(CPU) + { + if(CPU->GetType() != PPC_THREAD_PPU) + { + SPU_DisAsm& dis_asm = *new SPU_DisAsm(*CPU, InterpreterMode); + decoder = new SPU_Decoder(dis_asm); + disasm = &dis_asm; + } + else + { + PPU_DisAsm& dis_asm = *new PPU_DisAsm(*CPU, InterpreterMode); + decoder = new PPU_Decoder(dis_asm); + disasm = &dis_asm; + } + } + + DoUpdate(); +} + void InterpreterDisAsmFrame::OnKeyDown(wxKeyEvent& event) { if(wxGetActiveWindow() != wxGetTopLevelParent(this)) @@ -164,47 +199,59 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr) { PC = addr; m_list->Freeze(); - for(uint i=0; iSetItem(i, 0, wxString::Format("[%08llx] illegal address", PC)); - continue; } - - disasm->dump_pc = PC; - decoder->Decode(Memory.Read32(PC)); - - if(IsBreakPoint(PC)) + } + else + { + disasm->offset = CPU->GetOffset(); + for(uint i=0; iSetItem(i, 0, ">>> " + disasm->last_opcode); - } - else - { - m_list->SetItem(i, 0, " " + disasm->last_opcode); - } - - wxColour colour; - - if((!CPU.IsRunned() || !Emu.IsRunned()) && PC == CPU.PC) - { - colour = wxColour("Green"); - } - else - { - colour = wxColour("White"); - - for(u32 i=0; iGetOffset() + PC, 4)) { - if(Emu.GetMarkedPoints()[i] == PC) + m_list->SetItem(i, 0, wxString::Format("[%08llx] illegal address", PC)); + continue; + } + + disasm->dump_pc = PC; + decoder->Decode(Memory.Read32(CPU->GetOffset() + PC)); + + if(IsBreakPoint(PC)) + { + m_list->SetItem(i, 0, ">>> " + disasm->last_opcode); + } + else + { + m_list->SetItem(i, 0, " " + disasm->last_opcode); + } + + wxColour colour; + + if((!CPU->IsRunned() || !Emu.IsRunned()) && PC == CPU->PC) + { + colour = wxColour("Green"); + } + else + { + colour = wxColour("White"); + + for(u32 i=0; iSetItemBackgroundColour( i, colour ); + m_list->SetItemBackgroundColour( i, colour ); + } } while(remove_markedPC.GetCount()) @@ -231,9 +278,17 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr) void InterpreterDisAsmFrame::WriteRegs() { + if(!CPU) + { + m_regs->Clear(); + return; + } + + const wxString data = CPU->RegsToString(); + m_regs->Freeze(); m_regs->Clear(); - m_regs->WriteText(CPU.RegsToString()); + m_regs->WriteText(data); m_regs->Thaw(); } @@ -246,37 +301,38 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event) { switch(event.GetId()) { - case DID_STOP_EMU: - case DID_PAUSE_EMU: - DoUpdate(); + case DID_STOPED_EMU: + UpdateUnitList(); + break; + + case DID_PAUSED_EMU: + //DoUpdate(); break; } } - else if(thr->GetId() == CPU.GetId()) + else if(CPU && thr->GetId() == CPU->GetId()) { switch(event.GetId()) { case DID_PAUSE_THREAD: + m_btn_run->Disable(); + m_btn_step->Disable(); + m_btn_pause->Disable(); + break; + + case DID_PAUSED_THREAD: m_btn_run->Enable(); m_btn_step->Enable(); m_btn_pause->Disable(); - - case DID_CREATE_THREAD: DoUpdate(); break; - case DID_START_THREAD: case DID_EXEC_THREAD: case DID_RESUME_THREAD: m_btn_run->Disable(); m_btn_step->Disable(); m_btn_pause->Enable(); - - if(event.GetId() == DID_START_THREAD) - { - DoUpdate(); - } break; case DID_REMOVE_THREAD: @@ -284,6 +340,38 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event) m_btn_run->Disable(); m_btn_step->Disable(); m_btn_pause->Disable(); + + if(event.GetId() == DID_REMOVE_THREAD) + { + //m_choice_units->SetSelection(-1); + //wxCommandEvent event; + //event.SetInt(-1); + //event.SetClientData(nullptr); + //OnSelectUnit(event); + UpdateUnitList(); + //DoUpdate(); + } + break; + } + } + else + { + switch(event.GetId()) + { + case DID_CREATE_THREAD: + UpdateUnitList(); + if(m_choice_units->GetSelection() == -1) + { + //m_choice_units->SetSelection(0); + //wxCommandEvent event; + //event.SetInt(0); + //event.SetClientData(&Emu.GetCPU().GetThreads()[0]); + //OnSelectUnit(event); + } + break; + + case DID_REMOVED_THREAD: + UpdateUnitList(); break; } } @@ -312,11 +400,11 @@ void InterpreterDisAsmFrame::Show_Val(wxCommandEvent& WXUNUSED(event)) diag->SetSizerAndFit( s_panel ); - p_pc->SetLabel(wxString::Format("%llx", CPU.PC)); + if(CPU) p_pc->SetLabel(wxString::Format("%llx", CPU->PC)); if(diag->ShowModal() == wxID_OK) { - u64 pc = CPU.PC; + u64 pc = CPU ? CPU->PC : 0x0; sscanf(p_pc->GetLabel(), "%llx", &pc); remove_markedPC.AddCpy(Emu.GetMarkedPoints().AddCpy(pc)); ShowAddr(CentrePc(pc)); @@ -325,17 +413,19 @@ void InterpreterDisAsmFrame::Show_Val(wxCommandEvent& WXUNUSED(event)) void InterpreterDisAsmFrame::Show_PC(wxCommandEvent& WXUNUSED(event)) { - ShowAddr(CentrePc(CPU.PC)); + if(CPU) ShowAddr(CentrePc(CPU->PC)); } extern bool dump_enable; void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event)) { - if(CPU.IsPaused()) CPU.Resume(); + if(!CPU) return; + + if(CPU->IsPaused()) CPU->Resume(); if(!Emu.IsPaused()) { - CPU.Exec(); + CPU->Exec(); } //ThreadBase::Start(); @@ -343,7 +433,8 @@ void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event)) void InterpreterDisAsmFrame::DoPause(wxCommandEvent& WXUNUSED(event)) { - CPU.Pause(); + //DoUpdate(); + if(CPU) CPU->Pause(); } void InterpreterDisAsmFrame::DoStep(wxCommandEvent& WXUNUSED(event)) @@ -417,8 +508,9 @@ bool InterpreterDisAsmFrame::RemoveBreakPoint(u64 pc) void InterpreterDisAsmFrame::Task() { - wxGetApp().SendDbgCommand(DID_RESUME_THREAD, &CPU); - + if(!CPU) return; + wxGetApp().SendDbgCommand(DID_RESUME_THREAD, CPU); + wxGetApp().SendDbgCommand(DID_RESUMED_THREAD, CPU); bool dump_status = dump_enable; //CPU.InitTls(); @@ -427,9 +519,9 @@ void InterpreterDisAsmFrame::Task() { do { - CPU.ExecOnce(); + CPU->ExecOnce(); } - while(CPU.IsRunned() && Emu.IsRunned() && !TestDestroy() && !IsBreakPoint(CPU.PC) && dump_status == dump_enable); + while(CPU->IsRunned() && Emu.IsRunned() && !TestDestroy() && !IsBreakPoint(CPU->PC) && dump_status == dump_enable); } catch(const wxString& e) { @@ -442,5 +534,6 @@ void InterpreterDisAsmFrame::Task() //CPU.FreeTls(); - wxGetApp().SendDbgCommand(DID_PAUSE_THREAD, &CPU); + wxGetApp().SendDbgCommand(DID_PAUSE_THREAD, CPU); + wxGetApp().SendDbgCommand(DID_PAUSED_THREAD, CPU); } \ No newline at end of file diff --git a/rpcs3/Gui/InterpreterDisAsm.h b/rpcs3/Gui/InterpreterDisAsm.h index 57d3846fcb..b86db3ab2a 100644 --- a/rpcs3/Gui/InterpreterDisAsm.h +++ b/rpcs3/Gui/InterpreterDisAsm.h @@ -20,16 +20,19 @@ class InterpreterDisAsmFrame wxButton* m_btn_pause; AppConnector m_app_connector; u32 m_item_count; + wxChoice* m_choice_units; public: - PPCThread& CPU; + PPCThread* CPU; public: - InterpreterDisAsmFrame(wxWindow* parent, PPCThread* cpu); + InterpreterDisAsmFrame(wxWindow* parent); ~InterpreterDisAsmFrame(); - u32 CentrePc(const u32 pc) const; + void UpdateUnitList(); + u64 CentrePc(const u64 pc) const; + void OnSelectUnit(wxCommandEvent& event); void OnKeyDown(wxKeyEvent& event); void OnResize(wxSizeEvent& event); void DoUpdate(); diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 0a6b1c435f..393cea6820 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -5,6 +5,8 @@ #include "Emu/System.h" #include "Ini.h" #include "Emu/GS/sysutil_video.h" +#include "Gui/VHDDManager.h" +#include "Gui/VFSManager.h" #include BEGIN_EVENT_TABLE(MainFrame, FrameBase) @@ -18,8 +20,11 @@ enum IDs id_boot_game, id_sys_pause, id_sys_stop, + id_sys_send_open_menu, id_sys_send_exit, id_config_emu, + id_config_vfs_manager, + id_config_vhdd_manager, id_update_dbg, }; @@ -31,8 +36,9 @@ wxString GetPaneName() } MainFrame::MainFrame() - : FrameBase(NULL, wxID_ANY, "", "MainFrame", wxSize(280, 180)) + : FrameBase(nullptr, wxID_ANY, "", "MainFrame", wxSize(800, 600)) , m_aui_mgr(this) + , m_sys_menu_opened(false) { SetLabel(wxString::Format(_PRGNAME_ " " _PRGVER_)); wxMenuBar& menubar(*new wxMenuBar()); @@ -53,25 +59,34 @@ MainFrame::MainFrame() menu_sys.Append(id_sys_pause, "Pause")->Enable(false); menu_sys.Append(id_sys_stop, "Stop\tCtrl + S")->Enable(false); menu_sys.AppendSeparator(); + menu_sys.Append(id_sys_send_open_menu, "Send open system menu cmd")->Enable(false); menu_sys.Append(id_sys_send_exit, "Send exit cmd")->Enable(false); menu_conf.Append(id_config_emu, "Settings"); + menu_conf.AppendSeparator(); + menu_conf.Append(id_config_vfs_manager, "Virtual File System Manager"); + menu_conf.Append(id_config_vhdd_manager, "Virtual HDD Manager"); SetMenuBar(&menubar); m_game_viewer = new GameViewer(this); AddPane(m_game_viewer, "Game List", wxAUI_DOCK_BOTTOM); - Connect( id_boot_game, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootGame) ); - Connect( id_boot_elf, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootElf) ); - Connect( id_boot_self, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootSelf) ); + Connect( id_boot_game, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootGame) ); + Connect( id_boot_elf, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootElf) ); + Connect( id_boot_self, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootSelf) ); - Connect( id_sys_pause, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Pause) ); - Connect( id_sys_stop, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Stop) ); - Connect( id_sys_send_exit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::SendExit) ); - Connect( id_update_dbg, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::UpdateUI) ); + Connect( id_sys_pause, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Pause) ); + Connect( id_sys_stop, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Stop) ); + Connect( id_sys_send_open_menu, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::SendOpenCloseSysMenu) ); + Connect( id_sys_send_exit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::SendExit) ); + + Connect( id_config_emu, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Config) ); + Connect( id_config_vfs_manager, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigVFS) ); + Connect( id_config_vhdd_manager,wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigVHDD) ); + + Connect( id_update_dbg, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::UpdateUI) ); - Connect( id_config_emu, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Config) ); m_app_connector.Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MainFrame::OnKeyDown), (wxObject*)0, this); m_app_connector.Connect(wxEVT_DBG_COMMAND, wxCommandEventHandler(MainFrame::UpdateUI), (wxObject*)0, this); } @@ -83,6 +98,7 @@ MainFrame::~MainFrame() void MainFrame::AddPane(wxWindow* wind, const wxString& caption, int flags) { + wind->SetSize(-1, 300); m_aui_mgr.AddPane(wind, wxAuiPaneInfo().Name(GetPaneName()).Caption(caption).Direction(flags).CloseButton(false).MaximizeButton()); } @@ -260,6 +276,13 @@ void MainFrame::SendExit(wxCommandEvent& event) Emu.GetCallbackManager().m_exit_callback.Handle(0x0101, 0); } +void MainFrame::SendOpenCloseSysMenu(wxCommandEvent& event) +{ + Emu.GetCallbackManager().m_exit_callback.Handle(m_sys_menu_opened ? 0x0132 : 0x0131, 0); + m_sys_menu_opened = !m_sys_menu_opened; + UpdateUI(wxCommandEvent()); +} + void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) { //TODO @@ -366,6 +389,16 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) if(paused) Emu.Resume(); } +void MainFrame::ConfigVFS(wxCommandEvent& WXUNUSED(event)) +{ + VFSManagerDialog(this).ShowModal(); +} + +void MainFrame::ConfigVHDD(wxCommandEvent& WXUNUSED(event)) +{ + VHDDManagerDialog(this).ShowModal(); +} + void MainFrame::UpdateUI(wxCommandEvent& event) { event.Skip(); @@ -388,6 +421,7 @@ void MainFrame::UpdateUI(wxCommandEvent& event) is_runned = false; is_stopped = true; is_ready = false; + m_sys_menu_opened = false; break; case DID_PAUSE_EMU: @@ -410,11 +444,14 @@ void MainFrame::UpdateUI(wxCommandEvent& event) is_ready = true; break; - default: + case DID_REGISTRED_CALLBACK: is_runned = Emu.IsRunned(); is_stopped = Emu.IsStopped(); is_ready = Emu.IsReady(); break; + + default: + return; } } else @@ -427,15 +464,19 @@ void MainFrame::UpdateUI(wxCommandEvent& event) wxMenuBar& menubar( *GetMenuBar() ); wxMenuItem& pause = *menubar.FindItem( id_sys_pause ); wxMenuItem& stop = *menubar.FindItem( id_sys_stop ); - wxMenuItem& send_exit = *menubar.FindItem( id_sys_send_exit ); - + wxMenuItem& send_exit = *menubar.FindItem( id_sys_send_exit ); + wxMenuItem& send_open_menu = *menubar.FindItem( id_sys_send_open_menu ); pause.SetText(is_runned ? "Pause\tCtrl + P" : is_ready ? "Start\tCtrl + C" : "Resume\tCtrl + C"); pause.Enable(!is_stopped); stop.Enable(!is_stopped); //send_exit.Enable(false); - send_exit.Enable(!is_stopped && Emu.GetCallbackManager().m_exit_callback.m_callbacks.GetCount()); + bool enable_commands = !is_stopped && Emu.GetCallbackManager().m_exit_callback.m_callbacks.GetCount(); - m_aui_mgr.Update(); + send_open_menu.SetText(wxString::Format("Send %s system menu cmd", m_sys_menu_opened ? "close" : "open")); + send_open_menu.Enable(enable_commands); + send_exit.Enable(enable_commands); + + //m_aui_mgr.Update(); //wxCommandEvent refit( wxEVT_COMMAND_MENU_SELECTED, id_update_dbg ); //GetEventHandler()->AddPendingEvent( refit ); diff --git a/rpcs3/Gui/MainFrame.h b/rpcs3/Gui/MainFrame.h index b7e479a324..43909bcd76 100644 --- a/rpcs3/Gui/MainFrame.h +++ b/rpcs3/Gui/MainFrame.h @@ -7,6 +7,7 @@ class MainFrame : public FrameBase GameViewer* m_game_viewer; wxAuiManager m_aui_mgr; AppConnector m_app_connector; + bool m_sys_menu_opened; public: MainFrame(); @@ -24,7 +25,10 @@ private: void Pause(wxCommandEvent& event); void Stop(wxCommandEvent& event); void SendExit(wxCommandEvent& event); + void SendOpenCloseSysMenu(wxCommandEvent& event); void Config(wxCommandEvent& event); + void ConfigVFS(wxCommandEvent& event); + void ConfigVHDD(wxCommandEvent& event); void UpdateUI(wxCommandEvent& event); void OnKeyDown(wxKeyEvent& event); diff --git a/rpcs3/Gui/TextInputDialog.cpp b/rpcs3/Gui/TextInputDialog.cpp new file mode 100644 index 0000000000..619bcf57c4 --- /dev/null +++ b/rpcs3/Gui/TextInputDialog.cpp @@ -0,0 +1,37 @@ +#include "stdafx.h" +#include "TextInputDialog.h" + +TextInputDialog::TextInputDialog(wxWindow* parent, const wxString& defvalue) + : wxDialog(parent, wxID_ANY, "Input text", wxDefaultPosition) +{ + m_tctrl_text = new wxTextCtrl(this, wxID_ANY, defvalue); + + wxBoxSizer& s_text(*new wxBoxSizer(wxVERTICAL)); + s_text.Add(m_tctrl_text, 1, wxEXPAND); + + wxBoxSizer& s_btns(*new wxBoxSizer(wxHORIZONTAL)); + s_btns.Add(new wxButton(this, wxID_OK)); + s_btns.AddSpacer(30); + s_btns.Add(new wxButton(this, wxID_CANCEL)); + + wxBoxSizer& s_main(*new wxBoxSizer(wxVERTICAL)); + s_main.Add(&s_text, 1, wxEXPAND | wxUP | wxLEFT | wxRIGHT, 5); + s_main.AddSpacer(30); + s_main.Add(&s_btns, 0, wxCENTER | wxDOWN | wxLEFT | wxRIGHT, 5); + + SetSizerAndFit(&s_main); + SetSize(250, -1); + + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(TextInputDialog::OnOk)); +} + +void TextInputDialog::OnOk(wxCommandEvent& event) +{ + m_result = m_tctrl_text->GetValue(); + EndModal(wxID_OK); +} + +wxString& TextInputDialog::GetResult() +{ + return m_result; +} \ No newline at end of file diff --git a/rpcs3/Gui/TextInputDialog.h b/rpcs3/Gui/TextInputDialog.h new file mode 100644 index 0000000000..cb4cf0ab52 --- /dev/null +++ b/rpcs3/Gui/TextInputDialog.h @@ -0,0 +1,13 @@ +#pragma once + +class TextInputDialog : public wxDialog +{ + wxTextCtrl* m_tctrl_text; + wxString m_result; + +public: + TextInputDialog(wxWindow* parent, const wxString& defvalue = wxEmptyString); + void OnOk(wxCommandEvent& event); + + wxString& GetResult(); +}; \ No newline at end of file diff --git a/rpcs3/Gui/VFSManager.cpp b/rpcs3/Gui/VFSManager.cpp new file mode 100644 index 0000000000..cfd82c446d --- /dev/null +++ b/rpcs3/Gui/VFSManager.cpp @@ -0,0 +1,219 @@ +#include "stdafx.h" +#include "VFSManager.h" + +VFSEntrySettingsDialog::VFSEntrySettingsDialog(wxWindow* parent, VFSManagerEntry& entry) + : wxDialog(parent, wxID_ANY, "Mount configuration", wxDefaultPosition) + , m_entry(entry) +{ + m_tctrl_dev_path = new wxTextCtrl(this, wxID_ANY); + m_btn_select_dev_path = new wxButton(this, wxID_ANY, "..."); + m_tctrl_path = new wxTextCtrl(this, wxID_ANY); + m_btn_select_path = new wxButton(this, wxID_ANY, "..."); + m_tctrl_mount = new wxTextCtrl(this, wxID_ANY); + m_ch_type = new wxChoice(this, wxID_ANY); + + wxBoxSizer& s_type(*new wxBoxSizer(wxHORIZONTAL)); + s_type.Add(m_ch_type, 1, wxEXPAND); + + wxBoxSizer& s_dev_path(*new wxBoxSizer(wxHORIZONTAL)); + s_dev_path.Add(m_tctrl_dev_path, 1, wxEXPAND); + s_dev_path.Add(m_btn_select_dev_path, 0, wxLEFT, 5); + + wxBoxSizer& s_path(*new wxBoxSizer(wxHORIZONTAL)); + s_path.Add(m_tctrl_path, 1, wxEXPAND); + s_path.Add(m_btn_select_path, 0, wxLEFT, 5); + + wxBoxSizer& s_mount(*new wxBoxSizer(wxHORIZONTAL)); + s_mount.Add(m_tctrl_mount, 1, wxEXPAND); + + wxBoxSizer& s_btns(*new wxBoxSizer(wxHORIZONTAL)); + s_btns.Add(new wxButton(this, wxID_OK)); + s_btns.AddSpacer(30); + s_btns.Add(new wxButton(this, wxID_CANCEL)); + + wxBoxSizer& s_main(*new wxBoxSizer(wxVERTICAL)); + s_main.Add(&s_type, 1, wxEXPAND | wxALL, 10); + s_main.Add(&s_dev_path, 1, wxEXPAND | wxALL, 10); + s_main.Add(&s_path, 1, wxEXPAND | wxALL, 10); + s_main.Add(&s_mount, 1, wxEXPAND | wxALL, 10); + s_main.AddSpacer(10); + s_main.Add(&s_btns, 0, wxALL | wxCENTER, 10); + + SetSizerAndFit(&s_main); + + SetSize(350, -1); + + for(const auto i : vfsDeviceTypeNames) + { + m_ch_type->Append(i); + } + + Connect(m_ch_type->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectType)); + Connect(m_btn_select_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectPath)); + Connect(m_btn_select_dev_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectDevPath)); + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnOk)); + + m_tctrl_dev_path->SetValue(m_entry.device_path.GetPtr()); + m_tctrl_path->SetValue(m_entry.path.GetPtr()); + m_tctrl_mount->SetValue(m_entry.mount.GetPtr()); + m_ch_type->SetSelection(m_entry.device); + + OnSelectType(wxCommandEvent()); +} + +void VFSEntrySettingsDialog::OnSelectType(wxCommandEvent& event) +{ + m_btn_select_path->Enable(m_ch_type->GetSelection() == vfsDevice_LocalFile); + m_tctrl_dev_path->Enable(m_ch_type->GetSelection() != vfsDevice_LocalFile); + m_btn_select_dev_path->Enable(m_ch_type->GetSelection() != vfsDevice_LocalFile); +} + +void VFSEntrySettingsDialog::OnSelectPath(wxCommandEvent& event) +{ + wxDirDialog ctrl(this, "Select path", wxGetCwd()); + + if(ctrl.ShowModal() == wxID_CANCEL) + { + return; + } + + m_tctrl_path->SetValue(ctrl.GetPath()); +} + +void VFSEntrySettingsDialog::OnSelectDevPath(wxCommandEvent& event) +{ + wxFileDialog ctrl(this, "Select device"); + + if(ctrl.ShowModal() == wxID_CANCEL) + { + return; + } + + m_tctrl_dev_path->SetValue(ctrl.GetPath()); +} + +void VFSEntrySettingsDialog::OnOk(wxCommandEvent& event) +{ + m_entry.device_path = m_tctrl_dev_path->GetValue(); + m_entry.path = m_tctrl_path->GetValue(); + m_entry.mount = m_tctrl_mount->GetValue(); + m_entry.device = (vfsDeviceType)m_ch_type->GetSelection(); + + EndModal(wxID_OK); +} + +enum +{ + id_add, + id_remove, + id_config, +}; + +VFSManagerDialog::VFSManagerDialog(wxWindow* parent) + : wxDialog(parent, wxID_ANY, "Virtual File System Manager", wxDefaultPosition) +{ + m_list = new wxListView(this); + + wxBoxSizer& s_main(*new wxBoxSizer(wxVERTICAL)); + s_main.Add(m_list, 1, wxEXPAND); + + SetSizerAndFit(&s_main); + SetSize(800, 600); + + m_list->InsertColumn(0, "Path"); + m_list->InsertColumn(1, "Device path"); + m_list->InsertColumn(2, "Path to Device"); + m_list->InsertColumn(3, "Device"); + + Connect(m_list->GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); + Connect(m_list->GetId(), wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(VFSManagerDialog::OnRightClick)); + Connect(id_add, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnAdd)); + Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnRemove)); + Connect(id_config, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); + Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VFSManagerDialog::OnClose)); + + LoadEntries(); + UpdateList(); +} + +void VFSManagerDialog::UpdateList() +{ + m_list->Freeze(); + m_list->DeleteAllItems(); + for(uint i=0; iInsertItem(i, m_entries[i].mount.GetPtr()); + m_list->SetItem(i, 1, m_entries[i].path.GetPtr()); + m_list->SetItem(i, 2, m_entries[i].device_path.GetPtr()); + m_list->SetItem(i, 3, vfsDeviceTypeNames[m_entries[i].device]); + } + m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); + m_list->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER); + m_list->SetColumnWidth(2, wxLIST_AUTOSIZE_USEHEADER); + m_list->SetColumnWidth(3, wxLIST_AUTOSIZE_USEHEADER); + m_list->Thaw(); +} + +void VFSManagerDialog::OnEntryConfig(wxCommandEvent& event) +{ + int idx = m_list->GetFirstSelected(); + if(idx != wxNOT_FOUND) + { + VFSEntrySettingsDialog(this, m_entries[idx]).ShowModal(); + UpdateList(); + } +} + +void VFSManagerDialog::OnRightClick(wxCommandEvent& event) +{ + wxMenu* menu = new wxMenu(); + int idx = m_list->GetFirstSelected(); + + menu->Append(id_add, "Add"); + menu->Append(id_remove, "Remove")->Enable(idx != wxNOT_FOUND); + menu->AppendSeparator(); + menu->Append(id_config, "Config")->Enable(idx != wxNOT_FOUND); + + PopupMenu( menu ); +} + +void VFSManagerDialog::OnAdd(wxCommandEvent& event) +{ + u32 idx = m_entries.Move(new VFSManagerEntry()); + UpdateList(); + + for(int i=0; iGetItemCount(); ++i) + { + m_list->SetItemState(i, i == idx ? wxLIST_STATE_SELECTED : ~wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); + } + + OnEntryConfig(wxCommandEvent()); +} + +void VFSManagerDialog::OnRemove(wxCommandEvent& event) +{ + for(int sel = m_list->GetNextSelected(-1), offs = 0; sel != wxNOT_FOUND; sel = m_list->GetNextSelected(sel), --offs) + { + m_entries.RemoveAt(sel + offs); + } + + UpdateList(); +} + +void VFSManagerDialog::OnClose(wxCloseEvent& event) +{ + SaveEntries(); + event.Skip(); +} + +void VFSManagerDialog::LoadEntries() +{ + m_entries.Clear(); + + Emu.GetVFS().SaveLoadDevices(m_entries, true); +} + +void VFSManagerDialog::SaveEntries() +{ + Emu.GetVFS().SaveLoadDevices(m_entries, false); +} \ No newline at end of file diff --git a/rpcs3/Gui/VFSManager.h b/rpcs3/Gui/VFSManager.h new file mode 100644 index 0000000000..e46f4911af --- /dev/null +++ b/rpcs3/Gui/VFSManager.h @@ -0,0 +1,39 @@ +#pragma once + +class VFSEntrySettingsDialog : public wxDialog +{ + wxTextCtrl* m_tctrl_dev_path; + wxButton* m_btn_select_dev_path; + wxTextCtrl* m_tctrl_path; + wxButton* m_btn_select_path; + wxTextCtrl* m_tctrl_mount; + wxChoice* m_ch_type; + VFSManagerEntry& m_entry; + +public: + VFSEntrySettingsDialog(wxWindow* parent, VFSManagerEntry& entry); + void OnSelectType(wxCommandEvent& event); + void OnSelectPath(wxCommandEvent& event); + void OnSelectDevPath(wxCommandEvent& event); + void OnOk(wxCommandEvent& event); +}; + +class VFSManagerDialog : public wxDialog +{ + wxListView* m_list; + Array m_entries; + +public: + VFSManagerDialog(wxWindow* parent); + + void UpdateList(); + + void OnEntryConfig(wxCommandEvent& event); + void OnRightClick(wxCommandEvent& event); + void OnAdd(wxCommandEvent& event); + void OnRemove(wxCommandEvent& event); + + void OnClose(wxCloseEvent& event); + void LoadEntries(); + void SaveEntries(); +}; \ No newline at end of file diff --git a/rpcs3/Gui/VHDDManager.cpp b/rpcs3/Gui/VHDDManager.cpp new file mode 100644 index 0000000000..367b144c6f --- /dev/null +++ b/rpcs3/Gui/VHDDManager.cpp @@ -0,0 +1,551 @@ +#include "stdafx.h" +#include "VHDDManager.h" +#include "TextInputDialog.h" +#include + +VHDDListDropTarget::VHDDListDropTarget(wxListView* parent) : m_parent(parent) +{ + SetDataObject(new wxDataObjectSimple(wxDF_PRIVATE)); +} + +wxDragResult VHDDListDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def) +{ + int flags = 0; + int indx = m_parent->HitTest(wxPoint(x, y), flags); + for(int i=0; iGetItemCount(); ++i) + { + m_parent->SetItemState(i, i == indx ? wxLIST_STATE_SELECTED : ~wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); + } + + return def; +} + +void VHDDListDropTarget::OnLeave() +{ + for(int i=0; iGetItemCount(); ++i) + { + m_parent->SetItemState(i, ~wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); + } +} + +wxDragResult VHDDListDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def) +{ + int flags = 0; + int dst_indx = m_parent->HitTest(wxPoint(x, y), flags); + ConLog.Write("OnData(%d -> %d)", m_src_indx, dst_indx); + return def; +} + +enum +{ + id_open = 0x777, + id_rename, + id_remove, + id_create_dir, + id_create_file, + id_import, + id_export, + id_create_hdd, + id_add_hdd +}; + +VHDDExplorer::VHDDExplorer(wxWindow* parent, const wxString& hdd_path) : wxDialog(parent, wxID_ANY, "Virtual HDD Explorer", wxDefaultPosition) +{ + m_list = new wxListView(this); + m_drop_target = new VHDDListDropTarget(m_list); + + m_list->SetDropTarget(m_drop_target); + m_list->DragAcceptFiles(true); + + wxBoxSizer& s_main(*new wxBoxSizer(wxVERTICAL)); + s_main.Add(m_list, 1, wxEXPAND | wxALL, 5); + SetSizerAndFit(&s_main); + + SetSize(800, 600); + m_list->InsertColumn(0, "Name"); + m_list->InsertColumn(1, "Type"); + m_list->InsertColumn(2, "Size"); + m_list->InsertColumn(3, "Creation time"); + + m_hdd = new vfsHDD(hdd_path); + UpdateList(); + Connect(m_list->GetId(), wxEVT_COMMAND_LIST_BEGIN_DRAG, wxListEventHandler(VHDDExplorer::OnListDrag)); + Connect(m_list->GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(VHDDExplorer::DClick)); + Connect(m_list->GetId(), wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(VHDDExplorer::OnContextMenu)); + m_list->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(VHDDExplorer::OnDropFiles), (wxObject*)0, this); + + Connect(id_open, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDExplorer::OnOpen)); + Connect(id_rename, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDExplorer::OnRename)); + Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDExplorer::OnRemove)); + Connect(id_create_dir, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDExplorer::OnCreateDir)); + Connect(id_create_file, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDExplorer::OnCreateFile)); + Connect(id_import, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDExplorer::OnImport)); + Connect(id_export, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDExplorer::OnExport)); +} + +void VHDDExplorer::UpdateList() +{ + m_list->Freeze(); + m_list->DeleteAllItems(); + m_entries.Clear(); + m_names.Clear(); + + u64 block; + vfsHDD_Entry entry; + wxString name; + + for(bool is_ok = m_hdd->GetFirstEntry(block, entry, name); is_ok; is_ok = m_hdd->GetNextEntry(block, entry, name)) + { + int item = m_list->GetItemCount(); + m_list->InsertItem(item, name); + m_list->SetItem(item, 1, entry.type == vfsHDD_Entry_Dir ? "Dir" : "File"); + m_list->SetItem(item, 2, wxString::Format("%lld", entry.size)); + m_list->SetItem(item, 3, wxDateTime().Set(time_t(entry.ctime)).Format()); + m_entries.AddCpy(entry); + m_names.Add(name); + } + + m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); + m_list->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER); + m_list->SetColumnWidth(2, wxLIST_AUTOSIZE_USEHEADER); + m_list->SetColumnWidth(3, wxLIST_AUTOSIZE_USEHEADER); + m_list->Thaw(); +} + +void VHDDExplorer::Import(const wxString& path, const wxString& to) +{ + if(!m_hdd->Create(vfsHDD_Entry_File, to)) + { + wxMessageBox("IMPORT ERROR: file creation error."); + return; + } + + if(!m_hdd->Open(to, vfsWrite)) + { + wxMessageBox("IMPORT ERROR: file open error."); + return; + } + + wxFile f(path); + char buf[256]; + + while(!f.Eof()) + { + m_hdd->Write(buf, f.Read(buf, 256)); + } + + m_hdd->Close(); +} + +void VHDDExplorer::Export(const wxString& path, const wxString& to) +{ + if(!m_hdd->Open(path)) + { + wxMessageBox(wxString::Format("EXPORT ERROR: file open error. (%s)", path)); + return; + } + + wxFile f(to, wxFile::write); + char buf[256]; + + while(u64 size = m_hdd->Read(buf, 256)) + { + f.Write(buf, size); + } +} + +void VHDDExplorer::OpenDir(int sel) +{ + if(sel == wxNOT_FOUND) + { + return; + } + + if(m_entries[sel].type == vfsHDD_Entry_Dir) + { + m_hdd->OpenDir(m_names[sel]); + UpdateList(); + } +} + +void VHDDExplorer::OnListDrag(wxListEvent& event) +{ + m_drop_target->SetSrcIndx(event.GetIndex()); + wxDataObjectSimple obj(wxDF_PRIVATE); + wxDropSource drag(obj, m_list); + drag.DoDragDrop(wxDrag_AllowMove); +} + +void VHDDExplorer::OnDropFiles(wxDropFilesEvent& event) +{ + int count = event.GetNumberOfFiles(); + wxString* dropped = event.GetFiles(); + + wxBusyCursor busyCursor; + wxWindowDisabler disabler; + wxBusyInfo busyInfo("Adding files, wait please..."); + + + for(int i=0; iGetFirstSelected(); + + menu->Append(id_open, "Open")->Enable(idx != wxNOT_FOUND && m_entries[idx].type == vfsHDD_Entry_Dir); + menu->Append(id_rename, "Rename")->Enable(idx != wxNOT_FOUND && m_names[idx] != "." && m_names[idx] != ".."); + menu->Append(id_remove, "Remove")->Enable(idx != wxNOT_FOUND && m_names[idx] != "." && m_names[idx] != ".."); + menu->AppendSeparator(); + menu->Append(id_create_dir, "Create dir"); + menu->Append(id_create_file, "Create file"); + menu->AppendSeparator(); + menu->Append(id_import, "Import"); + menu->Append(id_export, "Export")->Enable(idx != wxNOT_FOUND); + + PopupMenu( menu ); +} + +void VHDDExplorer::OnOpen(wxCommandEvent& event) +{ + m_hdd->OpenDir(m_names[m_list->GetFirstSelected()]); + UpdateList(); +} + +void VHDDExplorer::OnRename(wxCommandEvent& event) +{ + TextInputDialog dial(this, m_names[m_list->GetFirstSelected()]); + + if(dial.ShowModal() == wxID_OK) + { + m_hdd->Rename(m_names[m_list->GetFirstSelected()], dial.GetResult()); + UpdateList(); + } +} + +void VHDDExplorer::OnRemove(wxCommandEvent& event) +{ + for(int sel = m_list->GetNextSelected(-1); sel != wxNOT_FOUND; sel = m_list->GetNextSelected(sel)) + { + m_hdd->RemoveEntry(m_names[sel]); + } + + UpdateList(); +} + +void VHDDExplorer::OnCreateDir(wxCommandEvent& event) +{ + int i = 1; + static const wxString& fmt = "New Dir (%d)"; + while(m_hdd->HasEntry(wxString::Format(fmt, i))) i++; + + m_hdd->Create(vfsHDD_Entry_Dir, wxString::Format(fmt, i)); + UpdateList(); +} + +void VHDDExplorer::OnCreateFile(wxCommandEvent& event) +{ + int i = 1; + static const wxString& fmt = "New File (%d)"; + while(m_hdd->HasEntry(wxString::Format(fmt, i))) i++; + + m_hdd->Create(vfsHDD_Entry_File, wxString::Format(fmt, i)); + UpdateList(); +} + +void VHDDExplorer::OnImport(wxCommandEvent& event) +{ + wxFileDialog ctrl(this, "Select import files", wxEmptyString, wxEmptyString, wxFileSelectorDefaultWildcardStr, + wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE); + + if(ctrl.ShowModal() == wxID_CANCEL) + { + return; + } + + wxArrayString paths; + ctrl.GetPaths(paths); + for(size_t i=0; iGetSelectedItemCount() > 1) + { + wxDirDialog ctrl(this, "Select export folder", wxGetCwd()); + + if(ctrl.ShowModal() == wxID_CANCEL) + { + return; + } + + for(int sel = m_list->GetNextSelected(-1); sel != wxNOT_FOUND; sel = m_list->GetNextSelected(sel)) + { + Export(m_names[sel], ctrl.GetPath() + '\\' + m_names[sel]); + } + } + else + { + int sel = m_list->GetFirstSelected(); + wxFileDialog ctrl(this, "Select export file", wxEmptyString, m_names[sel], wxFileSelectorDefaultWildcardStr, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + + if(ctrl.ShowModal() == wxID_CANCEL) + { + return; + } + + Export(m_names[sel], ctrl.GetPath()); + } + + UpdateList(); +} + +VHDDSetInfoDialog::VHDDSetInfoDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, "HDD Settings", wxDefaultPosition) +{ + m_spin_size = new wxSpinCtrl(this); + m_ch_type = new wxChoice(this, wxID_ANY); + m_spin_block_size = new wxSpinCtrl(this); + + wxBoxSizer& s_sinf(*new wxBoxSizer(wxHORIZONTAL)); + s_sinf.Add(m_spin_size, wxSizerFlags().Border(wxALL, 5).Expand()); + s_sinf.Add(m_ch_type, wxSizerFlags().Border(wxALL, 5).Expand()); + + wxBoxSizer& s_binf(*new wxBoxSizer(wxHORIZONTAL)); + s_binf.Add(m_spin_block_size, wxSizerFlags().Border(wxALL, 5).Expand()); + + wxBoxSizer& s_btns(*new wxBoxSizer(wxHORIZONTAL)); + s_btns.Add(new wxButton(this, wxID_OK), wxSizerFlags().Align(wxALIGN_LEFT).Border(wxALL, 5)); + s_btns.Add(new wxButton(this, wxID_CANCEL), wxSizerFlags().Align(wxALIGN_RIGHT).Border(wxALL, 5)); + + wxBoxSizer& s_main(*new wxBoxSizer(wxVERTICAL)); + s_main.Add(&s_sinf, wxSizerFlags().Align(wxALIGN_TOP).Expand()); + s_main.Add(&s_binf, wxSizerFlags().Align(wxALIGN_TOP).Expand()); + s_main.Add(&s_btns, wxSizerFlags().Align(wxALIGN_BOTTOM).Expand()); + SetSizerAndFit(&s_main); + + m_ch_type->Append("B"); + m_ch_type->Append("KB"); + m_ch_type->Append("MB"); + m_ch_type->Append("GB"); + + m_spin_size->SetMin(1); + m_spin_size->SetMax(0x7fffffff); + m_spin_size->SetValue(64); + m_ch_type->SetSelection(3); + m_spin_block_size->SetMin(64); + m_spin_block_size->SetMax(0x7fffffff); + m_spin_block_size->SetValue(2048); + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VHDDSetInfoDialog::OnOk)); +} + +void VHDDSetInfoDialog::OnOk(wxCommandEvent& event) +{ + m_res_size = m_spin_size->GetValue(); + + for(int i=0; iGetSelection(); ++i) + { + m_res_size *= 1024; + } + + m_res_block_size = m_spin_block_size->GetValue(); + + EndModal(wxID_OK); +} + +void VHDDSetInfoDialog::GetResult(u64& size, u64& block_size) +{ + size = m_res_size; + block_size = m_res_block_size; +} + +VHDDManagerDialog::VHDDManagerDialog(wxWindow* parent) + : wxDialog(parent, wxID_ANY, "Virtual HDD Manager", wxDefaultPosition) +{ + m_list = new wxListView(this); + + wxBoxSizer& s_main(*new wxBoxSizer(wxVERTICAL)); + s_main.Add(m_list, 1, wxEXPAND | wxALL, 5); + + SetSizerAndFit(&s_main); + SetSize(800, 600); + + m_list->InsertColumn(0, "Path"); + //m_list->InsertColumn(1, "Size"); + //m_list->InsertColumn(2, "Block size"); + Connect(m_list->GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(VHDDManagerDialog::DClick)); + Connect(m_list->GetId(), wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(VHDDManagerDialog::OnContextMenu)); + + Connect(id_add_hdd, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDManagerDialog::AddHDD)); + Connect(id_open, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDManagerDialog::OnOpen)); + Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDManagerDialog::OnRemove)); + Connect(id_create_hdd, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDManagerDialog::OnCreateHDD)); + Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VHDDManagerDialog::OnClose)); + LoadPathes(); + UpdateList(); +} + +void VHDDManagerDialog::UpdateList() +{ + m_list->Freeze(); + m_list->DeleteAllItems(); + + for(size_t i=0; iInsertItem(i, m_pathes[i]); + } + + m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); + //m_list->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER); + //m_list->SetColumnWidth(2, wxLIST_AUTOSIZE_USEHEADER); + + m_list->Thaw(); +} + +void VHDDManagerDialog::Open(int sel) +{ + VHDDExplorer dial(this, m_pathes[sel]); + dial.ShowModal(); +} + +void VHDDManagerDialog::DClick(wxListEvent& event) +{ + Open(event.GetIndex()); +} + +void VHDDManagerDialog::AddHDD(wxCommandEvent& event) +{ + wxFileDialog ctrl(this, "Select HDDs", wxEmptyString, wxEmptyString, "Virtual HDD (*.hdd) | *.hdd", + wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE); + + if(ctrl.ShowModal() == wxID_CANCEL) + { + return; + } + + wxArrayString pathes; + ctrl.GetPaths(pathes); + for(size_t i=0; iGetFirstSelected(); + menu->Append(id_open, "Open")->Enable(idx != wxNOT_FOUND); + menu->Append(id_remove, "Remove")->Enable(idx != wxNOT_FOUND); + menu->AppendSeparator(); + menu->Append(id_add_hdd, "Add"); + menu->Append(id_create_hdd, "Create"); + PopupMenu(menu); +} + +void VHDDManagerDialog::OnOpen(wxCommandEvent& event) +{ + int idx = m_list->GetFirstSelected(); + if(idx >= 0) Open(idx); +} + +void VHDDManagerDialog::OnRemove(wxCommandEvent& event) +{ + for(int sel = m_list->GetNextSelected(-1), offs = 0; sel != wxNOT_FOUND; sel = m_list->GetNextSelected(sel), --offs) + { + m_pathes.RemoveAt(sel + offs); + } + + UpdateList(); +} + +void VHDDManagerDialog::OnCreateHDD(wxCommandEvent& event) +{ + wxFileDialog ctrl(this, "Select HDD path", wxEmptyString, "new_hdd.hdd", "Virtual HDD (*.hdd) | *.hdd", + wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + + if(ctrl.ShowModal() == wxID_CANCEL) + { + return; + } + + VHDDSetInfoDialog dial(this); + + if(dial.ShowModal() == wxID_OK) + { + u64 size, bsize; + dial.GetResult(size, bsize); + vfsHDDManager::CreateHDD(ctrl.GetPath(), size, bsize); + m_pathes.AddCpy(ctrl.GetPath()); + UpdateList(); + } +} + +void VHDDManagerDialog::OnClose(wxCloseEvent& event) +{ + SavePathes(); + event.Skip(); +} + +void VHDDManagerDialog::LoadPathes() +{ + IniEntry path_count; + path_count.Init("path_count", "HDDManager"); + int count = 0; + count = path_count.LoadValue(count); + + m_pathes.SetCount(count); + + for(size_t i=0; i path_entry; + path_entry.Init(wxString::Format("path[%d]", i), "HDDManager"); + new (m_pathes + i) wxString(path_entry.LoadValue(wxEmptyString)); + } +} + +void VHDDManagerDialog::SavePathes() +{ + IniEntry path_count; + path_count.Init("path_count", "HDDManager"); + path_count.SaveValue(m_pathes.GetCount()); + + for(size_t i=0; i path_entry; + path_entry.Init(wxString::Format("path[%d]", i), "HDDManager"); + path_entry.SaveValue(m_pathes[i]); + } +} \ No newline at end of file diff --git a/rpcs3/Gui/VHDDManager.h b/rpcs3/Gui/VHDDManager.h new file mode 100644 index 0000000000..744760f27e --- /dev/null +++ b/rpcs3/Gui/VHDDManager.h @@ -0,0 +1,87 @@ +#pragma once +#include +#include "Emu/HDD/HDD.h" + +class VHDDListDropTarget : public wxDropTarget +{ + wxListView* m_parent; + int m_src_indx; + +public: + VHDDListDropTarget(wxListView* parent); + virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); + virtual void OnLeave(); + virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def); + void SetSrcIndx(int src_indx) + { + m_src_indx = src_indx; + } +}; + +class VHDDExplorer : public wxDialog +{ + Array m_entries; + wxArrayString m_names; + wxListView* m_list; + vfsHDD* m_hdd; + VHDDListDropTarget* m_drop_target; + +public: + VHDDExplorer(wxWindow* parent, const wxString& hdd_path); + + void UpdateList(); + void Import(const wxString& path, const wxString& to); + void Export(const wxString& path, const wxString& to); + + void OnListDrag(wxListEvent& event); + void OnDropFiles(wxDropFilesEvent& event); + void OpenDir(int sel); + void DClick(wxListEvent& event); + void OnContextMenu(wxCommandEvent& event); + void OnOpen(wxCommandEvent& event); + void OnRename(wxCommandEvent& event); + void OnRemove(wxCommandEvent& event); + void OnCreateDir(wxCommandEvent& event); + void OnCreateFile(wxCommandEvent& event); + void OnImport(wxCommandEvent& event); + void OnExport(wxCommandEvent& event); +}; + +class VHDDSetInfoDialog : public wxDialog +{ + wxSpinCtrl* m_spin_size; + wxChoice* m_ch_type; + wxSpinCtrl* m_spin_block_size; + + u64 m_res_size; + u64 m_res_block_size; +public: + VHDDSetInfoDialog(wxWindow* parent); + + void OnOk(wxCommandEvent& event); + + void GetResult(u64& size, u64& block_size); +}; + +class VHDDManagerDialog : public wxDialog +{ + Array m_pathes; + wxListView* m_list; + +public: + VHDDManagerDialog(wxWindow* parent); + + void UpdateList(); + + void Open(int sel); + void DClick(wxListEvent& event); + void AddHDD(wxCommandEvent& event); + void OnContextMenu(wxCommandEvent& event); + void OnOpen(wxCommandEvent& event); + void OnRemove(wxCommandEvent& event); + void OnCreateHDD(wxCommandEvent& event); + + void OnClose(wxCloseEvent& event); + void LoadPathes(); + void SavePathes(); +}; diff --git a/rpcs3/Ini.cpp b/rpcs3/Ini.cpp index d141b5bc4a..05a4ed6fb8 100644 --- a/rpcs3/Ini.cpp +++ b/rpcs3/Ini.cpp @@ -7,7 +7,12 @@ Inis Ini; static bool StringToBool(const wxString str) { - if(!str.CmpNoCase("enable") || !str.CmpNoCase("e") || !str.CmpNoCase("1")) + if( + !str.CmpNoCase("enable") || + !str.CmpNoCase("e") || + !str.CmpNoCase("1") || + !str.CmpNoCase("true") || + !str.CmpNoCase("t") ) { return true; } diff --git a/rpcs3/Loader/ELF32.cpp b/rpcs3/Loader/ELF32.cpp index 514ed3df17..74bb8a3112 100644 --- a/rpcs3/Loader/ELF32.cpp +++ b/rpcs3/Loader/ELF32.cpp @@ -135,6 +135,16 @@ bool ELF32Loader::LoadPhdrData(u64 offset) if(phdr_arr[i].p_type == 0x00000001) //LOAD { + if(phdr_arr[i].p_vaddr < min_addr) + { + min_addr = phdr_arr[i].p_vaddr; + } + + if(phdr_arr[i].p_vaddr + phdr_arr[i].p_memsz > max_addr) + { + max_addr = phdr_arr[i].p_vaddr + phdr_arr[i].p_memsz; + } + if(phdr_arr[i].p_vaddr != phdr_arr[i].p_paddr) { ConLog.Warning @@ -148,6 +158,47 @@ bool ELF32Loader::LoadPhdrData(u64 offset) elf32_f.Seek(phdr_arr[i].p_offset); elf32_f.Read(&Memory[phdr_arr[i].p_vaddr + offset], phdr_arr[i].p_filesz); } + else if(phdr_arr[i].p_type == 0x00000004) + { + elf32_f.Seek(phdr_arr[i].p_offset); + Elf32_Note note; + note.Load(elf32_f); + + if(note.type != 1) + { + ConLog.Error("ELF32: Bad NOTE type (%d)", note.type); + break; + } + + if(note.namesz != sizeof(note.name)) + { + ConLog.Error("ELF32: Bad NOTE namesz (%d)", note.namesz); + break; + } + + if(note.descsz != sizeof(note.desc) && note.descsz != 32) + { + ConLog.Error("ELF32: Bad NOTE descsz (%d)", note.descsz); + break; + } + + //if(note.desc.flags) + //{ + // ConLog.Error("ELF32: Bad NOTE flags (0x%x)", note.desc.flags); + // break; + //} + + if(note.descsz == sizeof(note.desc)) + { + ConLog.Warning("name = %s", note.name); + ConLog.Warning("ls_size = %d", note.desc.ls_size); + ConLog.Warning("stack_size = %d", note.desc.stack_size); + } + else + { + ConLog.Warning("desc = '%s'", note.desc_text); + } + } #ifdef LOADER_DEBUG ConLog.SkipLn(); #endif @@ -161,27 +212,28 @@ bool ELF32Loader::LoadShdrData(u64 offset) for(u32 i=0; i max_addr) + { + max_addr = shdr.sh_addr + shdr.sh_size; } - */ } //TODO diff --git a/rpcs3/Loader/ELF32.h b/rpcs3/Loader/ELF32.h index dc13b78ef7..586d5f4bb9 100644 --- a/rpcs3/Loader/ELF32.h +++ b/rpcs3/Loader/ELF32.h @@ -75,6 +75,52 @@ struct Elf32_Ehdr u32 GetEntry() const { return e_entry; } }; +struct Elf32_Desc +{ + u32 revision; + u32 ls_size; + u32 stack_size; + u32 flags; + + void Load(vfsStream& f) + { + revision = Read32(f); + ls_size = Read32(f); + stack_size = Read32(f); + flags = Read32(f); + } +}; + +struct Elf32_Note +{ + u32 namesz; + u32 descsz; + u32 type; + u8 name[8]; + union + { + Elf32_Desc desc; + char desc_text[32]; + }; + + void Load(vfsStream& f) + { + namesz = Read32(f); + descsz = Read32(f); + type = Read32(f); + f.Read(name, 8); + + if(descsz == 32) + { + f.Read(desc_text, descsz); + } + else + { + desc.Load(f); + } + } +}; + struct Elf32_Shdr { u32 sh_name; diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index e12b58f923..b1cf1ff8ef 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -155,8 +155,8 @@ bool ELF64Loader::LoadShdrInfo(s64 offset) shdr_name_arr.Clear(); if(ehdr.e_shoff == 0 && ehdr.e_shnum) { - ConLog.Error("LoadShdr64 error: Section header offset is null!"); - return false; + ConLog.Warning("LoadShdr64 error: Section header offset is null!"); + return true; } elf64_f.Seek(offset < 0 ? ehdr.e_shoff : offset); @@ -207,6 +207,16 @@ bool ELF64Loader::LoadPhdrData(u64 offset) { phdr_arr[i].Show(); + if(phdr_arr[i].p_vaddr < min_addr) + { + min_addr = phdr_arr[i].p_vaddr; + } + + if(phdr_arr[i].p_vaddr + phdr_arr[i].p_memsz > max_addr) + { + max_addr = phdr_arr[i].p_vaddr + phdr_arr[i].p_memsz; + } + if(phdr_arr[i].p_vaddr != phdr_arr[i].p_paddr) { ConLog.Warning @@ -329,7 +339,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset) Module* module = GetModuleByName(module_name); if(module) { - module->SetLoaded(); + //module->SetLoaded(); } else { @@ -372,7 +382,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset) mem32_t out_tbl(tbl + i*8); out_tbl += dst + i*section; - out_tbl += nid; + out_tbl += GetFuncNumById(nid); mem32_t out_dst(dst + i*section); out_dst += OR(11, 2, 2, 0); @@ -425,6 +435,22 @@ bool ELF64Loader::LoadShdrData(u64 offset) if(size == 0 || !Memory.IsGoodAddr(offset + addr, size)) continue; + if(shdr.sh_addr < min_addr) + { + min_addr = shdr.sh_addr; + } + + if(shdr.sh_addr + shdr.sh_size > max_addr) + { + max_addr = shdr.sh_addr + shdr.sh_size; + } + + if((shdr.sh_type == SHT_RELA) || (shdr.sh_type == SHT_REL)) + { + ConLog.Error("ELF64 ERROR: Relocation"); + continue; + } + switch(shdr.sh_type) { case SHT_NOBITS: @@ -437,6 +463,10 @@ bool ELF64Loader::LoadShdrData(u64 offset) elf64_f.Read(&Memory[addr], shdr.sh_size); */ break; + + case SHT_RELA: + ConLog.Warning("ELF64: RELA"); + break; } } diff --git a/rpcs3/Loader/Loader.h b/rpcs3/Loader/Loader.h index d96d5b15b6..febec7c85c 100644 --- a/rpcs3/Loader/Loader.h +++ b/rpcs3/Loader/Loader.h @@ -144,11 +144,15 @@ class LoaderBase { protected: u32 entry; + u32 min_addr; + u32 max_addr; Elf_Machine machine; LoaderBase() : machine(MACHINE_Unknown) , entry(0) + , min_addr(0) + , max_addr(0) { } @@ -157,6 +161,8 @@ public: virtual bool LoadData(u64 offset = 0) { return false; } Elf_Machine GetMachine() { return machine; } u32 GetEntry() { return entry; } + u32 GetMinAddr() { return min_addr; } + u32 GetMaxAddr() { return min_addr; } }; class Loader : public LoaderBase diff --git a/rpcs3/Loader/SELF.cpp b/rpcs3/Loader/SELF.cpp index 842d74263a..e6f522252d 100644 --- a/rpcs3/Loader/SELF.cpp +++ b/rpcs3/Loader/SELF.cpp @@ -30,13 +30,16 @@ bool SELFLoader::LoadData(u64 offset) if( !l.LoadEhdrInfo(self_hdr.se_elfoff) || !l.LoadPhdrInfo(self_hdr.se_phdroff) || !l.LoadShdrInfo(self_hdr.se_shdroff) || - !l.LoadData(offset) ) + !l.LoadData(self_hdr.se_appinfooff) ) { ConLog.Error("Broken SELF file."); return false; } + machine = l.GetMachine(); + entry = l.GetEntry(); + return true; ConLog.Error("Boot SELF not supported yet!"); diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index 8222acffc0..f716e8b532 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -22,15 +22,7 @@ bool Rpcs3App::OnInit() SetTopWindow(m_MainFrame); Emu.Init(); - try - { - (new CompilerELF(m_MainFrame))->Show(); - } - catch(...) - { - ConLog.Warning("CompilerELF is broken."); - } - + (new CompilerELF(m_MainFrame))->Show(); m_debugger_frame = new DebuggerPanel(m_MainFrame); ConLogFrame = new LogFrame(m_MainFrame); diff --git a/rpcs3/rpcs3.h b/rpcs3/rpcs3.h index 4f3a4649d4..6d1ff5911a 100644 --- a/rpcs3/rpcs3.h +++ b/rpcs3/rpcs3.h @@ -47,6 +47,7 @@ enum DbgCommand DID_EXEC_THREAD, DID_REGISTRED_CALLBACK, DID_UNREGISTRED_CALLBACK, + DID_EXIT_THR_SYSCALL, DID_LAST_COMMAND, }; @@ -57,7 +58,7 @@ public: MainFrame* m_MainFrame; DebuggerPanel* m_debugger_frame; - virtual bool OnInit(); + virtual bool OnInit(); virtual void Exit(); void SendDbgCommand(DbgCommand id, PPCThread* thr=nullptr); diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 50c21ec9bf..09fce76d29 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -197,10 +197,12 @@ + + @@ -219,11 +221,13 @@ + + @@ -240,7 +244,11 @@ + + + + @@ -254,6 +262,9 @@ + + + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index df23b4814f..d9e380c208 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -44,6 +44,9 @@ {dfd581c4-aed0-4229-bb30-7ee5816049e1} + + {718bc358-b7ef-4988-8547-2148d14bb08b} + @@ -250,6 +253,39 @@ Emu\CPU + + Emu\SysCalls\lv2 + + + Emu\SysCalls + + + Emu\SysCalls\Modules + + + Emu\CPU + + + Emu\CPU + + + Emu\HDD + + + Gui + + + Gui + + + Gui + + + Emu\SysCalls\Modules + + + Emu\SysCalls\Modules +