Java Code Examples for java.nio.LongBuffer#get()
The following examples show how to use
java.nio.LongBuffer#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandPool.java From oreon-engine with GNU General Public License v3.0 | 6 votes |
public CommandPool(VkDevice device, int queueFamilyIndex){ this.device = device; VkCommandPoolCreateInfo cmdPoolInfo = VkCommandPoolCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO) .queueFamilyIndex(queueFamilyIndex) .flags(VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); LongBuffer pCmdPool = memAllocLong(1); int err = vkCreateCommandPool(device, cmdPoolInfo, null, pCmdPool); handle = pCmdPool.get(0); cmdPoolInfo.free(); memFree(pCmdPool); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create command pool: " + VkUtil.translateVulkanResult(err)); } }
Example 2
Source File: BitMapOps.java From succinct with Apache License 2.0 | 6 votes |
/** * Get value at specified index of serialized bitmap. * * @param bitmap Serialized bitmap. * @param pos Position into bitmap. * @param bits Width in bits of value. * @return Value at specified position. */ public static long getValPos(LongBuffer bitmap, int pos, int bits) { assert (pos >= 0); int basePos = bitmap.position(); long val; long s = (long) pos; long e = s + (bits - 1); if ((s / 64) == (e / 64)) { val = bitmap.get(basePos + (int) (s / 64L)) << (s % 64); val = val >>> (63 - e % 64 + s % 64); } else { val = bitmap.get(basePos + (int) (s / 64L)) << (s % 64); val = val >>> (s % 64 - (e % 64 + 1)); val = val | (bitmap.get(basePos + (int) (e / 64L)) >>> (63 - e % 64)); } assert (val >= 0); return val; }
Example 3
Source File: DescriptorSet.java From oreon-engine with GNU General Public License v3.0 | 6 votes |
public DescriptorSet(VkDevice device, long descriptorPool, LongBuffer layouts) { this.device = device; this.descriptorPool = descriptorPool; VkDescriptorSetAllocateInfo allocateInfo = VkDescriptorSetAllocateInfo.calloc() .sType(VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO) .descriptorPool(descriptorPool) .pSetLayouts(layouts); LongBuffer pDescriptorSet = memAllocLong(1); int err = vkAllocateDescriptorSets(device, allocateInfo, pDescriptorSet); handle = pDescriptorSet.get(0); allocateInfo.free(); memFree(pDescriptorSet); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create Descriptor Set: " + VkUtil.translateVulkanResult(err)); } }
Example 4
Source File: ShaderModule.java From oreon-engine with GNU General Public License v3.0 | 6 votes |
private void createShaderModule(String filePath) { ByteBuffer shaderCode = null; try { shaderCode = ResourceLoader.ioResourceToByteBuffer(filePath, 1024); } catch (IOException e) { e.printStackTrace(); } int err; VkShaderModuleCreateInfo moduleCreateInfo = VkShaderModuleCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO) .pNext(0) .pCode(shaderCode) .flags(0); LongBuffer pShaderModule = memAllocLong(1); err = vkCreateShaderModule(device, moduleCreateInfo, null, pShaderModule); handle = pShaderModule.get(0); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create shader module: " + VkUtil.translateVulkanResult(err)); } memFree(pShaderModule); moduleCreateInfo.free(); }
Example 5
Source File: Gl_500_primitive_shading_nv.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { ByteBuffer pointer = gl4.glMapNamedBufferRange(bufferName.get(Buffer.TRANSFORM), 0, Mat4.SIZE * 1, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); // Make sure the uniform buffer is uploaded gl4.glUnmapNamedBuffer(bufferName.get(Buffer.TRANSFORM)); } gl4.glViewport(0, 0, windowSize.x, windowSize.y); gl4.glClearBufferfv(GL_COLOR, 0, black); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glBeginQuery(GL_PRIMITIVES_GENERATED, queryName.get(0)); { gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0); } gl4.glEndQuery(GL_PRIMITIVES_GENERATED); LongBuffer primitivesGeneratedBuffer = GLBuffers.newDirectLongBuffer(1); gl4.glGetQueryObjectui64v(queryName.get(0), GL_QUERY_RESULT, primitivesGeneratedBuffer); long primitivesGenerated = primitivesGeneratedBuffer.get(0); return primitivesGenerated > 0; }
Example 6
Source File: ImmutableBitSet.java From Bats with Apache License 2.0 | 5 votes |
/** * Returns a new immutable bit set containing all the bits in the given long * buffer. */ public static ImmutableBitSet valueOf(LongBuffer longs) { longs = longs.slice(); int n = longs.remaining(); while (n > 0 && longs.get(n - 1) == 0) { --n; } if (n == 0) { return EMPTY; } long[] words = new long[n]; longs.get(words); return new ImmutableBitSet(words); }
Example 7
Source File: VkPipeline.java From oreon-engine with GNU General Public License v3.0 | 5 votes |
public void createComputePipeline(ShaderModule shader){ VkComputePipelineCreateInfo.Buffer pipelineCreateInfo = VkComputePipelineCreateInfo.calloc(1) .sType(VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO) .stage(shader.getShaderStageInfo()) .layout(layoutHandle); LongBuffer pPipelines = memAllocLong(1); VkUtil.vkCheckResult(vkCreateComputePipelines(device, VK_NULL_HANDLE, pipelineCreateInfo, null, pPipelines)); handle = pPipelines.get(0); pipelineCreateInfo.free(); }
Example 8
Source File: Identifier.java From android-beacon-library with Apache License 2.0 | 5 votes |
/** * Gives you the Identifier as a UUID if possible. * * @throws UnsupportedOperationException if the byte array backing this Identifier is not exactly * 16 bytes long. */ public UUID toUuid() { if (mValue.length != 16) { throw new UnsupportedOperationException("Only Identifiers backed by a byte array with length of exactly 16 can be UUIDs."); } LongBuffer buf = ByteBuffer.wrap(mValue).asLongBuffer(); return new UUID(buf.get(), buf.get()); }
Example 9
Source File: VkImageView.java From oreon-engine with GNU General Public License v3.0 | 5 votes |
public VkImageView(VkDevice device, int imageFormat, long image, int aspectMask, int mipLevels){ this.device = device; VkImageViewCreateInfo imageViewCreateInfo = VkImageViewCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO) .pNext(0) .viewType(VK_IMAGE_VIEW_TYPE_2D) .format(imageFormat) .image(image); imageViewCreateInfo .components() .r(VK_COMPONENT_SWIZZLE_R) .g(VK_COMPONENT_SWIZZLE_G) .b(VK_COMPONENT_SWIZZLE_B) .a(VK_COMPONENT_SWIZZLE_A); imageViewCreateInfo .subresourceRange() .aspectMask(aspectMask) .baseMipLevel(0) .levelCount(mipLevels) .baseArrayLayer(0) .layerCount(1); LongBuffer pImageView = memAllocLong(1); int err = vkCreateImageView(device, imageViewCreateInfo, null, pImageView); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create image view: " + VkUtil.translateVulkanResult(err)); } handle = pImageView.get(0); memFree(pImageView); imageViewCreateInfo.free(); }
Example 10
Source File: ImmutableBitSet.java From calcite with Apache License 2.0 | 5 votes |
/** * Returns a new immutable bit set containing all the bits in the given long * buffer. */ public static ImmutableBitSet valueOf(LongBuffer longs) { longs = longs.slice(); int n = longs.remaining(); while (n > 0 && longs.get(n - 1) == 0) { --n; } if (n == 0) { return EMPTY; } long[] words = new long[n]; longs.get(words); return new ImmutableBitSet(words); }
Example 11
Source File: VkSampler.java From oreon-engine with GNU General Public License v3.0 | 5 votes |
public VkSampler(VkDevice device, int filterMode, boolean anisotropic, float maxAnisotropy, int mipmapMode, float maxLod, int addressMode){ this.device = device; VkSamplerCreateInfo createInfo = VkSamplerCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO) .magFilter(filterMode) .minFilter(filterMode) .addressModeU(addressMode) .addressModeV(addressMode) .addressModeW(addressMode) .anisotropyEnable(anisotropic) .maxAnisotropy(maxAnisotropy) .borderColor(VK_BORDER_COLOR_INT_OPAQUE_BLACK) .unnormalizedCoordinates(false) .compareEnable(false) .compareOp(VK_COMPARE_OP_ALWAYS) .mipmapMode(mipmapMode) .mipLodBias(0) .minLod(0) .maxLod(maxLod); LongBuffer pBuffer = memAllocLong(1); int err = vkCreateSampler(device, createInfo, null, pBuffer); handle = pBuffer.get(0); memFree(pBuffer); createInfo.free(); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create sampler: " + VkUtil.translateVulkanResult(err)); } }
Example 12
Source File: LongJustCopy.java From metrics with Apache License 2.0 | 5 votes |
private void copy(LongBuffer src, LongOutputStream dst) { long[] buf = new long[1024]; int len; while ((len = src.remaining()) > 0) { if (len > buf.length) { len = buf.length; } src.get(buf, 0, len); dst.write(buf, 0, len); } }
Example 13
Source File: FlumeEventQueue.java From mt-flume with Apache License 2.0 | 5 votes |
/** * Read the inflights file and return a * {@link com.google.common.collect.SetMultimap} * of transactionIDs to events that were inflight. * * @return - map of inflight events per txnID. * */ public SetMultimap<Long, Long> deserialize() throws IOException, BadCheckpointException { SetMultimap<Long, Long> inflights = HashMultimap.create(); if (!fileChannel.isOpen()) { file = new RandomAccessFile(inflightEventsFile, "rw"); fileChannel = file.getChannel(); } if(file.length() == 0) { return inflights; } file.seek(0); byte[] checksum = new byte[16]; file.read(checksum); ByteBuffer buffer = ByteBuffer.allocate( (int)(file.length() - file.getFilePointer())); fileChannel.read(buffer); byte[] fileChecksum = digest.digest(buffer.array()); if (!Arrays.equals(checksum, fileChecksum)) { throw new BadCheckpointException("Checksum of inflights file differs" + " from the checksum expected."); } buffer.position(0); LongBuffer longBuffer = buffer.asLongBuffer(); try { while (true) { long txnID = longBuffer.get(); int numEvents = (int)(longBuffer.get()); for(int i = 0; i < numEvents; i++) { long val = longBuffer.get(); inflights.put(txnID, val); } } } catch (BufferUnderflowException ex) { LOG.debug("Reached end of inflights buffer. Long buffer position =" + String.valueOf(longBuffer.position())); } return inflights; }
Example 14
Source File: VkContext.java From oreon-engine with GNU General Public License v3.0 | 4 votes |
public static void create(){ init(); window = new VkWindow(); resources = new VkResources(); camera = new VkCamera(); deviceManager = new DeviceManager(); if (!glfwInit()) throw new IllegalStateException("Unable to initialize GLFW"); if (!glfwVulkanSupported()) { throw new AssertionError("GLFW failed to find the Vulkan loader"); } ByteBuffer[] layers = { memUTF8("VK_LAYER_LUNARG_standard_validation") // memUTF8("VK_LAYER_LUNARG_assistant_layer") }; enabledLayers = layers; vkInstance = new VulkanInstance( VkUtil.getValidationLayerNames( config.isVkValidation(), layers)); getWindow().create(); LongBuffer pSurface = memAllocLong(1); int err = glfwCreateWindowSurface(vkInstance.getHandle(), BaseContext.getWindow().getId(), null, pSurface); surface = pSurface.get(0); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create surface: " + VkUtil.translateVulkanResult(err)); } PhysicalDevice physicalDevice = new PhysicalDevice(vkInstance.getHandle(), surface); LogicalDevice logicalDevice = new LogicalDevice(physicalDevice, 0); VkDeviceBundle majorDevice = new VkDeviceBundle(physicalDevice, logicalDevice); VkContext.getDeviceManager().addDevice(DeviceType.MAJOR_GRAPHICS_DEVICE, majorDevice); DescriptorPool descriptorPool = new DescriptorPool( majorDevice.getLogicalDevice().getHandle(), 4); descriptorPool.addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 33); descriptorPool.addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 61); descriptorPool.addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 2); descriptorPool.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 12); descriptorPool.create(); majorDevice.getLogicalDevice().addDescriptorPool(Thread.currentThread().getId(), descriptorPool); }
Example 15
Source File: LongCodec.java From metrics with Apache License 2.0 | 4 votes |
public static int decodeLength(byte[] src) { LongBuffer srcBuf = ByteBuffer.wrap(src).asLongBuffer(); return (int)srcBuf.get(); }
Example 16
Source File: NameGenerator.java From yawp with MIT License | 4 votes |
private static UUID fromByteArray(byte[] bytes) { ByteBuffer buffer = ByteBuffer.wrap(bytes); LongBuffer longBuffer = buffer.asLongBuffer(); return new UUID(longBuffer.get(0), longBuffer.get(1)); }
Example 17
Source File: FastqView.java From cramtools with Apache License 2.0 | 4 votes |
public static int readNameLength(int read, LongBuffer buf) { long entry = buf.get(read); return (int) (0x0000FFFF & (entry >> (8 * 3))); }
Example 18
Source File: BitSet.java From openjdk-8 with GNU General Public License v2.0 | 3 votes |
/** * Returns a new bit set containing all the bits in the given long * buffer between its position and limit. * * <p>More precisely, * <br>{@code BitSet.valueOf(lb).get(n) == ((lb.get(lb.position()+n/64) & (1L<<(n%64))) != 0)} * <br>for all {@code n < 64 * lb.remaining()}. * * <p>The long buffer is not modified by this method, and no * reference to the buffer is retained by the bit set. * * @param lb a long buffer containing a little-endian representation * of a sequence of bits between its position and limit, to be * used as the initial bits of the new bit set * @return a {@code BitSet} containing all the bits in the buffer in the * specified range * @since 1.7 */ public static BitSet valueOf(LongBuffer lb) { lb = lb.slice(); int n; for (n = lb.remaining(); n > 0 && lb.get(n - 1) == 0; n--) ; long[] words = new long[n]; lb.get(words); return new BitSet(words); }
Example 19
Source File: BitSet.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Returns a new bit set containing all the bits in the given long * buffer between its position and limit. * * <p>More precisely, * <br>{@code BitSet.valueOf(lb).get(n) == ((lb.get(lb.position()+n/64) & (1L<<(n%64))) != 0)} * <br>for all {@code n < 64 * lb.remaining()}. * * <p>The long buffer is not modified by this method, and no * reference to the buffer is retained by the bit set. * * @param lb a long buffer containing a little-endian representation * of a sequence of bits between its position and limit, to be * used as the initial bits of the new bit set * @return a {@code BitSet} containing all the bits in the buffer in the * specified range * @since 1.7 */ public static BitSet valueOf(LongBuffer lb) { lb = lb.slice(); int n; for (n = lb.remaining(); n > 0 && lb.get(n - 1) == 0; n--) ; long[] words = new long[n]; lb.get(words); return new BitSet(words); }
Example 20
Source File: BitSet.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Returns a new bit set containing all the bits in the given long * buffer between its position and limit. * * <p>More precisely, * <br>{@code BitSet.valueOf(lb).get(n) == ((lb.get(lb.position()+n/64) & (1L<<(n%64))) != 0)} * <br>for all {@code n < 64 * lb.remaining()}. * * <p>The long buffer is not modified by this method, and no * reference to the buffer is retained by the bit set. * * @param lb a long buffer containing a little-endian representation * of a sequence of bits between its position and limit, to be * used as the initial bits of the new bit set * @return a {@code BitSet} containing all the bits in the buffer in the * specified range * @since 1.7 */ public static BitSet valueOf(LongBuffer lb) { lb = lb.slice(); int n; for (n = lb.remaining(); n > 0 && lb.get(n - 1) == 0; n--) ; long[] words = new long[n]; lb.get(words); return new BitSet(words); }