Vulkan 1.0.26 - A Specification (with WSI extensions)

1649 篇文章 12 订阅
1623 篇文章 23 订阅

https://vulkan.lunarg.com/doc/view/1.0.26.0/linux/vkspec.chunked/index.html


Vulkan 1.0.26 - A Specification (with WSI extensions)

The Khronos Vulkan Working Group

Revision History
Revision 1.0.26Fri, 09 Sep 2016 15:20:45 +0000T
from git branch: 1.0 commit: e29c2489e238509c41aeb8c7bce9d669a496344b

Table of Contents

1. Introduction
1.1. What is the Vulkan Graphics System?
1.1.1. The Programmer’s View of Vulkan 1.1.2. The Implementor’s View of Vulkan 1.1.3. Our View of Vulkan
1.2. Filing Bug Reports 1.3. Terminology 1.4. Normative References
2. Fundamentals
2.1. Architecture Model 2.2. Execution Model
2.2.1. Queue Operation
2.3. Object Model
2.3.1. Object Lifetime
2.4. Command Syntax and Duration
2.4.1. Lifetime of Retrieved Results
2.5. Threading Behavior 2.6. Errors
2.6.1. Valid Usage 2.6.2. Return Codes
2.7. Numeric Representation and Computation
2.7.1. Floating-Point Computation 2.7.2. 16-Bit Floating-Point Numbers 2.7.3. Unsigned 11-Bit Floating-Point Numbers 2.7.4. Unsigned 10-Bit Floating-Point Numbers 2.7.5. General Requirements
2.8. Fixed-Point Data Conversions
2.8.1. Conversion from Normalized Fixed-Point to Floating-Point 2.8.2. Conversion from Floating-Point to Normalized Fixed-Point
2.9. API Version Numbers and Semantics 2.10. Common Object Types
2.10.1. Offsets 2.10.2. Extents 2.10.3. Rectangles
3. Initialization
3.1. Command Function Pointers 3.2. Instances
4. Devices and Queues
4.1. Physical Devices 4.2. Devices
4.2.1. Device Creation 4.2.2. Device Use 4.2.3. Lost Device 4.2.4. Device Destruction
4.3. Queues
4.3.1. Queue Family Properties 4.3.2. Queue Creation 4.3.3. Queue Family Index 4.3.4. Queue Priority 4.3.5. Queue Submission 4.3.6. Queue Destruction
5. Command Buffers
5.1. Command Pools 5.2. Command Buffer Allocation and Management 5.3. Command Buffer Recording 5.4. Command Buffer Submission 5.5. Queue Forward Progress 5.6. Secondary Command Buffer Execution
6. Synchronization and Cache Control
6.1. Fences 6.2. Semaphores 6.3. Events 6.4. Execution And Memory Dependencies 6.5. Pipeline Barriers
6.5.1. Subpass Self-dependency 6.5.2. Pipeline Stage Flags 6.5.3. Memory Barriers 6.5.4. Global Memory Barriers 6.5.5. Buffer Memory Barriers 6.5.6. Image Memory Barriers 6.5.7. Wait Idle Operations
6.6. Host Write Ordering Guarantees
7. Render Pass
7.1. Render Pass Creation 7.2. Render Pass Compatibility 7.3. Framebuffers 7.4. Render Pass Commands
8. Shaders
8.1. Shader Modules 8.2. Shader Execution 8.3. Shader Memory Access Ordering 8.4. Shader Inputs and Outputs 8.5. Vertex Shaders
8.5.1. Vertex Shader Execution
8.6. Tessellation Control Shaders
8.6.1. Tessellation Control Shader Execution
8.7. Tessellation Evaluation Shaders
8.7.1. Tessellation Evaluation Shader Execution
8.8. Geometry Shaders
8.8.1. Geometry Shader Execution
8.9. Fragment Shaders
8.9.1. Fragment Shader Execution 8.9.2. Early Fragment Tests
8.10. Compute Shaders 8.11. Interpolation Decorations 8.12. Static Use 8.13. Invocation and Derivative Groups
9. Pipelines
9.1. Compute Pipelines 9.2. Graphics Pipelines
9.2.1. Valid Combinations of Stages for Graphics Pipelines
9.3. Pipeline destruction 9.4. Multiple Pipeline Creation 9.5. Pipeline Derivatives 9.6. Pipeline Cache 9.7. Specialization Constants 9.8. Pipeline Binding
10. Memory Allocation
10.1. Host Memory 10.2. Device Memory
10.2.1. Host Access to Device Memory Objects 10.2.2. Lazily Allocated Memory
11. Resource Creation
11.1. Buffers 11.2. Buffer Views 11.3. Images 11.4. Image Layouts 11.5. Image Views 11.6. Resource Memory Association 11.7. Resource Sharing Mode 11.8. Memory Aliasing
12. Samplers 13. Resource Descriptors
13.1. Descriptor Types
13.1.1. Storage Image 13.1.2. Sampler 13.1.3. Sampled Image 13.1.4. Combined Image Sampler 13.1.5. Uniform Texel Buffer 13.1.6. Storage Texel Buffer 13.1.7. Uniform Buffer 13.1.8. Storage Buffer 13.1.9. Dynamic Uniform Buffer 13.1.10. Dynamic Storage Buffer 13.1.11. Input Attachment
13.2. Descriptor Sets
13.2.1. Descriptor Set Layout 13.2.2. Pipeline Layouts 13.2.3. Allocation of Descriptor Sets 13.2.4. Descriptor Set Updates 13.2.5. Descriptor Set Binding 13.2.6. Push Constant Updates
14. Shader Interfaces
14.1. Shader Input and Output Interfaces
14.1.1. Built-in Interface Block 14.1.2. User-defined Variable Interface 14.1.3. Interface Matching 14.1.4. Location Assignment 14.1.5. Component Assignment
14.2. Vertex Input Interface 14.3. Fragment Output Interface 14.4. Fragment Input Attachment Interface 14.5. Shader Resource Interface
14.5.1. Push Constant Interface 14.5.2. Descriptor Set Interface 14.5.3. DescriptorSet and Binding Assignment 14.5.4. Offset and Stride Assignment
14.6. Built-In Variables
15. Image Operations
15.1. Image Operations Overview
15.1.1. Texel Coordinate Systems
15.2. Conversion Formulas
15.2.1. RGB to Shared Exponent Conversion 15.2.2. Shared Exponent to RGB
15.3. Texel Input Operations
15.3.1. Texel Input Validation Operations 15.3.2. Format Conversion 15.3.3. Texel Replacement 15.3.4. Depth Compare Operation 15.3.5. Conversion to RGBA 15.3.6. Component Swizzle 15.3.7. Sparse Residency
15.4. Texel Output Operations
15.4.1. Texel Output Validation Operations 15.4.2. Integer Texel Coordinate Validation 15.4.3. Sparse Texel Operation 15.4.4. Texel Output Format Conversion
15.5. Derivative Operations 15.6. Normalized Texel Coordinate Operations
15.6.1. Projection Operation 15.6.2. Derivative Image Operations 15.6.3. Cube Map Face Selection and Transformations 15.6.4. Cube Map Face Selection 15.6.5. Cube Map Coordinate Transformation 15.6.6. Cube Map Derivative Transformation 15.6.7. Scale Factor Operation, Level-of-Detail Operation and Image Level(s) Selection 15.6.8. (s,t,r,q,a) to (u,v,w,a) Transformation
15.7. Unnormalized Texel Coordinate Operations
15.7.1. (u,v,w,a) to (i,j,k,l,n) Transformation And Array Layer Selection
15.8. Image Sample Operations
15.8.1. Wrapping Operation 15.8.2. Texel Gathering 15.8.3. Texel Filtering 15.8.4. Texel Anisotropic Filtering
15.9. Image Operation Steps
16. Queries
16.1. Query Pools 16.2. Query Operation 16.3. Occlusion Queries 16.4. Pipeline Statistics Queries 16.5. Timestamp Queries
17. Clear Commands
17.1. Clearing Images Outside A Render Pass Instance 17.2. Clearing Images Inside A Render Pass Instance 17.3. Clear Values 17.4. Filling Buffers 17.5. Updating Buffers
18. Copy Commands
18.1. Common Operation 18.2. Copying Data Between Buffers 18.3. Copying Data Between Images 18.4. Copying Data Between Buffers and Images 18.5. Image Copies with Scaling 18.6. Resolving Multisample Images
19. Drawing Commands
19.1. Primitive Topologies
19.1.1. Points 19.1.2. Separate Lines 19.1.3. Line Strips 19.1.4. Triangle Strips 19.1.5. Triangle Fans 19.1.6. Separate Triangles 19.1.7. Lines With Adjacency 19.1.8. Line Strips With Adjacency 19.1.9. Triangle List With Adjacency 19.1.10. Triangle Strips With Adjacency 19.1.11. Separate Patches 19.1.12. General Considerations For Polygon Primitives
19.2. Programmable Primitive Shading
20. Fixed-Function Vertex Processing
20.1. Vertex Attributes
20.1.1. Attribute Location and Component Assignment
20.2. Vertex Input Description 20.3. Example
21. Tessellation
21.1. Tessellator 21.2. Tessellator Patch Discard 21.3. Tessellator Spacing 21.4. Triangle Tessellation 21.5. Quad Tessellation 21.6. Isoline Tessellation 21.7. Tessellation Pipeline State
22. Geometry Shading
22.1. Geometry Shader Input Primitives 22.2. Geometry Shader Output Primitives 22.3. Multiple Invocations of Geometry Shaders 22.4. Geometry Shader Primitive Ordering
23. Fixed-Function Vertex Post-Processing
23.1. Flat Shading 23.2. Primitive Clipping 23.3. Clipping Shader Outputs 23.4. Coordinate Transformations 23.5. Controlling the Viewport
24. Rasterization
24.1. Discarding Primitives Before Rasterization 24.2. Rasterization Order 24.3. Multisampling 24.4. Sample Shading 24.5. Points
24.5.1. Basic Point Rasterization
24.6. Line Segments
24.6.1. Basic Line Segment Rasterization
24.7. Polygons
24.7.1. Basic Polygon Rasterization 24.7.2. Polygon Mode 24.7.3. Depth Bias
25. Fragment Operations
25.1. Early Per-Fragment Tests 25.2. Scissor Test 25.3. Sample Mask 25.4. Early Fragment Test Mode 25.5. Late Per-Fragment Tests 25.6. Multisample Coverage 25.7. Depth and Stencil Operations 25.8. Depth Bounds Test 25.9. Stencil Test 25.10. Depth Test 25.11. Sample Counting
26. The Framebuffer
26.1. Blending
26.1.1. Blend Factors 26.1.2. Dual-Source Blending 26.1.3. Blend Operations
26.2. Logical Operations
27. Dispatching Commands 28. Sparse Resources
28.1. Sparse Resource Features 28.2. Sparse Buffers and Fully-Resident Images
28.2.1. Sparse Buffer and Fully-Resident Image Block Size
28.3. Sparse Partially-Resident Buffers 28.4. Sparse Partially-Resident Images
28.4.1. Accessing Unbound Regions 28.4.2. Mip Tail Regions 28.4.3. Standard Sparse Image Block Shapes 28.4.4. Custom Sparse Image Block Shapes 28.4.5. Multiple Aspects
28.5. Sparse Memory Aliasing 28.6. Sparse Resource Implementation Guidelines 28.7. Sparse Resource API
28.7.1. Physical Device Features 28.7.2. Physical Device Sparse Properties 28.7.3. Sparse Image Format Properties 28.7.4. Sparse Resource Creation 28.7.5. Sparse Resource Memory Requirements 28.7.6. Binding Resource Memory
28.8. Examples
28.8.1. Basic Sparse Resources 28.8.2. Advanced Sparse Resources
29. Window System Integration (WSI)
29.1. WSI Platform 29.2. WSI Surface
29.2.1. Android Platform 29.2.2. Mir Platform 29.2.3. Wayland Platform 29.2.4. Win32 Platform 29.2.5. XCB Platform 29.2.6. Xlib Platform 29.2.7. Platform-Independent Information
29.3. Presenting Directly to Display Devices
29.3.1. Display Enumeration 29.3.2. Display Surfaces
29.4. Querying for WSI Support
29.4.1. Android Platform 29.4.2. Mir Platform 29.4.3. Wayland Platform 29.4.4. Win32 Platform 29.4.5. XCB Platform 29.4.6. Xlib Platform
29.5. Surface Queries 29.6. WSI Swapchain
30. Extended Functionality
30.1. Layers
30.1.1. Device Layer Deprecation
30.2. Extensions
30.2.1. Instance Extensions and Device Extensions
31. Features, Limits, and Formats
31.1. Features
31.1.1. Feature Requirements
31.2. Limits
31.2.1. Limit Requirements
31.3. Formats
31.3.1. Format Definition 31.3.2. Format Properties 31.3.3. Required Format Support
31.4. Additional Image Capabilities
31.4.1. Supported Sample Counts 31.4.2. Allowed Extent Values Based On Image Type
A. Vulkan Environment for SPIR-V
A.1. Required Versions and Formats A.2. Capabilities A.3. Validation Rules within a Module A.4. Precision and Operation of SPIR-V Instructions
B. Compressed Image Formats
B.1. Block-Compressed Image Formats B.2. ETC Compressed Image Formats B.3. ASTC Compressed Image Formats
C. Layers & Extensions
C.1. VK_KHR_sampler_mirror_clamp_to_edge
C.1.1. New Enum Constants C.1.2. Example C.1.3. Version History
C.2. Window System Integration (WSI) Extensions
C.2.1. Editors C.2.2. VK_KHR_surface C.2.3. VK_KHR_swapchain C.2.4. VK_KHR_display C.2.5. VK_KHR_display_swapchain C.2.6. VK_KHR_android_surface C.2.7. VK_KHR_mir_surface C.2.8. VK_KHR_wayland_surface C.2.9. VK_KHR_win32_surface C.2.10. VK_KHR_xcb_surface C.2.11. VK_KHR_xlib_surface
D. API Boilerplate
D.1. Structure Types D.2. Flag Types D.3. Macro Definitions in vulkan.h
D.3.1. Vulkan Version Number Macros D.3.2. Vulkan Header File Version Number D.3.3. Vulkan Handle macros
D.4. Platform-Specific Macro Definitions in vk_platform.h
D.4.1. Platform-Specific Calling Conventions D.4.2. Platform-Specific Header Control D.4.3. Window System-Specific Header Control
E. Invariance
E.1. Repeatability E.2. Multi-pass Algorithms E.3. Invariance Rules E.4. Tessellation Invariance
Glossary Common Abbreviations Prefixes F. Credits

List of Tables

3.1.  vkGetInstanceProcAddr behavior 3.2.  vkGetDeviceProcAddr behavior 6.1.  Event Object Status Codes 6.2.  Supported pipeline stage flags 6.3.  Supported access flags 9.1.  Layout for pipeline cache header version VK_PIPELINE_CACHE_HEADER_VERSION_ONE 11.1.  Image and image view parameter compatibility requirements 11.2.  Component Mappings Equivalent To VK_COMPONENT_SWIZZLE_IDENTITY 13.1.  Pipeline Layout Resource Limits 14.1.  Shader Input and Output Locations 14.2.  Shader Resource and Descriptor Type Correspondence 14.3.  Shader Resource and Storage Class Correspondence 14.4.  Shader Resource Limits 15.1.  Border Color BB 15.2.  Border Texel Components After Replacement 15.3.  Texel Color After Conversion To RGBA 15.4.  Cube map face and coordinate selection 15.5.  Cube map derivative selection 19.1.  Triangles generated by triangle strips with adjacency. 20.1.  Input attribute components accessed by 32-bit input variables 20.2.  Input attributes accessed by 32-bit input matrix variables 20.3.  Input attribute locations and components accessed by 64-bit input variables 23.1.  Provoking vertex selection 24.1.  Standard sample locations 26.1.  Blend Factors 26.2.  Blend Operations 26.3.  Logical Operations 28.1.  Standard Sparse Image Block Shapes (Single Sample) 28.2.  Standard Sparse Image Block Shapes (MSAA) 31.1.  Required Limit Types 31.2.  Required Limits 31.3.  Interpretation of Numeric Format 31.4.  Interpretation of Compression Scheme 31.5.  Byte mappings for non-packed/compressed color formats 31.6.  Bit mappings for packed 8-bit formats 31.7.  Bit mappings for packed 16-bit formats 31.8.  Bit mappings for packed 32-bit formats 31.9.  Compatible formats 31.10.  Key for format feature tables 31.11.  Feature bits in optimalTilingFeatures 31.12.  Feature bits in bufferFeatures 31.13.  Mandatory format support: sub-byte channels 31.14.  Mandatory format support: 1-3 byte-sized channels 31.15.  Mandatory format support: 4 byte-sized channels 31.16.  Mandatory format support: 10-bit channels 31.17.  Mandatory format support: 16-bit channels 31.18.  Mandatory format support: 32-bit channels 31.19.  Mandatory format support: 64-bit/uneven channels and depth/stencil 31.20.  Mandatory format support: BC compressed formats with VkImageType VK_IMAGE_TYPE_2D and VK_IMAGE_TYPE_3D 31.21.  Mandatory format support: ETC2 and EAC compressed formats with VkImageType VK_IMAGE_TYPE_2D 31.22.  Mandatory format support: ASTC LDR compressed formats with VkImageType VK_IMAGE_TYPE_2D A.1.  SPIR-V Capabilities which are not required, and corresponding feature names A.2.  Precision of core SPIR-V Instructions A.3.  Precision of GLSL.std.450 Instructions A.4.  SPIR-V and Vulkan Image Format Compatibility B.1.  Mapping of Vulkan BC formats to descriptions B.2.  Mapping of Vulkan ETC formats to descriptions B.3.  Mapping of Vulkan ASTC formats to descriptions D.1.  Window System Extensions and Required Compile-Time Symbol Definitions

ADB,即 Android Debug Bridge,它是 Android 开发/测试人员不可替代的强大工具,也是 Android 设备玩家的好玩具。 注:有部分命令的支持情况可能与 Android 系统版本及定制 ROM 的实现有关。 基本用法 命令语法 adb 命令的基本语法如下: adb [-d|-e|-s ] 如果只有一个设备/模拟器连接时,可以省略掉 [-d|-e|-s ] 这一部分,直接使用 adb 。 为命令指定目标设备 如果有多个设备/模拟器连接,则需要为命令指定目标设备。 参数 含义 -d 指定当前唯一通过 USB 连接的 Android 设备为命令目标 -e 指定当前唯一运行的模拟器为命令目标 -s 指定相应 serialNumber 号的设备/模拟器为命令目标 在多个设备/模拟器连接的情况下较常用的是 -s 参数,serialNumber 可以通过 adb devices 命令获取。如: $ adb devices List of devices attached cf264b8f device emulator-5554 device 10.129.164.6:5555 device 输出里的 cf264b8f、emulator-5554 和 10.129.164.6:5555 即为 serialNumber。 比如这时想指定 cf264b8f 这个设备来运行 adb 命令获取屏幕分辨率: adb -s cf264b8f shell wm size 又如想给 10.129.164.6:5555 这个设备安装应用(这种形式的 serialNumber 格式为 :,一般为无线连接的设备或 Genymotion 等第三方 Android 模拟器): adb -s 10.129.164.6:5555 install test.apk 遇到多设备/模拟器的情况均使用这几个参数为命令指定目标设备,下文中为简化描述,不再重复。 启动/停止 启动 adb server 命令: adb start-server (一般无需手动执行此命令,在运行 adb 命令时若发现 adb server 没有启动会自动调起。) 停止 adb server 命令: adb kill-server 查看 adb 版本 命令: adb version 示例输出: Android Debug Bridge version 1.0.36 Revision 8f855a3d9b35-android 以 root 权限运行 adbd adb 的运行原理是 PC 端的 adb server 与手机端的守护进程 adbd 建立连接,然后 PC 端的 adb client 通过 adb server 转发命令,adbd 接收命令后解析运行。 所以如果 adbd 以普通权限执行,有些需要 root 权限才能执行的命令无法直接用 adb xxx 执行。这时可以 adb shell 然后 su 后执行命令,也可以让 adbd 以 root 权限执行,这个就能随意执行高权限命令了。 命令: adb root 正常输出: restarting adbd as root 现在再运行 adb shell,看看命令行提示符是不是变成 # 了? 有些手机 root 后也无法通过 adb root 命令让 adbd 以 root 权限执行,比如三星的部分机型,会提示 adbd cannot run as root in production builds,此时可以先安装 adbd Insecure,然后 adb root 试试。 相应地,如果要恢复 adbd 为非 root 权限的话,可以使用 adb unroot 命令。 指定 adb server 的网络端口 命令: adb -P start-server 默认端口为 5037。 设备连接管理 查询已连接设备/模拟器 命令: adb devices 输出示例: List of devices attached cf264b8f device emulator-5554 device 10.129.164.6:5555 device 输出格式为 [serialNumber] [state],serialNumber 即我们常说的 SN,state 有如下几种: offline —— 表示设备未连接成功或无响应。 device —— 设备已连接。注意这个状态并不能标识 Android 系统已经完全启动和可操作,在设备启动过程中设备实例就可连接到 adb,但启动完毕后系统才处于可操作状态。 no device —— 没有设备/模拟器连接。 以上输出显示当前已经连接了三台设备/模拟器,cf264b8f、emulator-5554 和 10.129.164.6:5555 分别是它们的 SN。从 emulator-5554 这个名字可以看出它是一个 Android 模拟器,而 10.129.164.6:5555 这种形为 : 的 serialNumber 一般是无线连接的设备或 Genymotion 等第三方 Android 模拟器。 常见异常输出: 没有设备/模拟器连接成功。 List of devices attached 设备/模拟器未连接到 adb 或无响应。 List of devices attached cf264b8f offline USB 连接 通过 USB 连接来正常使用 adb 需要保证几点: 硬件状态正常。 包括 Android 设备处于正常开机状态,USB 连接线和各种接口完好。 Android 设备的开发者选项和 USB 调试模式已开启。 可以到「设置」-「开发者选项」-「Android 调试」查看。 如果在设置里找不到开发者选项,那需要通过一个彩蛋来让它显示出来:在「设置」-「关于手机」连续点击「版本号」7 次。 设备驱动状态正常。 这一点貌似在 Linux 和 Mac OS X 下不用操心,在 Windows 下有可能遇到需要安装驱动的情况,确认这一点可以右键「计算机」-「属性」,到「设备管理器」里查看相关设备上是否有黄色感叹号或问号,如果没有就说明驱动状态已经好了。否则可以下载一个手机助手类程序来安装驱动先。 通过 USB 线连接好电脑和设备后确认状态。 adb devices 如果能看到 xxxxxx device 说明连接成功。 无线连接(需要借助 USB 线) 除了可以通过 USB 连接设备与电脑来使用 adb,也可以通过无线连接——虽然连接过程中也有需要使用 USB 的步骤,但是连接成功之后你的设备就可以在一定范围内摆脱 USB 连接线的限制啦! 操作步骤: 将 Android 设备与要运行 adb 的电脑连接到同一个局域网,比如连到同一个 WiFi。 将设备与电脑通过 USB 线连接。 应确保连接成功(可运行 adb devices 看是否能列出该设备)。 让设备在 5555 端口监听 TCP/IP 连接: adb tcpip 5555 断开 USB 连接。 找到设备的 IP 地址。 一般能在「设置」-「关于手机」-「状态信息」-「IP地址」找到,也可以使用下文里 查看设备信息 - IP 地址 一节里的方法用 adb 命令来查看。 通过 IP 地址连接设备。 adb connect 这里的 就是上一步中找到的设备 IP 地址。 确认连接状态。 adb devices 如果能看到 :5555 device 说明连接成功。 如果连接不了,请确认 Android 设备与电脑是连接到了同一个 WiFi,然后再次执行 adb connect 那一步; 如果还是不行的话,通过 adb kill-server 重新启动 adb 然后从头再来一次试试。 断开无线连接 命令: adb disconnect 无线连接(无需借助 USB 线) 注:需要 root 权限。 上一节「无线连接(需要借助 USB 线)」是官方文档里介绍的方法,需要借助于 USB 数据线来实现无线连接。 既然我们想要实现无线连接,那能不能所有步骤下来都是无线的呢?答案是能的。 在 Android 设备上安装一个终端模拟器。 已经安装过的设备可以跳过此步。我使用的终端模拟器下载地址是:Terminal Emulator for Android Downloads 将 Android 设备与要运行 adb 的电脑连接到同一个局域网,比如连到同一个 WiFi。 打开 Android 设备上的终端模拟器,在里面依次运行命令: su setprop service.adb.tcp.port 5555 找到 Android 设备的 IP 地址。 一般能在「设置」-「关于手机」-「状态信息」-「IP地址」找到,也可以使用下文里 查看设备信息 - IP 地址 一节里的方法用 adb 命令来查看。 在电脑上通过 adb 和 IP 地址连接 Android 设备。 adb connect 这里的 就是上一步中找到的设备 IP 地址。 如果能看到 connected to :5555 这样的输出则表示连接成功。 节注一: 有的设备,比如小米 5S + MIUI 8.0 + Android 6.0.1 MXB48T,可能在第 5 步之前需要重启 adbd 服务,在设备的终端模拟器上运行: restart adbd 如果 restart 无效,尝试以下命令: start adbd stop adbd 应用管理 查看应用列表 查看应用列表的基本命令格式是 adb shell pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [--user USER_ID] [FILTER] 即在 adb shell pm list packages 的基础上可以加一些参数进行过滤查看不同的列表,支持的过滤参数如下: 参数 显示列表 无 所有应用 -f 显示应用关联的 apk 文件 -d 只显示 disabled 的应用 -e 只显示 enabled 的应用 -s 只显示系统应用 -3 只显示第三方应用 -i 显示应用的 installer -u 包含已卸载应用 包名包含 字符串 所有应用 命令: adb shell pm list packages 输出示例: package:com.android.smoketest package:com.example.android.livecubes package:com.android.providers.telephony package:com.google.android.googlequicksearchbox package:com.android.providers.calendar package:com.android.providers.media package:com.android.protips package:com.android.documentsui package:com.android.gallery package:com.android.externalstorage ... // other packages here ... 系统应用 命令: adb shell pm list packages -s 第三方应用 命令: adb shell pm list packages -3 包名包含某字符串的应用 比如要查看包名包含字符串 mazhuang 的应用列表,命令: adb shell pm list packages mazhuang 当然也可以使用 grep 来过滤: adb shell pm list packages | grep mazhuang 安装 APK 命令格式: adb install [-lrtsdg] 参数: adb install 后面可以跟一些可选参数来控制安装 APK 的行为,可用参数及含义如下: 参数 含义 -l 将应用安装到保护目录 /mnt/asec -r 允许覆盖安装 -t 允许安装 AndroidManifest.xml 里 application 指定 android:testOnly="true" 的应用 -s 将应用安装到 sdcard -d 允许降级覆盖安装 -g 授予所有运行时权限 运行命令后如果见到类似如下输出(状态为 Success)代表安装成功: [100%] /data/local/tmp/1.apk pkg: /data/local/tmp/1.apk Success 上面是当前最新版 v1.0.36 的 adb 的输出,会显示 push apk 文件到手机的进度百分比。 使用旧版本 adb 的输出则是这样的: 12040 KB/s (22205609 bytes in 1.801s) pkg: /data/local/tmp/SogouInput_android_v8.3_sweb.apk Success 而如果状态为 Failure 则表示安装失败,比如: [100%] /data/local/tmp/map-20160831.apk pkg: /data/local/tmp/map-20160831.apk Failure [INSTALL_FAILED_ALREADY_EXISTS] 常见安装失败输出代码、含义及可能的解决办法如下: 输出 含义 解决办法 INSTALL_FAILED_ALREADY_EXISTS 应用已经存在,或卸载了但没卸载干净 adb install 时使用 -r 参数,或者先 adb uninstall 再安装 INSTALL_FAILED_INVALID_APK 无效的 APK 文件 INSTALL_FAILED_INVALID_URI 无效的 APK 文件名 确保 APK 文件名里无中文 INSTALL_FAILED_INSUFFICIENT_STORAGE 空间不足 清理空间 INSTALL_FAILED_DUPLICATE_PACKAGE 已经存在同名程序 INSTALL_FAILED_NO_SHARED_USER 请求的共享用户不存在 INSTALL_FAILED_UPDATE_INCOMPATIBLE 以前安装过同名应用,但卸载时数据没有移除 先 adb uninstall 再安装 INSTALL_FAILED_SHARED_USER_INCOMPATIBLE 请求的共享用户存在但签名不一致 INSTALL_FAILED_MISSING_SHARED_LIBRARY 安装包使用了设备上不可用的共享库 INSTALL_FAILED_REPLACE_COULDNT_DELETE 替换时无法删除 INSTALL_FAILED_DEXOPT dex 优化验证失败或空间不足 INSTALL_FAILED_OLDER_SDK 设备系统版本低于应用要求 INSTALL_FAILED_CONFLICTING_PROVIDER 设备里已经存在与应用里同名的 content provider INSTALL_FAILED_NEWER_SDK 设备系统版本高于应用要求 INSTALL_FAILED_TEST_ONLY 应用是 test-only 的,但安装时没有指定 -t 参数 INSTALL_FAILED_CPU_ABI_INCOMPATIBLE 包含不兼容设备 CPU 应用程序二进制接口的 native code INSTALL_FAILED_MISSING_FEATURE 应用使用了设备不可用的功能 INSTALL_FAILED_CONTAINER_ERROR 1. sdcard 访问失败; 2. 应用签名与 ROM 签名一致,被当作内置应用 1. 确认 sdcard 可用,或者安装到内置存储; 2. 打包时不与 ROM 使用相同签名 INSTALL_FAILED_INVALID_INSTALL_LOCATION 1. 不能安装到指定位置; 2. 应用签名与 ROM 签名一致,被当作内置应用 1. 切换安装位置,添加或删除 -s 参数; 2. 打包时不与 ROM 使用相同签名 INSTALL_FAILED_MEDIA_UNAVAILABLE 安装位置不可用 一般为 sdcard,确认 sdcard 可用或安装到内置存储 INSTALL_FAILED_VERIFICATION_TIMEOUT 验证安装包超时 INSTALL_FAILED_VERIFICATION_FAILURE 验证安装包失败 INSTALL_FAILED_PACKAGE_CHANGED 应用与调用程序期望的不一致 INSTALL_FAILED_UID_CHANGED 以前安装过该应用,与本次分配的 UID 不一致 清除以前安装过的残留文件 INSTALL_FAILED_VERSION_DOWNGRADE 已经安装了该应用更高版本 使用 -d 参数 INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE 已安装 target SDK 支持运行时权限的同名应用,要安装的版本不支持运行时权限 INSTALL_PARSE_FAILED_NOT_APK 指定路径不是文件,或不是以 .apk 结尾 INSTALL_PARSE_FAILED_BAD_MANIFEST 无法解析的 AndroidManifest.xml 文件 INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION 解析器遇到异常 INSTALL_PARSE_FAILED_NO_CERTIFICATES 安装包没有签名 INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES 已安装该应用,且签名与 APK 文件不一致 先卸载设备上的该应用,再安装 INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING 解析 APK 文件时遇到 CertificateEncodingException INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME manifest 文件里没有或者使用了无效的包名 INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID manifest 文件里指定了无效的共享用户 ID INSTALL_PARSE_FAILED_MANIFEST_MALFORMED 解析 manifest 文件时遇到结构性错误 INSTALL_PARSE_FAILED_MANIFEST_EMPTY 在 manifest 文件里找不到找可操作标签(instrumentation 或 application) INSTALL_FAILED_INTERNAL_ERROR 因系统问题安装失败 INSTALL_FAILED_USER_RESTRICTED 用户被限制安装应用 INSTALL_FAILED_DUPLICATE_PERMISSION 应用尝试定义一个已经存在的权限名称 INSTALL_FAILED_NO_MATCHING_ABIS 应用包含设备的应用程序二进制接口不支持的 native code INSTALL_CANCELED_BY_USER 应用安装需要在设备上确认,但未操作设备或点了取消 在设备上同意安装 INSTALL_FAILED_ACWF_INCOMPATIBLE 应用程序与设备不兼容 does not contain AndroidManifest.xml 无效的 APK 文件 is not a valid zip file 无效的 APK 文件 Offline 设备未连接成功 先将设备与 adb 连接成功 unauthorized 设备未授权允许调试 error: device not found 没有连接成功的设备 先将设备与 adb 连接成功 protocol failure 设备已断开连接 先将设备与 adb 连接成功 Unknown option: -s Android 2.2 以下不支持安装到 sdcard 不使用 -s 参数 No space left on devicerm 空间不足 清理空间 Permission denied … sdcard … sdcard 不可用 参考:PackageManager.java adb install 内部原理简介 adb install 实际是分三步完成: push apk 文件到 /data/local/tmp。 调用 pm install 安装。 删除 /data/local/tmp 下的对应 apk 文件。 所以,必要的时候也可以根据这个步骤,手动分步执行安装过程。 卸载应用 命令: adb uninstall [-k] 表示应用的包名,-k 参数可选,表示卸载应用但保留数据和缓存目录。 命令示例: adb uninstall com.qihoo360.mobilesafe 表示卸载 360 手机卫士。 清除应用数据与缓存 命令: adb shell pm clear 表示应用名包,这条命令的效果相当于在设置里的应用信息界面点击了「清除缓存」和「清除数据」。 命令示例: adb shell pm clear com.qihoo360.mobilesafe 表示清除 360 手机卫士的数据和缓存。 查看前台 Activity 命令: adb shell dumpsys activity activities | grep mFocusedActivity 输出示例: mFocusedActivity: ActivityRecord{8079d7e u0 com.cyanogenmod.trebuchet/com.android.launcher3.Launcher t42} 其中的 com.cyanogenmod.trebuchet/com.android.launcher3.Launcher 就是当前处于前台的 Activity。 查看正在运行的 Services 命令: adb shell dumpsys activity services [] 参数不是必须的,指定 表示查看与某个包名相关的 Services,不指定表示查看所有 Services。 不一定要给出完整的包名,比如运行 adb shell dumpsys activity services org.mazhuang,那么包名 org.mazhuang.demo1、org.mazhuang.demo2 和 org.mazhuang123 等相关的 Services 都会列出来。 与应用交互 主要是使用 am 命令,常用的 如下: command 用途 start [options] 启动 指定的 Activity startservice [options] 启动 指定的 Service broadcast [options] 发送 指定的广播 force-stop 停止 相关的进程 参数很灵活,和写 Android 程序时代码里的 Intent 相对应。 用于决定 intent 对象的选项如下: 参数 含义 -a 指定 action,比如 android.intent.action.VIEW -c 指定 category,比如 android.intent.category.APP_CONTACTS -n 指定完整 component 名,用于明确指定启动哪个 Activity,如 com.example.app/.ExampleActivity 里还能带数据,就像写代码时的 Bundle 一样: 参数 含义 --esn null 值(只有 key 名) -e|--es string 值 --ez boolean 值 --ei integer 值 --el long 值 --ef float 值 --eu URI --ecn component name --eia [,<EXTRA_INT_VALUE...] integer 数组 --ela [,<EXTRA_LONG_VALUE...] long 数组 调起 Activity 命令格式: adb shell am start [options] 例如: adb shell am start -n com.tencent.mm/.ui.LauncherUI 表示调起微信主界面。 adb shell am start -n org.mazhuang.boottimemeasure/.MainActivity --es "toast" "hello, world" 表示调起 org.mazhuang.boottimemeasure/.MainActivity 并传给它 string 数据键值对 toast - hello, world。 调起 Service 命令格式: adb shell am startservice [options] 例如: adb shell am startservice -n com.tencent.mm/.plugin.accountsync.model.AccountAuthenticatorService 表示调起微信的某 Service。 发送广播 命令格式: adb shell am broadcast [options] 可以向所有组件广播,也可以只向指定组件广播。 例如,向所有组件广播 BOOT_COMPLETED: adb shell am broadcast -a android.intent.action.BOOT_COMPLETED 又例如,只向 org.mazhuang.boottimemeasure/.BootCompletedReceiver 广播 BOOT_COMPLETED: adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -n org.mazhuang.boottimemeasure/.BootCompletedReceiver 这类用法在测试的时候很实用,比如某个广播的场景很难制造,可以考虑通过这种方式来发送广播。 既能发送系统预定义的广播,也能发送自定义广播。如下是部分系统预定义广播及正常触发时机: action 触发时机 android.net.conn.CONNECTIVITY_CHANGE 网络连接发生变化 android.intent.action.SCREEN_ON 屏幕点亮 android.intent.action.SCREEN_OFF 屏幕熄灭 android.intent.action.BATTERY_LOW 电量低,会弹出电量低提示框 android.intent.action.BATTERY_OKAY 电量恢复了 android.intent.action.BOOT_COMPLETED 设备启动完毕 android.intent.action.DEVICE_STORAGE_LOW 存储空间过低 android.intent.action.DEVICE_STORAGE_OK 存储空间恢复 android.intent.action.PACKAGE_ADDED 安装了新的应用 android.net.wifi.STATE_CHANGE WiFi 连接状态发生变化 android.net.wifi.WIFI_STATE_CHANGED WiFi 状态变为启用/关闭/正在启动/正在关闭/未知 android.intent.action.BATTERY_CHANGED 电池电量发生变化 android.intent.action.INPUT_METHOD_CHANGED 系统输入法发生变化 android.intent.action.ACTION_POWER_CONNECTED 外部电源连接 android.intent.action.ACTION_POWER_DISCONNECTED 外部电源断开连接 android.intent.action.DREAMING_STARTED 系统开始休眠 android.intent.action.DREAMING_STOPPED 系统停止休眠 android.intent.action.WALLPAPER_CHANGED 壁纸发生变化 android.intent.action.HEADSET_PLUG 插入耳机 android.intent.action.MEDIA_UNMOUNTED 卸载外部介质 android.intent.action.MEDIA_MOUNTED 挂载外部介质 android.os.action.POWER_SAVE_MODE_CHANGED 省电模式开启 (以上广播均可使用 adb 触发) 强制停止应用 命令: adb shell am force-stop 命令示例: adb shell am force-stop com.qihoo360.mobilesafe 表示停止 360 安全卫士的一切进程与服务。 文件管理 复制设备里的文件到电脑 命令: adb pull [电脑上的目录] 其中 电脑上的目录 参数可以省略,默认复制到当前目录。 例: adb pull /sdcard/sr.mp4 ~/tmp/ 小技巧:设备上的文件路径可能需要 root 权限才能访问,如果你的设备已经 root 过,可以先使用 adb shell 和 su 命令在 adb shell 里获取 root 权限后,先 cp /path/on/device /sdcard/filename 将文件复制到 sdcard,然后 adb pull /sdcard/filename /path/on/pc。 复制电脑里的文件到设备 命令: adb push 例: adb push ~/sr.mp4 /sdcard/ 小技巧:设备上的文件路径普通权限可能无法直接写入,如果你的设备已经 root 过,可以先 adb push /path/on/pc /sdcard/filename,然后 adb shell 和 su 在 adb shell 里获取 root 权限后,cp /sdcard/filename /path/on/device。 模拟按键/输入 在 adb shell 里有个很实用的命令叫 input,通过它可以做一些有趣的事情。 input 命令的完整 help 信息如下: Usage: input [] [...] The sources are: mouse keyboard joystick touchnavigation touchpad trackball stylus dpad gesture touchscreen gamepad The commands and default sources are: text (Default: touchscreen) keyevent [--longpress] ... (Default: keyboard) tap (Default: touchscreen) swipe [duration(ms)] (Default: touchscreen) press (Default: trackball) roll (Default: trackball) 比如使用 adb shell input keyevent 命令,不同的 keycode 能实现不同的功能,完整的 keycode 列表详见 KeyEvent,摘引部分我觉得有意思的如下: keycode 含义 3 HOME 键 4 返回键 5 打开拨号应用 6 挂断电话 24 增加音量 25 降低音量 26 电源键 27 拍照(需要在相机应用里) 64 打开浏览器 82 菜单键 85 播放/暂停 86 停止播放 87 播放下一首 88 播放上一首 122 移动光标到行首或列表顶部 123 移动光标到行末或列表底部 126 恢复播放 127 暂停播放 164 静音 176 打开系统设置 187 切换应用 207 打开联系人 208 打开日历 209 打开音乐 210 打开计算器 220 降低屏幕亮度 221 提高屏幕亮度 223 系统休眠 224 点亮屏幕 231 打开语音助手 276 如果没有 wakelock 则让系统休眠 下面是 input 命令的一些用法举例。 电源键 命令: adb shell input keyevent 26 执行效果相当于按电源键。
realesrgan-ncnn-vulkan-20211212-windows是一个基于ncnn框架和Vulkan图形API开发的图像超分辨率增强模型。它是由GitHub用户realsrgan开发的最新版本,最新发布日期为2021年12月12日,专为Windows操作系统而设计。 该模型的主要应用是图像超分辨率增强,通过提高图像的分辨率和细节,使图像看起来更加清晰和真实。它采用深度学习和卷积神经网络等先进的技术,能够将低分辨率的图像转换成高分辨率的图像,从而提升图像的质量和视觉效果。 realesrgan-ncnn-vulkan-20211212-windows的开发使用了ncnn框架和Vulkan图形API,这使得它能够在Windows系统上实现快速且高效的图像处理。ncnn是一个轻量级的深度学习框架,专注于在移动平台和嵌入式设备上实现高性能和低延迟的推理。而Vulkan图形API是一种跨平台的图形渲染和计算API,可以充分利用计算设备的性能,提供高效的图像处理和渲染能力。 realesrgan-ncnn-vulkan-20211212-windows的使用可以通过命令行或者图形界面进行,用户可以根据自己的需求和偏好选择适合的方式。该模型提供了训练好的权重参数,用户可以直接加载这些参数并进行图像超分辨率增强。此外,该模型还支持批量处理和视频处理,方便用户对多个图像进行处理。 总之,realesrgan-ncnn-vulkan-20211212-windows是一个高效、快速且易于使用的图像超分辨率增强模型,适用于Windows系统,并利用了ncnn框架和Vulkan图形API的优势,为用户提供了出色的图像处理效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值