Commit 698235ce by Sean Risser Committed by Alexis Hétu

Revert submission

Reason for revert: Didn't update a build file, which broke the build and commit queue. Bug: b/139528538 Change-Id: I45cd93a01d984175c2dba5351a4cdd1154e50f31 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38528 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 0ad604a3
...@@ -15,76 +15,8 @@ ...@@ -15,76 +15,8 @@
#include "VkDebug.hpp" #include "VkDebug.hpp"
#include <string> #include <string>
#include <atomic>
#include <stdarg.h> #include <stdarg.h>
#if defined(__unix__)
#define PTRACE
#include <sys/types.h>
#include <sys/ptrace.h>
#elif defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#elif defined(__APPLE__) || defined(__MACH__)
#include <unistd.h>
#include <sys/sysctl.h>
#endif
namespace {
bool IsUnderDebugger()
{
#if defined(PTRACE) && !defined(__APPLE__) && !defined(__MACH__)
static bool checked = false;
static bool res = false;
if (!checked)
{
// If a debugger is attached then we're already being ptraced and ptrace
// will return a non-zero value.
checked = true;
if (ptrace(PTRACE_TRACEME, 0, 1, 0) != 0)
{
res = true;
}
else
{
ptrace(PTRACE_DETACH, 0, 1, 0);
}
}
return res;
#elif defined(_WIN32) || defined(_WIN64)
return IsDebuggerPresent() != 0;
#elif defined(__APPLE__) || defined(__MACH__)
// Code comes from the Apple Technical Q&A QA1361
// Tell sysctl what info we're requestion. Specifically we're asking for
// info about this our PID.
int res = 0;
int request[4] = {
CTL_KERN,
KERN_PROC,
KERN_PROC_PID,
getpid()
};
struct kinfo_proc info;
size_t size = sizeof(info);
info.kp_proc.p_flag = 0;
// Get the info we're requesting, if sysctl fails then info.kp_proc.p_flag will remain 0.
res = sysctl(request, sizeof(request) / sizeof(*request), &info, &size, NULL, 0);
ASSERT_MSG(res == 0, "syscl returned %d", res);
// We're being debugged if the P_TRACED flag is set
return ((info.kp_proc.p_flag & P_TRACED) != 0);
#else
return false;
#endif
}
}
namespace vk namespace vk
{ {
...@@ -139,29 +71,4 @@ void abort(const char *format, ...) ...@@ -139,29 +71,4 @@ void abort(const char *format, ...)
::abort(); ::abort();
} }
void trace_assert(const char *format, ...)
{
static std::atomic<bool> asserted = {false};
va_list vararg;
va_start(vararg, format);
if (IsUnderDebugger() && !asserted.exchange(true))
{
// Abort after tracing and printing to stderr
tracev(format, vararg);
va_end(vararg);
va_start(vararg, format);
vfprintf(stderr, format, vararg);
va_end(vararg);
::abort();
}
else if (!asserted)
{
tracev(format, vararg);
va_end(vararg);
}
}
} }
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <string>
#if !defined(TRACE_OUTPUT_FILE) #if !defined(TRACE_OUTPUT_FILE)
#define TRACE_OUTPUT_FILE "debug.txt" #define TRACE_OUTPUT_FILE "debug.txt"
...@@ -44,19 +43,14 @@ namespace vk ...@@ -44,19 +43,14 @@ namespace vk
// Outputs the message to the debugging log and stderr, and calls abort(). // Outputs the message to the debugging log and stderr, and calls abort().
void abort(const char *format, ...) CHECK_PRINTF_ARGS; void abort(const char *format, ...) CHECK_PRINTF_ARGS;
// Outputs text to the debugging log, and asserts once if a debugger is attached.
void trace_assert(const char *format, ...) CHECK_PRINTF_ARGS;
} }
// A macro to output a trace of a function call and its arguments to the // A macro to output a trace of a function call and its arguments to the
// debugging log. Disabled if SWIFTSHADER_DISABLE_TRACE is defined. // debugging log. Disabled if SWIFTSHADER_DISABLE_TRACE is defined.
#if defined(SWIFTSHADER_DISABLE_TRACE) #if defined(SWIFTSHADER_DISABLE_TRACE)
#define TRACE(message, ...) (void(0)) #define TRACE(message, ...) (void(0))
#define TRACE_ASSERT(message, ...) (void(0))
#else #else
#define TRACE(message, ...) vk::trace("%s:%d TRACE: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__) #define TRACE(message, ...) vk::trace("%s:%d TRACE: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
#define TRACE_ASSERT(message, ...) vk::trace_assert("%s:%d %s TRACE_ASSERT: " message "\n", __FILE__, __LINE__, __func__, ##__VA_ARGS__)
#endif #endif
// A macro to print a warning message to the debugging log and stderr to denote // A macro to print a warning message to the debugging log and stderr to denote
......
// Copyright 2019 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// VkStringify.hpp: Utilities to turn Vulkan enums into strings
#ifndef VK_STRINGIFY_HPP_
#define VK_STRINGIFY_HPP_
#include <vulkan/vulkan.h>
#include <string>
namespace vk {
const char *Stringify(VkStructureType value);
}
#endif
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include "VkSampler.hpp" #include "VkSampler.hpp"
#include "VkSemaphore.hpp" #include "VkSemaphore.hpp"
#include "VkShaderModule.hpp" #include "VkShaderModule.hpp"
#include "VkStringify.hpp"
#include "VkRenderPass.hpp" #include "VkRenderPass.hpp"
#if defined(VK_USE_PLATFORM_METAL_EXT) || defined(VK_USE_PLATFORM_MACOS_MVK) #if defined(VK_USE_PLATFORM_METAL_EXT) || defined(VK_USE_PLATFORM_MACOS_MVK)
...@@ -638,7 +637,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c ...@@ -638,7 +637,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
break; break;
default: default:
// "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]" // "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]"
TRACE_ASSERT("Unimplemented extensionCreateInfo->sType = %s", vk::Stringify(extensionCreateInfo->sType)); UNIMPLEMENTED("extensionCreateInfo->sType %d", int(extensionCreateInfo->sType)); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
break; break;
} }
...@@ -823,7 +822,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryA ...@@ -823,7 +822,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryA
} }
#endif #endif
default: default:
TRACE_ASSERT("Unimplemented allocationInfo->sType = %s", vk::Stringify(allocationInfo->sType)); UNIMPLEMENTED("allocationInfo->sType %u", allocationInfo->sType);
break; break;
} }
......
...@@ -136,6 +136,9 @@ public: ...@@ -136,6 +136,9 @@ public:
// complete. // complete.
VkResult QueueSubmitAndWait(VkCommandBuffer commandBuffer) const; VkResult QueueSubmitAndWait(VkCommandBuffer commandBuffer) const;
private:
Device(Driver const *driver, VkDevice device, VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex);
static VkResult GetPhysicalDevices( static VkResult GetPhysicalDevices(
Driver const *driver, VkInstance instance, Driver const *driver, VkInstance instance,
std::vector<VkPhysicalDevice> &out); std::vector<VkPhysicalDevice> &out);
...@@ -143,10 +146,6 @@ public: ...@@ -143,10 +146,6 @@ public:
static int GetComputeQueueFamilyIndex( static int GetComputeQueueFamilyIndex(
Driver const *driver, VkPhysicalDevice device); Driver const *driver, VkPhysicalDevice device);
private:
Device(Driver const *driver, VkDevice device, VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex);
static std::vector<VkQueueFamilyProperties> static std::vector<VkQueueFamilyProperties>
GetPhysicalDeviceQueueFamilyProperties( GetPhysicalDeviceQueueFamilyProperties(
Driver const *driver, VkPhysicalDevice device); Driver const *driver, VkPhysicalDevice device);
......
...@@ -117,79 +117,6 @@ TEST_F(SwiftShaderVulkanTest, Version) ...@@ -117,79 +117,6 @@ TEST_F(SwiftShaderVulkanTest, Version)
driver.vkDestroyInstance(instance, nullptr); driver.vkDestroyInstance(instance, nullptr);
} }
TEST_F(SwiftShaderVulkanTest, UnsupportedDeviceExtension)
{
Driver driver;
ASSERT_TRUE(driver.loadSwiftShader());
uint32_t apiVersion = 0;
VkResult result = driver.vkEnumerateInstanceVersion(&apiVersion);
EXPECT_EQ(apiVersion, (uint32_t)VK_API_VERSION_1_1);
const VkInstanceCreateInfo createInfo = {
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
nullptr, // pNext
0, // flags
nullptr, // pApplicationInfo
0, // enabledLayerCount
nullptr, // ppEnabledLayerNames
0, // enabledExtensionCount
nullptr, // ppEnabledExtensionNames
};
VkInstance instance = VK_NULL_HANDLE;
result = driver.vkCreateInstance(&createInfo, nullptr, &instance);
EXPECT_EQ(result, VK_SUCCESS);
ASSERT_TRUE(driver.resolve(instance));
VkBaseInStructure unsupportedExt = { VK_STRUCTURE_TYPE_SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT, nullptr };
// Gather all physical devices
std::vector<VkPhysicalDevice> physicalDevices;
result = Device::GetPhysicalDevices(&driver, instance, physicalDevices);
EXPECT_EQ(result, VK_SUCCESS);
// Inspect each physical device's queue families for compute support.
for (auto physicalDevice : physicalDevices)
{
int queueFamilyIndex = Device::GetComputeQueueFamilyIndex(&driver, physicalDevice);
if (queueFamilyIndex < 0)
{
continue;
}
const float queuePrioritory = 1.0f;
const VkDeviceQueueCreateInfo deviceQueueCreateInfo = {
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType
nullptr, // pNext
0, // flags
(uint32_t)queueFamilyIndex, // queueFamilyIndex
1, // queueCount
&queuePrioritory, // pQueuePriorities
};
const VkDeviceCreateInfo deviceCreateInfo = {
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType
&unsupportedExt, // pNext
0, // flags
1, // queueCreateInfoCount
&deviceQueueCreateInfo, // pQueueCreateInfos
0, // enabledLayerCount
nullptr, // ppEnabledLayerNames
0, // enabledExtensionCount
nullptr, // ppEnabledExtensionNames
nullptr, // pEnabledFeatures
};
VkDevice device;
result = driver.vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &device);
EXPECT_EQ(result, VK_SUCCESS);
driver.vkDestroyDevice(device, nullptr);
}
driver.vkDestroyInstance(instance, nullptr);
}
std::vector<uint32_t> compileSpirv(const char* assembly) std::vector<uint32_t> compileSpirv(const char* assembly)
{ {
spvtools::SpirvTools core(SPV_ENV_VULKAN_1_0); spvtools::SpirvTools core(SPV_ENV_VULKAN_1_0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment